wk
2024-06-06 27d01f3731d0737d8ffb61fd4c15829d10a6a7dd
pages/register/register.vue
@@ -42,6 +42,48 @@
                  placeholder="请输入内容"
                  clearable></u--input>
            </u-form-item>
            <u-form-item prop="cardImg1"
               label="身份证正面"
               labelWidth="20%"
               borderBottom
               required
               @click="beforeRead">
               <u-upload :fileList="fileList5"
                  deletable
                  @afterRead="afterRead"
                  @delete="deletePic"
                  name="5"
                  multiple
                  :maxCount="1"
                  width="250"
                  height="150"
                  :previewFullImage="true">
               </u-upload>
            </u-form-item>
            <u-form-item prop="cardImg2"
               label="身份证反面"
               labelWidth="20%"
               borderBottom
               required
               @click="beforeRead">
               <u-upload :fileList="fileList6"
                  deletable
                  @afterRead="afterRead"
                  @delete="deletePic"
                  name="6"
                  multiple
                  :maxCount="1"
                  width="250"
                  height="150"
                  :previewFullImage="true">
               </u-upload>
            </u-form-item>
            <u-form-item prop="expirationTimeIdcard"
               label="身份证过期时间"
               labelWidth="20%"
               borderBottom>
               <uni-datetime-picker v-model="registerFormModel.expirationTimeIdcard" type="datetime" :start="minDate" />
            </u-form-item>
            <u-form-item prop="phone"
               label="手机号"
               labelWidth="20%"
@@ -82,6 +124,18 @@
                  placeholder="请输入内容"
                  clearable></u--input>
            </u-form-item>
            <u-form-item labelWidth="20%"
               label="车辆类型"
               borderBottom
               ref="roleRef"
               v-if="radiovalue1 == '司机'">
               <niceui-data-select-input v-model="registerFormModel.carType"
                  :localdata="radiolist2"
                  label="车辆类型选择"
                  placeholder="请选择车辆类型"
                  @change="productcarTypeChange"
                  ></niceui-data-select-input>
            </u-form-item>
            <u-form-item prop="carImg"
               label="车辆照片"
               labelWidth="20%"
@@ -120,8 +174,15 @@
                  :previewFullImage="true">
               </u-upload>
            </u-form-item>
            <u-form-item prop="roadTransportImg"
               label="道路运输证"
            <u-form-item prop="expirationTimeDriving"
               label="行驶证过期时间"
               labelWidth="20%"
               borderBottom
               v-if="radiovalue1 == '司机'">
               <uni-datetime-picker v-model="registerFormModel.expirationTimeDriving" type="datetime"  :start="minDate" />
            </u-form-item>
            <u-form-item prop="driverImg"
               label="驾驶证"
               labelWidth="24%"
               borderBottom
               v-if="radiovalue1 == '司机'"
@@ -138,6 +199,13 @@
                  height="150"
                  :previewFullImage="true">
               </u-upload>
            </u-form-item>
            <u-form-item prop="expirationTimeDriver"
               label="驾驶证过期时间"
               labelWidth="20%"
               borderBottom
               v-if="radiovalue1 == '司机'">
               <uni-datetime-picker v-model="registerFormModel.expirationTimeDriver" type="datetime"  :start="minDate" />
            </u-form-item>
            <u-form-item prop="tradeQualificationImg"
               label="从业资格证"
@@ -157,24 +225,16 @@
                  height="150"
                  :previewFullImage="true">
               </u-upload>
               <span style="color:red">
                  凡是运输有毒化学物品的车辆必须上传从业资格证并填写从业资格证有效时间
               </span>
            </u-form-item>
            <u-form-item prop="inventoryImg"
               label="环保清单"
               labelWidth="24%"
            <u-form-item prop="expirationTimeTradequalification"
               label="从业资格过期时间"
               labelWidth="20%"
               borderBottom
               v-if="radiovalue1 == '司机'"
               @click="beforeRead">
               <u-upload :fileList="fileList5"
                  deletable
                  @afterRead="afterRead"
                  @delete="deletePic"
                  name="5"
                  multiple
                  :maxCount="3"
                  width="250"
                  height="150"
                  :previewFullImage="true">
               </u-upload>
               v-if="radiovalue1 == '司机'">
               <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime"  :start="minDate" />
            </u-form-item>
            <u-form-item label="是否非煤车辆"
               v-if="radiovalue1 == '司机'"
