yangan
2024-06-19 8bedb5a0c09876046b397a94a9b12bb6e805d284
pages/register/register.vue
@@ -17,7 +17,6 @@
                  iconSize="20">
                  <u-radio labelSize="14px"
                     size="20px"
                     :customStyle="{ marginBottom: '8px' }"
                     v-for="(item, index) in radiolist1"
                     :key="index"
                     :label="item.name"
@@ -43,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%"
@@ -61,6 +102,7 @@
                  placeholder="请输入内容"
                  password
                  clearable></u--input>
               <span> 密码应由8-16位数字、字母、符号组成。请不要使用容易被猜到的密码</span>
            </u-form-item>
            <u-form-item prop="confirmPassword"
               label="确认密码"
@@ -82,6 +124,18 @@
               <u--input v-model="registerFormModel.carNo"
                  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="车辆照片"
@@ -121,8 +175,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 == '司机'"
@@ -140,12 +201,18 @@
                  :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="从业资格证"
               labelWidth="24%"
               borderBottom
               v-if="radiovalue1 == '司机'"
               required
               @click="beforeRead">
               <u-upload :fileList="fileList4"
                  deletable
@@ -158,20 +225,34 @@
                  height="150"
                  :previewFullImage="true">
               </u-upload>
               <span style="color:red">
                  凡是运输有毒化学物品的车辆必须上传从业资格证并填写从业资格证有效时间
               </span>
            </u-form-item>
            <u-form-item label="是否非煤车辆"
               labelWidth="30%"
            <u-form-item prop="expirationTimeTradequalification"
               label="从业资格过期时间"
               labelWidth="20%"
               borderBottom
               prop="isNonCoal">
               <u-checkbox-group v-model="registerFormModel.isNonCoal"
               v-if="radiovalue1 == '司机'">
               <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime"  :start="minDate" />
            </u-form-item>
            <u-form-item labelWidth="20%"
               v-if="radiovalue1 == '司机'"
               label="环保类型"
               borderBottom
               prop="countryNumberCar">
               <u-radio-group v-model="registerFormModel.countryNumberCar"
                  placement="row"
                  size="40"
                  @change="isNonCoalChange">
                  <u-checkbox :label="registerFormModel.isNonCoal.length!==0?'是':'否'"
                     name="是"
                     label-size="30">
                  </u-checkbox>
               </u-checkbox-group>
                  size="30"
                  shape="circle"
                  iconSize="20">
                  <u-radio labelSize="14px"
                     size="20px"
                     v-for="(item, index) in countryNumberCarList"
                     :key="index"
                     :label="item.label"
                     :name="item.name"></u-radio>
               </u-radio-group>
            </u-form-item>
         </u--form>
      </view>
