shuishen
2022-02-26 c765784d2d2d4db55bfcb629cc3f6ec0b57dddcc
pages/registerUser/registerUser.vue
@@ -3,20 +3,39 @@
      <u-form :model="form" ref="uForm">
         <u-form-item :label="item.title" :prop="item.froms" label-width="200" :left-icon="item.img"
            :required="item.requireds" v-for="(item, index) in list" :key="index">
            <u-input v-model="form[item.froms]" :placeholder="item.placeholder" />
            <u-input v-model="form[item.froms]" :placeholder="item.placeholder" :type="item.type" />
         </u-form-item>
         <u-form-item label="角色" prop="role" left-icon="account-fill" label-width="200" :required="true">
            <u-input v-model="form.role" type="select" placeholder="请选择角色" :border="true" @click="depl" />
            <u-select v-model="show" mode="mutil-column-auto" :list="roleList" @confirm="radioGroupChange">
            </u-select>
         </u-form-item>
         <u-form-item label="工作单位" prop="obj" left-icon="account-fill" label-width="200" :required="true"
            v-if="xqShow">
            <u-input v-model="form.obj" placeholder="请输入工作单位" />
         <u-form-item v-show="form.role == '民警'" label="警号" prop="signals" left-icon="edit-pen" label-width="200"
            :required="true">
            <u-input v-model="form.signals" placeholder="请输入警号" />
         </u-form-item>
         <u-form-item label="辖区" prop="xq" left-icon="account-fill" label-width="200" :required="true">
            <u-input v-model="form.xq" type="select" placeholder="请选择辖区" :border="true" @click="openLoginMap" />
            <!-- <u-select v-model="showxq" mode="mutil-column-auto" :list="listxq" @confirm="confirmxq"></u-select> -->
         <u-form-item label="工作单位" left-icon="home-fill" label-width="200" :required="true">
            <u-radio-group v-model="jobValue">
               <u-radio v-for="(item, index) in jobList" :key="index" :name="item.name" :disabled="item.disabled">
                  {{item.name}}
               </u-radio>
            </u-radio-group>
         </u-form-item>
         <u-form-item v-show="jobValue == '有'" label="单位名称" prop="jobUnit" label-width="200" left-icon="home"
            :required="true">
            <u-input v-model="form.jobUnit" placeholder="请输入单位名称" />
         </u-form-item>
         <u-form-item v-show="jobValue == '有'" label="工作地点" prop="xq" left-icon="map-fill" label-width="200"
            :required="true">
            <u-input v-model="form.xq" type="select" placeholder="请选择工作地点" :border="true"
               @click="regionClick('工作地点')" />
         </u-form-item>
         <u-form-item label="居住地" prop="address" left-icon="map" label-width="200" :required="true">
            <u-input v-model="form.address" type="select" placeholder="请选择居住地" :border="true"
               @click="placeClick('居住地')" />
         </u-form-item>
         <u-form-item label="性别" label-width="200" left-icon="man">
            <u-radio-group v-model="form.sex">
@@ -25,7 +44,7 @@
               </u-radio>
            </u-radio-group>
         </u-form-item>
         <u-form-item label="是否人脸登录" label-width="240" left-icon="server-man">
         <!-- <u-form-item label="是否人脸登录" label-width="240" left-icon="server-man">
            <u-radio-group v-model="radioValue">
               <u-radio v-for="(item, index) in radioList" :key="index" :name="item.name"
                  :disabled="item.disabled">
@@ -33,29 +52,37 @@
               </u-radio>
            </u-radio-group>
            (功能研发中)
         </u-form-item>
         </u-form-item> -->
      </u-form>
         <view class="agree">
            注册即代表同意
            <text class="a">《用户协议》</text>
      <view class="agree">
         <u-checkbox v-model="userConsent" shape="circle">
            我已阅读并同意
            <text class="a" @click="agreement(0)">用户协议</text>
            和
            <text class="a">《隐私政策》</text>
         </view>
      <div v-show="mapShow">
         <div class="login-map-bc" @click="mapShow = false">
         </div>
         <div class="login-map-content">
            <u-icon class="login-map-close" name="close" @click="mapShow = false"></u-icon>
            <iframe style="width: 100%; height: 100%; position: absolute; " :src="loginMapUrl">
            </iframe>
         </div>
      </div>
            <text class="a" @click="agreement(1)">隐私政策</text>
         </u-checkbox>
      </view>
      <u-button class="submit" @click="zc">
         下一步</u-button>
         注册</u-button>
      <map v-show="signLocation" id="SignLocationMap"
         style="position: fixed; left: 0; width: 100%; z-index: 99;"
         :style="{height: screenHeight + 'px', top: screenTop + 'px'}"
         @regionchange="regionChange" :latitude="latitude" :longitude="longitude" :scale="scale">
         <cover-view class="dingwBut">
            <cover-image class="location-log" src="../../static/img/location.png">
            </cover-image>
         </cover-view>
         <cover-view class="confirmBtn" @click="confirmChangeBtn">
            获取地址
         </cover-view>
      </map>
      <!-- <u-button @click="signLocation = true">dakai</u-button> -->
      <!-- <u-button class="submit" @click="submit">提交</u-button> -->
   </view>
