| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403 |
- <template>
- <view>
- <view class="form">
- <view class="flex">
- <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
- <text class="text-lg text-bold">请选择基本信息</text>
- </view>
- <view class="card">
- <u-form :model="model" ref="uForm" >
- <u-form-item :required="true" :label-width="labelWidth" label="车牌号码" >
- <u-input type="text" v-model="model.number" disabled @click="openKeyBoard" placeholder="请填写车牌号码" ></u-input>
- </u-form-item>
- <u-form-item :required="true" :label-width="labelWidth" label="车辆类型" >
- <u-input type="select" :select-open="carTypeShow" v-model="carTypeLabel" placeholder="请选择车辆类型" @click="carTypeShow=true"></u-input>
- </u-form-item>
- <u-form-item :required="true" :label-width="labelWidth" label="车辆性质" >
- <u-input type="select" :select-open="carPropertiesShow" v-model="carPropertiesLabel" placeholder="请选择车辆性质" @click="carPropertiesShow=true"></u-input>
- </u-form-item>
- <u-form-item :required="true" :label-width="labelWidth" label="燃油类别" >
- <u-input type="select" :select-open="fuelCategoryShow" v-model="fuelCategoryLabel" placeholder="请选择燃油类别" @click="fuelCategoryShow=true"></u-input>
- </u-form-item>
- </u-form>
- </view>
- </view>
- <view class="form">
- <view class="flex">
- <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
- <text class="text-lg text-bold">请上传车辆照片</text>
- </view>
- <view class="card">
- <view style="padding: 20rpx 0;" @click="chooseImage(1)" class="flex justify-center ">
- <view class=" ">
- <upload-img
- :width="width"
- :height="height"
- :currentImage="model.carImg"
- bgsrc="/static/myCar/upload.png"
- >
- </upload-img>
- <view class="text-center padding-top-20 base-color" >
- <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
- <text v-if="$isEmpty(model.carImg)">点击上传车辆照片</text>
- <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="form">
- <view class="flex">
- <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
- <text class="text-lg text-bold">请上传行驶证正面</text>
- </view>
- <view class="card">
- <view style="padding: 20rpx 0;" @click="chooseImage(2)" class="flex justify-center ">
- <view class=" ">
- <upload-img
- :width="width"
- :height="height"
- :currentImage="model.vehicleDrivingLicense1"
- bgsrc="/static/myCar/zm.png"
- >
- </upload-img>
- <view class="text-center padding-top-20 base-color" >
- <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
- <text v-if="$isEmpty(model.carImg)">点击上传行驶证正面</text>
- <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="form">
- <view class="flex">
- <image style="width: 35rpx;height: 35rpx;display: block;padding-top: 6rpx;padding-right: 10rpx;" src="/static/myCar/tag1.png" mode=""></image>
- <text class="text-lg text-bold">请上传行驶证反面</text>
- </view>
- <view class="card">
- <view style="padding: 20rpx 0;" @click="chooseImage(3)" class="flex justify-center ">
- <view class=" ">
- <upload-img
- :width="width"
- :height="height"
- :currentImage="model.vehicleDrivingLicense2"
- bgsrc="/static/myCar/fm.png"
- >
- </upload-img>
- <view class="text-center padding-top-20 base-color" >
- <text class="cuIcon-camera padding-right-sm" style="font-size: 30rpx;"></text>
- <text v-if="$isEmpty(model.carImg)">点击上传行驶证反面</text>
- <text style="margin-top: 40rpx;display: inline-block;" v-else>点击重新上传</text>
- </view>
- </view>
- </view>
- </view>
- </view>
-
- <view >
- <view class="bg-white" style="height: 80rpx;"></view>
- <view class="" @click="submit" style="width: 90%;margin: 0 auto ;margin-bottom: 10%;">
- <view class="cu-btn round base-bg-color" style="padding: 40rpx;width: 100%;" >
- <text class="cuIcon-add"></text>
- <text v-text="model.id?'重新审核':'确认添加'"></text>
- </view>
- </view>
- </view>
- <u-select @confirm="carTypeConfirm" v-model="carTypeShow" :list="carTypeList"></u-select>
- <u-select @confirm="carPropertiesConfirm" v-model="carPropertiesShow" :list="carPropertiesList"></u-select>
- <u-select @confirm="fuelCategoryConfirm" v-model="fuelCategoryShow" :list="fuelCategoryList"></u-select>
- <keyboard-package z-index="999" ref="plateNumber" type="plateNumber" @onInput="onInput" @onDelete="onDelete" @onConfirm="onConfirm"/>
- </view>
- </template>
- <script>
- import keyboardPackage from "@/comps/keyboard-package/keyboard-package.vue"
- import uploadImg from '@/comps/uploadimg/uploadImg.vue'
- var that;
- var app = getApp();
- export default {
- components: {
- uploadImg, keyboardPackage
- },
- data() {
- return {
- labelWidth:'200',
- width:480,
- height:320,
-
- //车牌号
- carNoInputList:[],
-
- //车辆类型
- carTypeList:[],
- carTypeShow:false,
- carTypeLabel:'',
-
- //车辆性质
- carPropertiesList:[],
- carPropertiesShow:false,
- carPropertiesLabel:'',
-
- //燃油类别
- fuelCategoryList:[],
- fuelCategoryShow:false,
- fuelCategoryLabel:'',
-
- model:{
- type:'',//车辆类型的key
- number:'',//车牌号
- properties:'',//车辆性质的key,
- fuelCategory:'',//燃油类别的key
- carImg:'',//车辆照片
- vehicleDrivingLicense1:'',//行驶证正面
- vehicleDrivingLicense2:'',//行驶证反面
- personId:'',
- residentialId:'',
- },
- }
- },
- onLoad(options) {
- that = this;
- this.model.residentialId = uni.getStorageSync('residentialId')
- this.model.personId = app.globalData.userId;
- //获取字典
- this.getDict()
- this.parseParams(options)
- },
- computed: {
- plateNumberStr() {
- let str = '';
- this.carNoInputList.forEach(item=>{
- str += item.toString();
- })
- this.model.number=str
- return str;
- }
- },
- methods: {
- parseParams(options){
- if (this.$isEmpty(options)) {
- return
- }
- this.model=options
- this.carNoInputList=options.number.split('')
- this.carTypeList.forEach(item=>{
- if (item.value==options.type) {
- this.carTypeLabel=item.label
- }
- })
- this.carPropertiesList.forEach(item=>{
- if (item.value==options.properties) {
- this.carPropertiesLabel=item.label
- }
- })
- this.fuelCategoryList.forEach(item=>{
- if (item.value==options.fuelCategory) {
- this.fuelCategoryLabel=item.label
- }
- })
- },
- submit(){
- if (this.$isEmpty(this.model.number)) {
- this.$u.toast('请填写车牌号')
- return
- }
- if (this.$isEmpty(this.model.type)) {
- this.$u.toast('请选择车辆类型')
- return
- }
- if (this.$isEmpty(this.model.properties)) {
- this.$u.toast('请选择车辆性质')
- return
- }
- if (this.$isEmpty(this.model.fuelCategory)) {
- this.$u.toast('请选择燃油类型')
- return
- }
- if (this.$isEmpty(this.model.carImg)) {
- this.$u.toast('请上传车辆照片')
- return
- }
- if (this.$isEmpty(this.model.vehicleDrivingLicense1)) {
- this.$u.toast('请上传行驶证正面')
- return
- }
- if (this.$isEmpty(this.model.vehicleDrivingLicense2)) {
- this.$u.toast('请上传行驶证反面')
- return
- }
- let that = this;
- let operation = 'car/saveOrUpdate';
- app.globalData.postRequest(this.model, operation, function (res) {
- console.log(res);
- if (res.data.result) {
- that.$util.showModal('操作成功!',false).then(res=>{
- that.$util.isReloadAndBack()
- })
- } else {
- that.$util.showModal("提交失败",false);
- }
- })
- },
- getDict() {
- let carType = uni.getStorageSync("carType");
- let carProperty = uni.getStorageSync("carProperty");
- let fuelCategory = uni.getStorageSync("fuelCategory");
- if (carType && carProperty && fuelCategory) {
- this.carTypeList = carType;
- this.carPropertiesList = carProperty;
- this.fuelCategoryList = fuelCategory;
- return;
- }
-
- let operation = 'permissions/dict/getByCode?code=car_type';
- let that = this;
- let params = {};
- //车辆类型
- app.globalData.postRequest(params, operation, function (res) {
- if (res.data.code != 200) {
- app.globalData.oneFailHint(res.data.msg, function () {
- uni.switchTab({
- url:"../index/index"
- })
- });
- }
- res.data.list.forEach((item) => {
- let tmp = {
- value: item.dictKey,
- label: item.dictValue
- }
- that.carTypeList.push(tmp)
- })
- });
-
- //车辆性质
- operation = "permissions/dict/getByCode?code=car_properties"
- app.globalData.postRequest(params, operation, function (res) {
- if (res.data.code != 200) {
- app.globalData.oneFailHint(res.data.msg, function () {
- uni.switchTab({
- url:"../index/index"
- })
- });
- }
- res.data.list.forEach((item) => {
- let tmp = {
- value:item.dictKey,
- label:item.dictValue
- }
- that.carPropertiesList.push(tmp)
- })
- });
-
- //燃油类别
- operation = "permissions/dict/getByCode?code=fuel_category"
- app.globalData.postRequest(params, operation, function (res) {
- if (res.data.code != 200) {
- app.globalData.oneFailHint(res.data.msg, function () {
- uni.switchTab({
- url:"../index/index"
- })
- });
- }
- res.data.list.forEach((item)=>{
- let tmp = {
- value:item.dictKey,
- label:item.dictValue
- }
- that.fuelCategoryList.push(tmp);
- })
- });
- },
- carTypeConfirm(e){
- this.model.type=e[0].value
- this.carTypeLabel=e[0].label
- },
- carPropertiesConfirm(e){
- this.model.properties=e[0].value
- this.carPropertiesLabel=e[0].label
- },
- fuelCategoryConfirm(e){
- this.model.fuelCategory=e[0].value
- this.fuelCategoryLabel=e[0].label
- },
- //上传图片
- chooseImage(type) {
- uni.chooseImage({
- count: 1,
- //最多可以选择的图片张数,默认9
- sourceType: ['album'],
- sizeType: ['compressed'],
- //可选择原图或压缩后的图片
- success: res => {
- this.uploadImage(res.tempFilePaths[0], type);
- }
- });
- },
- /**上传图片
- * @param {Object} imgUrl 图片url
- */
- uploadImage(imgUrl, type) {
- var that = this;
- //是否需要md5加密上传人脸照
- let is_need_md5 = false;
- uni.getFileSystemManager().readFile({
- filePath: imgUrl,
- //选择图片返回的相对路径
- encoding: 'base64',
- //编码格式
- success: res => {
- //成功的回调
- app.globalData.uploadBase64('data:image/jpeg;base64,' + res.data, is_need_md5, function (result) {
- if (type == 1) {
- that.model.carImg = result.data.showUri;
- } else if (type == 2) {
- that.model.vehicleDrivingLicense1 = result.data.showUri;
- } else if (type == 3) {
- that.model.vehicleDrivingLicense2 = result.data.showUri;
- }
- });
- }
- });
- },
- //车牌号键盘
- onInput(val){
- this.carNoInputList.push(val)
- },
- onDelete(){
- this.carNoInputList.pop();
- },
- onConfirm(){
- this.model.number=this.plateNumberStr
- },
- openKeyBoard() {
- this.$refs.plateNumber.open();
- },
- }
- }
- </script>
- <style>
- page{
- background-color: #FFFFFF;
- }
- </style>
- <style lang="scss" scoped>
- .form {
- padding: 40rpx 30rpx;
- .card {
- margin-top: 20rpx;
- padding: 0 30rpx;
- box-sizing: border-box;
- border-radius: 12rpx;
- box-shadow: 0 -10rpx rgba(248, 248, 248,.9) ,0 10rpx rgba(248, 248, 248,.9) , -10rpx 0rpx rgba(248, 248, 248,.9) ,10rpx 0rpx rgba(248, 248, 248,.9);
- .item {
- padding:30rpx 0;
- display: flex;
- justify-content: space-between;
- }
- }
- }
- </style>
|