wk
2024-06-18 30e3526b109a94b83ee53d460b5626300361e5a5
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"
@@ -42,6 +41,48 @@
               <u--input v-model="registerFormModel.idCard"
                  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="手机号"
@@ -83,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%"
@@ -121,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 == '司机'"
@@ -139,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="从业资格证"
@@ -158,13 +225,48 @@
                  height="150"
                  :previewFullImage="true">
               </u-upload>
               <span style="color:red">
                  凡是运输有毒化学物品的车辆必须上传从业资格证并填写从业资格证有效时间
               </span>
            </u-form-item>
            <u-form-item label="推荐人账号"
               labelWidth="25%"
               borderBottom>
               <u--input v-model="registerFormModel.tuiJianMa"
                  placeholder="请输入内容"
                  clearable></u--input>
            <u-form-item prop="expirationTimeTradequalification"
               label="从业资格过期时间"
               labelWidth="20%"
               borderBottom
               v-if="radiovalue1 == '司机'">
               <uni-datetime-picker v-model="registerFormModel.expirationTimeTradequalification" type="datetime"  :start="minDate" />
            </u-form-item>
            <u-form-item label="是否非煤车辆"
               v-if="radiovalue1 == '司机'"
               labelWidth="30%"
               borderBottom
               prop="isNonCoal">
               <u-checkbox-group v-model="registerFormModel.isNonCoal"
                  placement="row"
                  size="40"
                  @change="isNonCoalChange">
                  <u-checkbox name="是"
                     label-size="30">
                  </u-checkbox>
               </u-checkbox-group>
            </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="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>
@@ -180,12 +282,6 @@
            type="primary"
            @click="registerClick"
            :loading="registerClickloading"></u-button></view>
      <!-- 图片预览弹出框 -->
      <!-- <view class="previewImage-container">
         <u-popup :show="previewImageShow" mode="center" @close="previewImageClose" @open="previewImageOpen">
            <u--image :src="previewImageSrc != null ? BaseUrl + previewImageSrc : ''" width="400px" height="400px"></u--image>
         </u-popup>
      </view> -->
   </view>
</template>
@@ -194,27 +290,9 @@
   import { BaseUrl } from '@/api/publicInterface.js';
   import { mapMutations } from 'vuex';
   export default {
      // onLoad: function() {
      //   // 查看是否授权
      //   wx.getSetting({
      //     success (res){
      //       if (res.authSetting['scope.userInfo']) {
      //         // 已经授权,可以直接调用 getUserInfo 获取头像昵称
      //         wx.getUserInfo({
      //           success: function(res) {
      //             console.log('res.userInfo',res.userInfo)
      //           }
      //         })
      //       }
      //     }
      //   })
      // },
      // 监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
      onReady() {
         this.$refs.regesterFormRef.setRules(this.rules);
         // this.$refs.regesterFormRef.validate().then(res => {}).catch(err => {
         //   console.log(err);
         // })
      },
      onLoad(params) {
         if (params) {
@@ -224,6 +302,7 @@
      },
      data() {
         return {
            minDate: this.getToday(),
            // 车牌号键盘控制
            carNumShow: false,
            keyValue: '',
@@ -233,7 +312,7 @@
               name: '',
               username: '',
               openId: '',
               type: 2,
               type: 3,
               idCard: '',
               carNo: '',
               carImg: '',
@@ -241,13 +320,34 @@
               tuiJianMa: '',
               confirmPassword: '',
               tradeQualificationImg: '',
               roadTransportImg: ''
               driverImg: '',
               isNonCoal: [],
               isCoalCar: 1, //是否为煤炭车辆(司机使用字段) 1 是 2 不是
               countryNumberCar: 0, //车辆类型;国五 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,
@@ -324,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,
@@ -336,31 +448,53 @@
                  message: '请上传行驶证照片',
                  trigger: ['blur', 'change']
               },
               roadTransportImg: {
               driverImg: {
                  type: 'string',
                  required: true,
                  message: '请上传道路运输证照片',
                  trigger: ['blur', 'change']
               },
               tradeQualificationImg: {
                  type: 'string',
                  required: true,
                  message: '请上传从业资格证照片',
                  message: '请上传驾驶证照片',
                  trigger: ['blur', 'change']
               }
            },
            // 基本案列数据
            radiolist1: [{
                  name: '货代',
                  name: '司机',
                  disabled: false
               },
               {
                  name: '司机',
                  name: '货代',
                  disabled: false
               }
            ],
            // u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
            radiovalue1: '货代',
            radiolist2: [{
                  text: '普通运输车',
                  value:1
               },
               {
                  text: '集装箱平板车',
                  value:2
               },
               {
                  text: '液氯槽车',
                  value:3
               },
               {
                  text: '液碱槽车',
                  value:4
               }
            ],
            countryNumberCarList: [{
                  name: 1,
                  label: '国五',
               },
               {
                  name: 2,
                  label: '国六',
               },
               {
                  name: 3,
                  label: '新能源',
               }
            ],
            radiovalue1: '司机',
            beforeChangeValue: '',
            // 更换角色弹框
            editRoleModelShow: false,
@@ -368,7 +502,7 @@
            content: '当前填入信息,切换角色后,即清除,是否切换?',
            wxcode: '',
            openid: '',
            registerClickloading: false
            registerClickloading: false,
         };
      },
      watch: {
@@ -392,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',
@@ -417,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 => {
@@ -428,6 +599,7 @@
                     console.log('err', err);
                     this.$u.toast('请规范输入内容');
                  });
                  }
            } else {
               this.$u.toast('两次密码不一致');
            }
@@ -493,9 +665,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;
@@ -504,11 +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.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}`);
                     }
@@ -535,6 +712,9 @@
            this.$nextTick(() => {
               this.editRoleModelShow = false;
            });
         },
         isNonCoalChange() {
            this.registerFormModel.isCoalCar = this.registerFormModel.isNonCoal.length !== 0 ? 1 : 2
         }
      }
   };