@@ -242,6 +302,7 @@
      },
      data() {
         return {
            minDate: this.getToday(),
            // 车牌号键盘控制
            carNumShow: false,
            keyValue: '',
@@ -259,11 +320,11 @@
               tuiJianMa: '',
               confirmPassword: '',
               tradeQualificationImg: '',
               roadTransportImg: '',
               driverImg: '',
               isNonCoal: [],
               isCoalCar: 1, //是否为煤炭车辆(司机使用字段) 1 是 2 不是
               inventoryImg: '',
               countryNumberCar: 0, //车辆类型;国五 1,国六 2
               carType:0
            },
            fileList1: [],
            fileList2: [],
@@ -272,10 +333,19 @@
            fileList5: [],
            fileList6: [],
            rules: {
               inventoryImg: {
               countryNumberCar: {
                  required: false,
               },
               countryNumberCar: {
               expirationTimeIdcard: {
                  required: false,
               },
               expirationTimeDriving: {
                  required: false,
               },
               expirationTimeDriver: {
                  required: false,
               },
               expirationTimeTradequalification: {
                  required: false,
               },
               name: {
@@ -354,6 +424,18 @@
                     trigger: ['change', 'blur']
                  }
               ],
               cardImg1:{
                  type: 'string',
                  required: true,
                  message: '请上传身份证正面',
                  trigger: ['blur', 'change']
               },
               cardImg2:{
                  type: 'string',
                  required: true,
                  message: '请上传身份证反面',
                  trigger: ['blur', 'change']
               },
               carImg: {
                  type: 'string',
                  required: true,
@@ -366,18 +448,12 @@
                  message: '请上传行驶证照片',
                  trigger: ['blur', 'change']
               },
               roadTransportImg: {
               driverImg: {
                  type: 'string',
                  required: true,
                  message: '请上传道路运输证照片',
                  message: '请上传驾驶证照片',
                  trigger: ['blur', 'change']
               },
               tradeQualificationImg: {
                  type: 'string',
                  required: true,
                  message: '请上传从业资格证照片',
                  trigger: ['blur', 'change']
               },
               }
            },
            radiolist1: [{
                  name: '司机',
@@ -388,6 +464,23 @@
                  disabled: false
               }
            ],
            radiolist2: [{
                  text: '普通运输车',
                  value:1
               },
               {
                  text: '集装箱平板车',
                  value:2
               },
               {
                  text: '液氯槽车',
                  value:3
               },
               {
                  text: '液碱槽车',
                  value:4
               }
            ],
            countryNumberCarList: [{
                  name: 1,
                  label: '国五',
@@ -395,6 +488,10 @@
               {
                  name: 2,
                  label: '国六',
               },
               {
                  name: 3,
                  label: '新能源',
               }
            ],
            radiovalue1: '司机',
@@ -429,22 +526,59 @@
                  break;
            }
            return;
         }
         },
      },
      methods: {
         ...mapMutations(['changeisUploadimg']),
         getToday() {
           let now = new Date();
           let year = now.getFullYear();
           let month = this.padStart(now.getMonth() + 1); // 月份是从0开始的
           let day = this.padStart(now.getDate());
           let hour = this.padStart(now.getHours());
           let minute = this.padStart(now.getMinutes());
           let second = this.padStart(now.getSeconds());
           console.log(`${year}-${month}-${day} ${hour}:${minute}:${second}`)
           return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
         },
         padStart(value) {
           return value.toString().padStart(2, '0');
         },
         productcarTypeChange(e){
            console.log(this.registerFormModel.carType,this.radiolist2.find(v => v.value === e).value)
            this.registerFormModel.carType = this.radiolist2.find(v => v.value === e).value
         },
         registerClick() {
            if (this.registerFormModel.password == this.registerFormModel.confirmPassword) {
               if(this.registerFormModel.carType==3&&!this.registerFormModel.tradeQualificationImg||this.registerFormModel.carType==4&&!this.registerFormModel.tradeQualificationImg){
                  uni.showToast({
                     title: '请上传从业资格证!',
                     icon: 'error',
                     duration: 2000
                  });
               }else{
               this.$refs.regesterFormRef
                  .validate()
                  .then(res => {
                     console.log(this.registerFormModel);
                     this.registerClickloading = true;
                     this.registerFormModel.username = this.registerFormModel.phone;
                     apiRegister(this.registerFormModel)
                     this.registerFormModel.idCardImg = this.registerFormModel.cardImg1+","+this.registerFormModel.cardImg2;
                     if(this.registerFormModel.expirationTimeDriver){
                        this.registerFormModel.expirationTimeDriver=this.registerFormModel.expirationTimeDriver.slice(0,16)
                     }
                     if(this.registerFormModel.expirationTimeDriving){
                        this.registerFormModel.expirationTimeDriving=this.registerFormModel.expirationTimeDriving.slice(0,16)
                     }
                     if(this.registerFormModel.expirationTimeIdcard){
                        this.registerFormModel.expirationTimeIdcard=this.registerFormModel.expirationTimeIdcard.slice(0,16)
                     }
                     if(this.registerFormModel.expirationTimeTradequalification){
                        this.registerFormModel.expirationTimeTradequalification=this.registerFormModel.expirationTimeTradequalification.slice(0,16)
                     }
                        this.$reqPost('registerDriver', this.registerFormModel, 'json')
                        .then(res => {
                           this.registerClickloading = false;
                           if (res.data.code == 0) {
                           if (res.code == 0) {
                              uni.showToast({
                                 title: '注册成功,即将返回登录页',
                                 icon: 'none',
@@ -454,7 +588,7 @@
                                 uni.redirectTo({ url: '/pages/login/login' });
                              }, 1000);
                           } else {
                              this.$u.toast(res.data.msg ? res.data.msg : '添加失败');
                              this.$u.toast(res.msg ? res.msg : '添加失败');
                           }
                        })
                        .catch(err => {
@@ -465,6 +599,7 @@
                     console.log('err', err);
                     this.$u.toast('请规范输入内容');
                  });
                  }
            } else {
               this.$u.toast('两次密码不一致');
            }
@@ -538,15 +673,19 @@
                        this.registerFormModel.drivingImg = JSON.parse(res.data).data.url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     } else if (num == 3) {
                        this.registerFormModel.roadTransportImg = JSON.parse(res.data).data
                        this.registerFormModel.driverImg = JSON.parse(res.data).data
                           .url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     } else if (num == 4) {
                        this.registerFormModel.tradeQualificationImg = JSON.parse(res.data)
                           .data.url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     } else if (num == 5) {
                        this.registerFormModel.inventoryImg = JSON.parse(res.data)
                     }else if(num==5){
                        this.registerFormModel.cardImg1 = JSON.parse(res.data)
                           .data.url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     }else if(num==6){
                        this.registerFormModel.cardImg2 = JSON.parse(res.data)
                           .data.url;
                        resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                     }