zengh
2021-08-27 532faa49707dd6ee6c9843f39ec3d921cb17bf42
pages/registerUser/registerUser.vue
@@ -5,9 +5,21 @@
            :required="item.requireds" v-for="(item, index) in list" :key="index">
            <u-input v-model="form[item.froms]" :placeholder="item.placeholder" />
         </u-form-item>
         <u-form-item label="部门" left-icon="account-fill" label-width="200" :required="true">
            <u-input v-model="form.obj" type="select" placeholder="请选择部门" :border="true" @click="depl" />
         <u-form-item label="角色" prop="role" left-icon="account-fill" label-width="200" :required="true">
            <u-radio-group v-model="form.role" @change="radioGroupChange">
               <u-radio v-for="(item, index) in role" :key="index" :name="item.name" :disabled="item.disabled">
                  {{ item.name }}
               </u-radio>
            </u-radio-group>
         </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" type="select" placeholder="请选择组织机构" :border="true" @click="depl" />
            <u-select v-model="show" mode="mutil-column-auto" :list="listbm" @confirm="confirm"></u-select>
         </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="deplxq" />
            <u-select v-model="showxq" mode="mutil-column-auto" :list="listxq" @confirm="confirmxq"></u-select>
         </u-form-item>
         <u-form-item label="性别" label-width="200" left-icon="man">
            <u-radio-group v-model="form.sex">
@@ -17,7 +29,7 @@
            </u-radio-group>
         </u-form-item>
      </u-form>
      <u-button class="submit" @click="zc">
         下一步</u-button>
      <!-- <u-button class="submit" @click="submit">提交</u-button> -->