</template>
@@ -63,9 +90,60 @@
<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)) {
                  this.form.phone = value;
                  return true
               } else {
                  return callback(new Error('手机号格式不正确'));
               }
            }
            if (value.length > 11) {
               if (identity.test(value)) {
                  this.form.carId = value;
                  return true
               } else {
                  return callback(new Error('身份证号格式不正确'));
               }
            }
         };
         return {
            // 设置高度, TOP值
            screenHeight: 0,
            screenTop: 0,
            // 记录地区获取居住地
            regionOrPlace: '',
            // 地图相关
            scale: 15, //缩放级别
            signLocation: false,
            latitude: 28.678983439095823,
            longitude: 115.84414205551147,
            mapLocationName: '',
            mapLocationLatitude: '',
            mapLocationLongitude: '',
            userConsent: false,
            jobValue: '无',
            jobList: [{
                  name: '有',
                  disabled: false
               },
               {
                  name: '无',
                  disabled: false
               }
            ],
            regionName: '',
            loginMapUrl: "",
            radioList: [{
                  name: '是',
                  disabled: false
@@ -76,31 +154,9 @@
               }
            ],
            radioValue: '否',
            mapShow: false,
            latitude: 28.68, //纬度
            longitude: 115.85, //经度
            scale: 12, //缩放级别
            polyline: [
               //    { //指定一系列坐标点,从数组第一项连线至最后一项
               //    points: [{
               //          latitude: 34.79977,
               //          longitude: 113.66072
               //       },
               //       {
               //          latitude: 34.795541,
               //          longitude: 113.681646
               //       },
               //    ],
               //    color: "#0000AA", //线的颜色
               //    width: 1, //线的宽度
               //    //     dottedLine:true,//是否虚线
               //    arrowLine: true, //带箭头的线 开发者工具暂不支持该属性
               // },
            ],
            marker: [],
            show: false,
            showxq: false,
            xqShow: true,
            listbm: [],
            listxq: [],
            deptXb: "",
@@ -110,10 +166,11 @@
                  img: 'man-add-fill',
                  froms: 'user',
                  requireds: true,
                  placeholder: '请输入身份证号'
                  placeholder: '请输入身份证号或手机号'
               },
               {
                  title: '密码',
                  type: 'password',
                  img: 'lock-fill',
                  froms: 'pass',
                  requireds: true,
@@ -121,6 +178,7 @@
               },
               {
                  title: '确认密码',
                  type: 'password',
                  img: 'lock-fill',
                  froms: 'passTwo',
                  requireds: true,
@@ -131,14 +189,14 @@
                  img: 'account',
                  froms: 'name',
                  requireds: true,
                  placeholder: '请输入姓名'
                  placeholder: '请输入真实姓名'
               },
               {
                  title: '手机号',
                  img: 'phone-fill',
                  froms: 'phone',
                  requireds: false,
                  placeholder: '请输入手机号'
                  placeholder: '请输入真实手机号'
               },
               // {
               //    title: '部门',