@@ -206,7 +287,49 @@
         }
      },
      data() {
         const checkPassword = (rule, value, callback) => {
               let passL = 8;
               if(!value) {   //不必填
                 return callback()
               }
               if(value && value.length < passL) {
                 return callback(`密码不能少于${passL}位`)
               }
               if(value && value.length > 16) {
                 return callback('密码不能大于16位')
               }
               //校验是数字
               const regex1 = /^\d+$/
               // 校验字母
               const regex2 = /^[A-Za-z]+$/
               // 校验符号
               const regex3 =
                 /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、]+$/
               if(regex1.test(value)) {
                 return callback('密码强度过低')
               }else if(regex2.test(value)) {
                 return callback('密码强度过低')
               }else if(regex3.test(value)) {
                 return callback('密码强度过低')
               }else if(/^[A-Za-z\d]+$/.test(value)) {
                 return callback('密码强度过低')
               }else if(
                 /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、\d]+$/.test(
                   value
                 )
               ) {
                 return callback('密码强度过低')
               }else if(
                 /^[`~!@#$%^&*()_\-+=<>?:"{}|,.\/;'\\[\]·~!@#¥%……&*()——\-+={}|《》?:“”【】、;‘',。、A-Za-z]+$/.test(
                   value
                 )
               ) {
                 return callback('密码强度过低')
               }
               return callback()
             }
         return {
            minDate: this.getToday(),
            // 车牌号键盘控制
            carNumShow: false,
            keyValue: '',
@@ -216,7 +339,7 @@
               name: '',
               username: '',
               openId: '',
               type: 2,
               type: 3,
               idCard: '',
               carNo: '',
               carImg: '',
@@ -224,15 +347,32 @@
               tuiJianMa: '',
               confirmPassword: '',
               tradeQualificationImg: '',
               roadTransportImg: '',
               isNonCoal: [],
               isCoalCar: 1 //是否为煤炭车辆(司机使用字段) 1 是 2 不是
               driverImg: '',
               countryNumberCar: 2, //环保类型;国五 1,国六 2
               carType:0,
            },
            fileList1: [],
            fileList2: [],
            fileList3: [],
            fileList4: [],
            fileList5: [],
            fileList6: [],
            rules: {
               countryNumberCar: {
                  required: false,
               },
               expirationTimeIdcard: {
                  required: false,
               },
               expirationTimeDriving: {
                  required: false,
               },
               expirationTimeDriver: {
                  required: false,
               },
               expirationTimeTradequalification: {
                  required: false,
               },
               name: {
                  type: 'string',
                  required: true,
@@ -276,10 +416,11 @@
                     trigger: ['blur', 'change']
                  },
                  {
                     min: 6,
                     max: 12,
                     message: '长度在6-12个字符之间'
                  }
                     min: 8,
                     max: 16,
                     message: '长度在8-16个字符之间'
                  },
                   {validator: checkPassword, trigger: 'change'}
               ],
               confirmPassword: [{
                     required: true,
@@ -309,6 +450,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,
@@ -321,16 +474,10 @@
                  message: '请上传行驶证照片',
                  trigger: ['blur', 'change']
               },
               roadTransportImg: {
               driverImg: {
                  type: 'string',
                  required: true,
                  message: '请上传道路运输证照片',
                  trigger: ['blur', 'change']
               },
               tradeQualificationImg: {
                  type: 'string',
                  required: true,
                  message: '请上传从业资格证照片',
                  message: '请上传驾驶证照片',
                  trigger: ['blur', 'change']
               }
            },
@@ -341,6 +488,36 @@
               {
                  name: '货代',
                  disabled: false
               }
            ],
            radiolist2: [{
                  text: '普通运输车',
                  value:1
               },
               {
                  text: '集装箱平板车',
                  value:2
               },
               {
                  text: '液氯槽车',
                  value:3
               },
               {
                  text: '液碱槽车',
                  value:4
               }
            ],
            countryNumberCarList: [{
                  name: 1,
                  label: '国五',
               },
               {
                  name: 2,
                  label: '国六',
               },
               {
                  name: 3,
                  label: '新能源',
               }
            ],
            radiovalue1: '司机',
@@ -375,22 +552,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',
@@ -400,7 +614,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 => {
@@ -411,6 +625,7 @@
                     console.log('err', err);
                     this.$u.toast('请规范输入内容');
                  });
                  }
            } else {
               this.$u.toast('两次密码不一致');
            }
@@ -476,9 +691,6 @@
                  url: BaseUrl + '/admin/sys-file/uploadUnToken',
                  filePath: url,
                  name: 'file',
                  formData: {
                     // user: ''
                  },
                  success: res => {
                     if (num == 1) {
                        this.registerFormModel.carImg = JSON.parse(res.data).data.url;
@@ -487,11 +699,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.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}`);
                     }
@@ -518,9 +738,6 @@
            this.$nextTick(() => {
               this.editRoleModelShow = false;
            });
         },
         isNonCoalChange() {
            this.registerFormModel.isCoalCar = this.registerFormModel.isNonCoal.length !== 0 ? 1 : 2
         }
      }
   };