liuyg
2022-02-21 03c0ccec93a3f78c9732a999cb3dfa1cfc443d48
pages/registerUser/registerUser.vue
@@ -35,12 +35,12 @@
            (功能研发中)
         </u-form-item>
      </u-form>
         <view class="agree">
            注册即代表同意
            <text class="a">《用户协议》</text>
            和
            <text class="a">《隐私政策》</text>
         </view>
      <view class="agree">
         注册即代表同意
         <text class="a">《用户协议》</text>
         和
         <text class="a">《隐私政策》</text>
      </view>
      <div v-show="mapShow">
         <div class="login-map-bc" @click="mapShow = false">
@@ -63,6 +63,28 @@
<script>
   export default {
      data() {
         var validateUser = (rule, value, callback) => {
            var phone = /^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/;
            var identity = /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/;
            if (value.length <= 11) {
               if (phone.test(value)) {
                  return true
               } else {
                  return callback(new Error('手机号格式不正确'));
               }
            }
            if (value.length <= 18) {
               if (identity.test(value)) {
                  return true
               } else {
                  return callback(new Error('身份证号格式不正确'));
               }
            }
         };
         return {
            regionName: '',
            loginMapUrl: "",
@@ -110,7 +132,7 @@
                  img: 'man-add-fill',
                  froms: 'user',
                  requireds: true,
                  placeholder: '请输入身份证号'
                  placeholder: '请输入身份证号或手机号'
               },
               {
                  title: '密码',
@@ -172,17 +194,16 @@
               jsid: ''
            },
            rules: {
               user: [{
                  required: true,
                  message: '请输入身份证号',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }, {
                  pattern: /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)/,
                  message: '证件号码格式有误!',
                  trigger: 'blur'
               }],
               user: [
                  {
                     /*
                      u-form提供的可直接调用的js验证,
                      具体有哪些可以观看官方文档,这里就不在赘述了。
                     */
                     validator: validateUser,
                     trigger: ['change', 'blur'],
                  },
               ],
               pass: [{
                  required: true,
                  message: '请输入6~16位密码',
@@ -342,32 +363,38 @@
         },
         zc() {
            var that = this;
            uni.request({
               url: that.$store.state.piAPI + '/zc/inster',
               method: 'POST',
               url: that.$store.state.piAPI + '/zc/inspect',
               method: 'GET',
               data: {
                  username: this.form.user
               },
               success: (res) => {
                  uni.showToast({
                     title: '注册成功,请等待审核',
                     icon: 'none',
                     duration: 2000
                  if (res.data.code == 400) {
                     uni.showToast({
                        title: res.data.msg,
                        icon: 'none',
                        duration: 2000
                     });
                     return
                  }
                  that.$refs.uForm.validate(valid => {
                     if (valid) {
                        var d = that.form;
                        uni.navigateTo({
                           url: '/pages/registerUser/idphoto?data= ' +
                              encodeURIComponent(JSON.stringify(
                                 d))
                        });
                     }
                  });
               }
            });
            var that = this;
            this.$refs.uForm.validate(valid => {
               if (valid) {
                  var d = this.form;
                  uni.navigateTo({
                     url: '/pages/registerUser/idphoto?data= ' + encodeURIComponent(JSON.stringify(
                        d))
                  });
               }
            });
         },
         depl() {
@@ -518,7 +545,7 @@
            } else if (name.indexOf('市') != -1) {
               that.regionName = name.replace('市', '市派出所');
            }
            that.form.xq = that.regionName
            that.mapShow = false
         }
@@ -624,7 +651,7 @@
   .registerUser {
      padding: 0 1.2rem;
   }
   .agree {
      margin: 27rpx 95rpx 0;
      font-size: 22rpx;
@@ -632,10 +659,9 @@
      font-weight: normal;
      color: #cacaca;
      line-height: 34rpx;
      .a {
         color: #000000;
      }
   }
</style>