@@ -165,24 +223,23 @@
               carId: '',
               phone: '',
               sex: '男',
               obj: '',
               objId: '',
               xq: '',
               xqobjId: '',
               jsid: ''
               jurisdiction: '',
               jsid: '',
               address: '',
               jobUnit: '',
               signals: '',
               workjurisdiction: ''
            },
            rules: {
               user: [{
                  required: true,
                  message: '请输入身份证号',
                  // 可以单个或者同时写两个触发验证方式
                  /*
                   u-form提供的可直接调用的js验证,
                   具体有哪些可以观看官方文档,这里就不在赘述了。
                  */
                  validator: validateUser,
                  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'
               }],
               }, ],
               pass: [{
                  required: true,
                  message: '请输入6~16位密码',
@@ -217,19 +274,31 @@
               }],
               name: [{
                  required: true,
                  message: '请输入姓名',
                  message: '请输入真实姓名',
                  // 可以单个或者同时写两个触发验证方式 
                  trigger: ['change', 'blur'],
               }],
               obj: [{
               jobUnit: [{
                  required: true,
                  message: '请输入工作单位',
                  message: '请输入单位名称',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }],
               address: [{
                  required: false,
                  message: '请输入居住地',
                  // 可以单个或者同时写两个触发验证方式 
                  trigger: ['change', 'blur'],
               }],
               role: [{
                  required: true,
                  message: '请选择角色',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }],
               signals: [{
                  required: true,
                  message: '请输入警号',
                  // 可以单个或者同时写两个触发验证方式 
                  trigger: ['change', 'blur'],
               }],
@@ -241,22 +310,10 @@
               }],
               depts: [{
                  required: true,
                  message: '请输入姓名',
                  message: '请输入真实姓名',
                  // 可以单个或者同时写两个触发验证方式 
                  trigger: ['change', 'blur'],
               }],
               // phone: [{
               //    required: false,
               //    message: '请输入手机号',
               //    // 可以单个或者同时写两个触发验证方式
               //    trigger: ['change', 'blur'],
               // }, {
               //    validator: (rule, value, callback) => {
               //       return this.$u.test.mobile(value);
               //    },
               //    message: '手机号码不正确',
               //    trigger: ['change', 'blur'],
               // }],
            },
            showGetFace: false,
            faceState: -2,