@@ -29,7 +41,11 @@
      data() {
         return {
            show: false,
            showxq: false,
            xqShow: true,
            listbm: [],
            listxq: [],
            deptXb: "",
            flag: false,
            list: [{
                  title: '账号',
@@ -90,6 +106,23 @@
                  disabled: false
               },
            ],
            role: [{
                  name: '民警',
                  disabled: false
               },
               {
                  name: '群众',
                  disabled: false
               },
               {
                  name: '群防队伍',
                  disabled: false
               },
               // {
               //    name: '保安',
               //    disabled: false
               // },
            ],
            objList: [{
                  text: '赣州'
               },
@@ -107,6 +140,9 @@
               sex: '男',
               obj: '',
               objId: '',
               xq: '',
               xqobjId: '',
               jsid: ''
            },
            rules: {
               user: [{
@@ -146,6 +182,24 @@
               name: [{
                  required: true,
                  message: '请输入姓名',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }],
               obj: [{
                  required: true,
                  message: '请选择组织机构',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }],
               xq: [{
                  required: true,
                  message: '请选择辖区',
                  // 可以单个或者同时写两个触发验证方式
                  trigger: ['change', 'blur'],
               }],
               role: [{
                  required: true,
                  message: '请选择角色',
                  // 可以单个或者同时写两个触发验证方式 
                  trigger: ['change', 'blur'],
               }],
@@ -192,19 +246,12 @@
      methods: {
         zc() {
            var that = this;
            // if (that.form.obj == "" || that.form.obj == null) {
            //    uni.showToast({
            //       title: '请选择部门',
            //       icon: 'none',
            //       duration: 2000
            //    });
            //    return;
            // }
            this.$refs.uForm.validate(valid => {
               if (true) {
               if (valid) {
                  var d = this.form;
                  uni.navigateTo({
                     url: '/pages/registerUser/idphoto?data= '+encodeURIComponent(JSON.stringify(d))
                     url: '/pages/registerUser/idphoto?data= ' + encodeURIComponent(JSON.stringify(
                        d))
                  });
               }
            });
@@ -217,22 +264,88 @@
               success: (res) => {
                  var routerArr = res.data.data;
                  var arr = that.formatRoutes(routerArr);
                  console.log(arr)
                  var list = [];
                  list.push(arr[0]);
                  that.listbm = list;
                  that.show = true;
                  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: []
                     })
                     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;
               }
            })
         },
         confirm(e) {
            this.form.obj = e[e.length - 1].label;
            var arr = "";
            var data = [];
            for (var i = 0; i < e.length; i++) {
               arr += e[i].value + ",";
               if (e[i].value != "0") {
                  arr += e[i].value + ",";
                  data.push(e[i]);
               }
            }
            var obj = arr.substr(0, arr.length - 1);
            this.form.obj = data[data.length - 1].label;
            this.form.objId = obj;
         },
         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;
@@ -255,96 +368,16 @@
                     value: tmp.id,
                     children: tmp.children
                  }
               } else if (tmp.hasChildren == false) {
               } else if (tmp.hasChildren == false || typeof(tmp.hasChildren) == 'undefined') {
                  obj = {
                     label: tmp.title,
                     value: tmp.id,
                     children: []
                  }
               }
               arr.push(obj);
            })
            return arr;
         },
         camera() {
            let that = this;
            uni.showToast({
               title: '功能研发中',
               icon: 'none',
               duration: 2000
            });
            // uni.showLoading({
            //    title: '加载中'
            // });
            // var i = 0;
            // var time = setTimeout(() => {
            //    if (i == 0) {
            //       uni.showToast({
            //          title: '未进行验证!',
            //          icon: "none",
            //          duration: 1000
            //       });
            //       clearTimeout(time);
            //       time = null;
            //    } else {
            //       // console.log('进行验证')
            //    }
            // }, 2000)
            // uni.chooseImage({
            //    count: 1, //默认9
            //    sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
            //    // sourceType: 'camera', //从相册选择
            //    sourceType: ['camera', 'album'], //从相册选择
            //    success: function(res) {
            //       i = 1;
            //       var img = res.tempFiles;
            //       console.log('img', img)
            //       // imgToBase64(res)
            //       var url = that.$store.state.piAPI + 'blade-user/faceCompare',
            //          // var url = 'http://192.168.0.114:82/' + 'blade-user/faceCompare',
            //          data = {
            //             "name": that.form.name,
            //             "idCardNo": that.form.carId
            //          };
            //       uni.uploadFile({
            //          url: url,
            //          filePath: img[0].path,
            //          name: 'file',
            //          formData: data,
            //          success: (data) => {
            //             if (data.statusCode == 200) {
            //                var data = JSON.parse(data.data);
            //                if (data.data.result == 0) {
            //                   that.faceState = 1;
            //                   uni.showToast({
            //                      title: '人脸识别成功!',
            //                      icon: "none",
            //                      duration: 1000
            //                   });
            //                } else {
            //                   that.faceState = -1;
            //                   uni.showToast({
            //                      title: data.data.errMsg == "pic not has face" ?
            //                         '未检测到人脸' : data.data.errMsg,
            //                      icon: "none",
            //                      duration: 1000
            //                   });
            //                }
            //             } else {
            //                that.faceState = 0;
            //                uni.showToast({
            //                   title: '服务器连接失败!',
            //                   icon: "none",
            //                   duration: 1000
            //                });
            //             }
            //             console.log(data)
            //          }
            //       });
            //    },
            //    complete: function() {
            //       console.log(4534)
            //    }
            // })
         },
         startRecord() {
            this.flag = true;
@@ -362,44 +395,22 @@
         objCallback(index) {
            this.form.obj = this.objList[index].text;
         },
         submit() {
            this.$refs.uForm.validate(valid => {
               if (valid && this.faceState == 1) {
                  // console.log('验证通过');
                  console.log(this.form);
                  var d = this.form;
                  var url = that.$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,
                     }
                  uni.request({
                     url: url,
                     method: 'POST',
                     data: data,
                     success: (res) => {
                        console.log(res)
                     }
                  })
                  // uni.showToast({
                  //    title: '提交成功!',
                  //    icon: "none",
                  //    duration: 1000
                  // });
               } else {
                  // console.log('验证失败');
                  uni.showToast({
                     title: '确认信息无误后重试!',
                     icon: "none",
                     duration: 1000
                  });
               }
            });
         // 选中任一radio时,由radio-group触发
         radioGroupChange(e) {
            this.xqShow = true;
            if (e == "群众") {
               this.xqShow = false;
               this.form.jsid = '1416225849858883585';
               this.form.objId = '1424616967934959617,1424617046523633666';
            } else if (e == "民警") {
               this.form.jsid = '1417092295132561409';
               this.deptXb = "0";
            } else if (e == "群防队伍") {
               this.deptXb = "1";
               this.form.jsid = '1372092102682521602';
            } else if (e == "保安") {
               this.form.jsid = '';
            }
         }
      },
      onReady() {
@@ -428,21 +439,21 @@
</script>
<style lang="scss" scoped>
   .warp {
         display: flex;
         align-items: center;
         justify-content: center;
         height: 100%;
      }
      .rect {
         text-align: center;
         width: 120px;
         height: 120px;
      }
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100%;
   }
   .rect {
      text-align: center;
      width: 120px;
      height: 120px;
   }
   .submit {
      margin: 30rpx 50rpx 0;
      margin: 30rpx 50rpx 50rpx;
      border: none;
      width: 572rpx;
      height: 86rpx;