qingyiay
2023-05-10 a9365f3f01a2406f971f999e9b6ff01cdd4b6a55
pages/register/register.vue
@@ -1,6 +1,5 @@
<template>
   <view class="register">
      <!-- <home-species title="注册"></home-species> -->
      <view class="registerForm">
         <u--form :rules="rules" :model="registerFormModel" ref="regesterFormRef">
            <u-form-item labelWidth="20%" label="选择身份" borderBottom ref="roleRef" required>
@@ -36,29 +35,58 @@
               <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-upload :fileList="fileList1" @afterRead="afterRead" @delete="deletePic" name="1" multiple :maxCount="1" width="250" height="150">
               <u-upload
                  :fileList="fileList1"
                  deletable
                  @afterRead="afterRead"
                  @delete="deletePic"
                  name="1"
                  multiple
                  :maxCount="1"
                  width="250"
                  height="150"
                  :previewFullImage="true"
               >
                  <!-- <image src="https://cdn.uviewui.com/uview/demo/upload/positive.png"
                  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-upload :fileList="fileList2" @afterRead="afterRead" @delete="deletePic" name="2" multiple :maxCount="1" width="250" height="150">
               <u-upload
                  :fileList="fileList2"
                  deletable
                  @afterRead="afterRead"
                  @delete="deletePic"
                  name="2"
                  multiple
                  :maxCount="1"
                  width="250"
                  height="150"
                  :previewFullImage="true"
               >
                  <!-- <image src="https://cdn.uviewui.com/uview/demo/upload/positive.png"
                  mode="widthFix" style="width: 250px;height: 150px;"></image> -->
               </u-upload>
            </u-form-item>
            <u-form-item label="推荐人账号" labelWidth="25%" borderBottom><u--input v-model="registerFormModel.tuiJianMa" placeholder="请输入内容" clearable></u--input></u-form-item>
            <u-form-item label="推荐人账号" labelWidth="25%" borderBottom>
               <u--input v-model="registerFormModel.tuiJianMa" placeholder="请输入内容" clearable></u--input>
            </u-form-item>
         </u--form>
      </view>
      <view class="roleModel">
         <u-modal :show="editRoleModelShow" :title="title" :content="content" :showCancelButton="true" @confirm="roleConfirm" @cancel="roleCancel"></u-modal>
      </view>
      <view class="registerBtn"><u-button text="注册" type="primary" @click="registerClick"></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>
<script>
// import HomeSpecies from '@/components/home-species/HomeSpecies.vue';
import { apiRegister } from '@/api/publicInterface.js';
import { BaseUrl } from '@/api/publicInterface.js';
export default {
@@ -77,12 +105,9 @@
   //     }
   //   })
   // },
   components: {
      // HomeSpecies
   },
   // 监听页面初次渲染完成。注意如果渲染速度快,会在页面进入动画完成前触发
   onReady() {
      // this.$refs.regesterFormRef.setRules(this.rules);
      this.$refs.regesterFormRef.setRules(this.rules);
      // this.$refs.regesterFormRef.validate().then(res => {}).catch(err => {
      //   console.log(err);
      // })
@@ -95,6 +120,9 @@
   },
   data() {
      return {
         // 车牌号键盘控制
         carNumShow: false,
         keyValue: '',
         registerFormModel: {
            phone: '',
            password: '',
@@ -167,6 +195,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: {
@@ -236,10 +274,9 @@
                  this.registerFormModel.username = this.registerFormModel.phone;
                  apiRegister(this.registerFormModel)
                     .then(res => {
                        console.log(res);
                        if (res.data.code == 0) {
                           uni.showToast({
                              title: '注册成功,即将进入登录!',
                              title: '注册成功,即将返回登录页',
                              icon: 'none',
                              duration: 1000
                           });
@@ -247,7 +284,7 @@
                              uni.redirectTo({ url: '/pages/login/login' });
                           }, 1000);
                        } else {
                           this.$u.toast(res.data.msg);
                           this.$u.toast(res.data.data ? res.data.data : '添加失败');
                        }
                     })
                     .catch(err => {
@@ -262,18 +299,9 @@
            this.$u.toast('两次密码不一致');
         }
      },
      // 音视频通话
      // callingIn() {
      //    uni.navigateTo({
      //       url: '/pages/calling-index/calling-index'
      //    });
      // },
      // 单选框事件
      groupChange(e) {
         console.log('单选框小组', e);
      },
      groupChange(e) {},
      radioChange(e) {
         console.log('单选框', e);
         if (
            this.registerFormModel.name == '' &&
            this.registerFormModel.idCard == '' &&
@@ -281,7 +309,6 @@
            this.registerFormModel.carNo == '' &&
            this.registerFormModel.password == ''
         ) {
            console.log('变了');
            this.$refs.regesterFormRef.clearValidate();
            this.beforeChangeValue = e;
         }
@@ -298,7 +325,6 @@
      },
      // 新增图片
      async afterRead(event) {
         console.log('event', event);
         // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
         let lists = [].concat(event.file);
         let fileListLen = this[`fileList${event.name}`].length;
@@ -317,7 +343,7 @@
               1,
               Object.assign(item, {
                  status: 'success',
                  message: '',
                  message: '上传成功',
                  url: result
               })
            );
@@ -330,15 +356,16 @@
               url: BaseUrl + '/admin/sys-file/uploadUnToken',
               filePath: url,
               name: 'file',
               // formData: {
               //    user: 'test'
               // },
               formData: {
                  // user: ''
               },
               success: res => {
                  resolve(JSON.parse(res.data).data.url);
                  if (num == 1) {
                     this.registerFormModel.carImg = JSON.parse(res.data).data.url;
                     resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                  } else if (num == 2) {
                     this.registerFormModel.drivingImg = JSON.parse(res.data).data.url;
                     resolve(`${BaseUrl}${JSON.parse(res.data).data.url}`);
                  }
               }
            });