@@ -264,238 +321,149 @@
            faceco: '#000',
            faceMsg: '',
            roleList: [{
                  label: '平安志愿者',
                  value: "1416225906918195201"
               }, {
                  label: '民警',
                  value: 1417092295132561409
                  value: "1417092295132561409"
               },
               {
                  label: '治保会队伍',
                  value: 1424615693403414529
                  value: "1495714130024673282"
               },
               {
                  label: '内保干部队伍',
                  value: 1424615773594312705
                  value: "1495714221926068225"
               },
               {
                  label: '治安巡防队伍',
                  value: 1424615835435130881
                  value: "1495714272471625729"
               },
               {
                  label: '信息员队伍',
                  value: 1424615909959524354
                  value: "1495714309071122434"
               },
               {
                  label: '保安员队伍',
                  value: 1424615972718895106
                  value: "1495714343888039937"
               },
               {
                  label: '警务辅助队伍',
                  value: 1424616047083905026
               },
               {
                  label: '平安志愿者',
                  value: 1494565079268491266
                  value: "1495714378025480193"
               }
            ]
            ],
         };
      },
      methods: {
         openLoginMap() {
            var that = this
            uni.getLocation({
               type: 'wgs84',
               success: function(res) {
                  console.log('当前位置的经度:' + res.longitude);
                  console.log('当前位置的纬度:' + res.latitude);
                  that.latitude = res.latitude
                  that.longitude = res.longitude
                  that.marker = [{
                     id: 0,
                     latitude: res.latitude, //纬度
                     longitude: res.longitude, //经度
                     iconPath: '/static/img/map/location.png', //显示的图标
                     rotate: 0, // 旋转度数
                     width: 20, //宽
                     height: 20, //高
                     title: '位置', //标注点名
                     alpha: 1, //透明度
                  }]
                  var data = [{
                     "id": '100000',
                     "place": '无数据',
                     "state": '0',
                     "dtype": '0',
                     "size": '300',
                     "jd": res.longitude,
                     "wd": res.latitude
                  }]
                  data = JSON.stringify(data);
                  // that.loginMapUrl = 'http://127.0.0.1:5500/leafletMapOur/loginMap/loginMap.html?data=' +
                  //    data
                  that.loginMapUrl = 'http://223.82.109.183:2082/loginMap/loginMap.html?data=' + data
                  that.mapShow = true
               }
            })
         agreement(e) {
            uni.navigateTo({
               url: '/pages/registerUser/agreement?e=' + e
            });
         },
         regionClick(e) {
            this.regionOrPlace = e
            this.signLocation = true
         },
         placeClick(e) {
            this.regionOrPlace = e
            this.signLocation = true
         },
         zc() {
            if (this.userConsent == false) {
               uni.showToast({
                  title: "请先阅读并同意协议",
                  icon: 'none',
                  duration: 2000
               });
               return
            }
            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) => {
                  if (res.data.code == 400) {
                     uni.showToast({
                        title: res.data.msg,
                        icon: 'none',
                        duration: 2000
                     });
                     return
                  }
                  that.registerEvent()
                  // that.$refs.uForm.validate(valid => {
                  //    if (valid) {
                  //       var d = that.form;
                  //       uni.navigateTo({
                  //          url: '/pages/registerUser/idphoto?data= ' +
                  //             encodeURIComponent(JSON.stringify(
                  //                d))
                  //       });
                  //    }
                  // });
               }
            });
         },
         registerEvent() {
            var d = this.form;
            var url = this.$store.state.piAPI + '/zc/inster',
               data = {
                  // deptid: ,
                  password: d.pass,
                  password2: d.passTwo,
                  phone: d.phone,
                  sex: d.sex == '男' ? 1 : 2,
                  sname: d.name,
                  username: d.user,
                  parentId: d.jsid,
                  cardid: d.carId,
                  // 居住地址
                  address: d.address,
                  // 单位名称
                  jobUnit: d.jobUnit,
                  // 居住辖区
                  jurisdiction: d.jurisdiction,
                  // 工作地址
                  workaddress: d.xq,
                  // 工作辖区
                  workjurisdiction: d.workjurisdiction,
                  signals: d.signals
               }
            uni.request({
               url: url,
               method: 'POST',
               data: data,
               success: (result) => {
                  console.log(result, 456)
                  uni.showToast({
                     title: '注册成功,请等待审核',
                     icon: 'none',
                     duration: 2000
                  });
               }
            });
            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() {
            var that = this;
            that.show = true;
         },
         // depl() {
         //    var that = this;
         //    uni.request({
         //       url: that.$store.state.piAPI + "/blade-system/dept/trees",
         //       method: 'get',
         //       success: (res) => {
         //          var routerArr = res.data.data;
         //          var arr = that.formatRoutes(routerArr);
         //          var list = [];
         //          if (that.deptXb != "") {
         //             list.push(arr[that.deptXb]);
         //             for (var i = 0; i < list.length; i++) {
         //                list[i].children.unshift({
         //                   label: '--请选择--',
         //                   value: 0,
         //                   children: []
         //                })
         //                for (var j = 0; j < list[i].children.length; j++) {
         //                   list[i].children[j].children.unshift({
         //                      label: '--请选择--',
         //                      value: 0,
         //                   })
         //                }
         //             }
         //             that.listbm = list;
         //             that.show = true;
         //          } else {
         //             uni.showToast({
         //                title: '请选择角色',
         //                icon: "none",
         //                duration: 1000
         //             });
         //          }
         //       }
         //    })
         // },
         deplxq() {
            var that = this;
            uni.request({
               url: that.$store.state.piAPI + "/jurisdiction/tree",
               method: 'get',
               success: (res) => {
                  var routerArr = res.data.data;
                  var arr = that.formatRoutes(routerArr);
                  var list = [];
                  list.push(arr);
                  for (var i = 0; i < arr.length; i++) {
                     arr[i].children.unshift({
                        label: '--请选择--',
                        value: 0,
                        children: []
                  setTimeout(function() {
                     uni.navigateTo({
                        url: '/pages/loging/loging'
                     })
                     for (var j = 0; j < arr[i].children.length; j++) {
                        arr[i].children[j].children.unshift({
                           label: '--请选择--',
                           value: 0,
                        })
                     }
                  }
                  that.listxq = arr;
                  that.showxq = true;
                  }, 2000);
               }
            })
            });
         },
         confirmxq(e) {
            var arr = "";
            var data = [];
            for (var i = 0; i < e.length; i++) {
               if (e[i].value != "0") {
                  arr += e[i].value + ",";
                  data.push(e[i]);
               }
            }
            var obj = arr.substr(0, arr.length - 1);
            this.form.xq = data[data.length - 1].label;
            this.form.xqobjId = obj;
            console.log(obj)
         },
         formatRoutes(routerArr) {
            var that = this;
            const arr = [];
            let obj = {};
            routerArr.forEach(router => {
               const tmp = {
                  ...router
               };
               if (tmp.hasChildren == true) {
                  tmp.children = that.formatRoutes(tmp.children);
                  const {
                     id,
                     title
                  } = router;
                  obj = {
                     label: tmp.title,
                     value: tmp.id,
                     children: tmp.children
                  }
               } else if (tmp.hasChildren == false || typeof(tmp.hasChildren) == 'undefined') {
                  obj = {
                     label: tmp.title,
                     value: tmp.id,
                     children: []
                  }
               }
               arr.push(obj);
            })
            return arr;
         },
         startRecord() {
            this.flag = true;
            // this.$message.success('开始录制')
            this.$refs.video.startRecord();
         },
         stopRecord() {
            this.flag = false;
            // this.$message.success('请看控制台视频文件的base64')
            this.$refs.video.stopRecord();
         },
         dataChange(data) {
            console.log(data);
         depl() {
            this.show = true;
         },
         // 选中任一radio时,由radio-group触发
         radioGroupChange(e) {
@@ -504,24 +472,81 @@
            this.form.jsid = e[0].value
            this.show = false;
         },
         regionChange() { // 移动地图后重新获取门店
            var that = this
            uni.createMapContext('SignLocationMap', this).getCenterLocation({
               success: res => {
                  that.getLocationInfor(res.longitude, res.latitude)
               },
               fail: res => {
                  uni.showModal({
                     content: '获取位置失败',
                     showCancel: false
                  })
               }
            })
         },
         getLocationInfor(longitude, latitude) {
            var that = this
            var point = new plus.maps.Point(longitude, latitude);
            plus.maps.Map.reverseGeocode(
               point, {},
               function(event) {
                  var address = event.address; // 转换后的地理位置
                  var point = event.coord; // 转换后的坐标信息
                  var coordType = event.coordType; // 转换后的坐标系类型
                  that.mapLocationName = address
                  that.mapLocationLongitude = point.longitude
                  that.mapLocationLatitude = point.latitude
               },
               function(e) {}
            );
         },
         confirmChangeBtn() {
            var that = this
            if (this.mapLocationName == "") {
               this.getLocationInfor(this.longitude, this.latitude)
            }
            if (this.regionOrPlace == "工作地点") {
               this.form.xq = this.mapLocationName
            } else {
               this.form.address = this.mapLocationName
            }
            uni.request({
               url: that.$store.state.piAPI + '/jurisdiction/isOnArea',
               method: 'get',
               data: {
                  jd: that.mapLocationLongitude,
                  wd: that.mapLocationLatitude
               },
               success: (res) => {
                  if (this.regionOrPlace == "工作地点") {
                     this.form.workjurisdiction = res.data.data[0].id
                  } else {
                     this.form.jurisdiction = res.data.data[0].id
                  }
               }
            });
            this.signLocation = false
         }
      },
      onReady() {
         this.$refs.uForm.setRules(this.rules);
         var that = this
         window.getRegionName = function(name) {
            console.log(name)
            if (name.indexOf('区') != -1) {
               that.regionName = name.replace('区', '派出所');
            } else if (name.indexOf('县') != -1) {
               that.regionName = name.replace('县', '派出所');
            } else if (name.indexOf('市') != -1) {
               that.regionName = name.replace('市', '市派出所');
            }
            that.form.xq = that.regionName
            that.mapShow = false
         }
         this.$refs.uForm.setRules(this.rules);
         uni.getSystemInfo({success: function (res) {
            that.screenHeight = res.windowHeight
            that.screenTop = res.windowTop
         }})
      },
      watch: {
         faceState() {
@@ -540,46 +565,13 @@
               this.faceMsg = '(服务连接失败!)';
            }
         }
      }
   };
