qingyiay
2023-06-25 b9c8410f6d5c7efa7b7b2b374adb21649dd2f886
pages/register/register.vue
@@ -34,7 +34,7 @@
            <u-form-item prop="carNo" label="车牌号" labelWidth="20%" borderBottom v-if="radiovalue1 == '司机'" required>
               <u--input v-model="registerFormModel.carNo" placeholder="请输入内容" clearable></u--input>
            </u-form-item>
            <u-form-item prop="carImg" label="车辆照片" labelWidth="20%" borderBottom v-if="radiovalue1 == '司机'" required>
            <u-form-item prop="carImg" label="车辆照片" labelWidth="20%" borderBottom v-if="radiovalue1 == '司机'" required @click="beforeRead">
               <u-upload
                  :fileList="fileList1"
                  deletable
@@ -51,7 +51,7 @@
                  mode="widthFix" style="width: 250px;height: 150px;"></image> -->
               </u-upload>
            </u-form-item>
            <u-form-item prop="drivingImg" label="行驶证" labelWidth="20%" borderBottom v-if="radiovalue1 == '司机'" required>
            <u-form-item prop="drivingImg" label="行驶证" labelWidth="20%" borderBottom v-if="radiovalue1 == '司机'" required @click="beforeRead">
               <u-upload
                  :fileList="fileList2"
                  deletable
@@ -89,6 +89,7 @@
<script>
import { apiRegister } from '@/api/publicInterface.js';
import { BaseUrl } from '@/api/publicInterface.js';
import { mapMutations } from 'vuex';
export default {
   // onLoad: function() {
   //   // 查看是否授权
@@ -107,7 +108,7 @@
   // },
   // 监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
   onReady() {
      // this.$refs.regesterFormRef.setRules(this.rules);
      this.$refs.regesterFormRef.setRules(this.rules);
      // this.$refs.regesterFormRef.validate().then(res => {}).catch(err => {
      //   console.log(err);
      // })
@@ -120,6 +121,9 @@
   },
   data() {
      return {
         // 车牌号键盘控制
         carNumShow: false,
         keyValue: '',
         registerFormModel: {
            phone: '',
            password: '',
@@ -143,16 +147,22 @@
               message: '请填写姓名',
               trigger: ['blur', 'change']
            },
            idCard: {
               type: 'string',
               required: true,
               message: '请输入身份证号',
               trigger: ['blur', 'change']
            },
            idCard: [
               {
                  type: 'string',
                  required: true,
                  message: '请输入身份证号',
                  trigger: ['blur', 'change']
               },
               {
                  pattern: /^([1-6][1-9]|50)\d{4}(18|19|20)\d{2}((0[1-9])|10|11|12)(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                  message: '身份证号格式不正确'
               }
            ],
            phone: [
               {
                  required: true,
                  message: '此为必填字段',
                  message: '此项为必填项',
                  // blur和change事件触发检验
                  trigger: ['blur', 'change']
               },
@@ -160,6 +170,13 @@
                  min: 11,
                  max: 11,
                  message: '请输入合法手机号'
               },
               {
                  validator: (rule, value, callback) => {
                     return uni.$u.test.mobile(value);
                  },
                  message: '手机号码不正确',
                  trigger: ['change', 'blur']
               }
            ],
            password: [
@@ -192,6 +209,16 @@
                  required: true,
                  message: '请输入车牌号',
                  trigger: ['blur', 'change']
               },
               {
                  transform(value) {
                     return String(value);
                  },
                  validator: (rule, value, callback) => {
                     return uni.$u.test.carNo(value);
                  },
                  message: '请输入正确的车牌号',
                  trigger: ['change', 'blur']
               }
            ],
            carImg: {
@@ -252,6 +279,7 @@
      }
   },
   methods: {
      ...mapMutations(['changeisUploadimg']),
      registerClick() {
         if (this.registerFormModel.password == this.registerFormModel.confirmPassword) {
            this.$refs.regesterFormRef
@@ -271,7 +299,7 @@
                              uni.redirectTo({ url: '/pages/login/login' });
                           }, 1000);
                        } else {
                           this.$u.toast(res.data.data ? res.data.data : '添加失败');
                           this.$u.toast(res.msg ? res.msg : '添加失败');
                        }
                     })
                     .catch(err => {
@@ -280,18 +308,15 @@
               })
               .catch(err => {
                  console.log('err', err);
                  uni.$u.toast('请规范输入内容');
                  this.$u.toast('请规范输入内容');
               });
         } else {
            this.$u.toast('两次密码不一致');
         }
      },
      // 单选框事件
      groupChange(e) {
         console.log('单选框小组', e);
      },
      groupChange(e) {},
      radioChange(e) {
         console.log('单选框', e);
         if (
            this.registerFormModel.name == '' &&
            this.registerFormModel.idCard == '' &&
@@ -299,7 +324,6 @@
            this.registerFormModel.carNo == '' &&
            this.registerFormModel.password == ''
         ) {
            console.log('变了');
            this.$refs.regesterFormRef.clearValidate();
            this.beforeChangeValue = e;
         }
@@ -310,8 +334,12 @@
         }
      },
      // 上传图片方法
      beforeRead() {
         this.changeisUploadimg(true);
      },
      // 删除图片
      deletePic(event) {
         this.changeisUploadimg(true);
         this[`fileList${event.name}`].splice(event.index, 1);
      },
      // 新增图片