</script>
</script>
<style lang="scss" scoped>
   .login-map-bc {
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      z-index: 111;
      background: rgba(0, 0, 0, .3);
   }
   .login-map-content {
      position: fixed;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 60%;
      z-index: 222;
      border-radius: 15px 15px 0 0;
      overflow: hidden;
      iframe {
         border: none;
      }
   }
   .login-map-close {
      position: absolute;
      top: 10px;
      right: 10px;
      width: 20px;
      height: 20px;
      z-index: 11;
   }
   .warp {
      display: flex;
      align-items: center;
@@ -624,18 +616,70 @@
   .registerUser {
      padding: 0 1.2rem;
   }
   .agree {
      margin: 27rpx 95rpx 0;
      margin-top: 28rpx;
      font-size: 22rpx;
      font-family: Adobe Heiti Std;
      font-weight: normal;
      color: #cacaca;
      line-height: 34rpx;
      text-align: center;
      .a {
         color: #000000;
         margin: 0 10rpx;
         color: #103289;
      }
   }
   @keyframes StartJump {
      0% {
         transform: translateY(-22px);
      }
      50% {
         transform: translateY(-32px);
      }
      100% {
         transform: translateY(-22px);
      }
   }
   .dingwBut {
      width: 48px;
      height: 48px;
      display: flex;
      align-items: center;
      justify-content: center;
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      margin: auto;
      z-index: 999;
      transform: translateY(-22px);
   }
   .confirmBtn {
      width: 96px;
      height: 36px;
      line-height: 32px;
      position: absolute;
      top: auto;
      left: 0;
      right: 0;
      bottom: 18rpx;
      margin: auto;
      z-index: 999;
      text-align: center;
      background: #103289;
      color: #fff;
      border-radius: 5px;
   }
</style>