diff --git a/pages/login/userRegister.vue b/pages/login/userRegister.vue index ca3bb98..248a43d 100644 --- a/pages/login/userRegister.vue +++ b/pages/login/userRegister.vue @@ -106,16 +106,71 @@ obj.type= that.type; if (!that.checkedParams(obj)) return; that.$u.api.visitorRegister(obj).then(res => { - uni.hideLoading(); - uni.showToast({ - title:"注册成功,请重新登录", + uni.hideLoading(); + uni.showToast({ + title:"注册成功", icon: "none" - }) - uni.reLaunch({ - url: '/pages/login/login_?autoLoading=no' - }) + }) + /* uni.reLaunch({ + url: '/pages/login/login_?autoLoading=no' + }) */ + that.$u.vuex('vuex_token', res.access) + that.$u.vuex('vuex_refresh', res.refresh); + that.$u.api.getUserInfo().then(user => { + if (user.avatar) { + user.avatar = this.vuex_host + user.avatar + } + that.$u.vuex('vuex_user', user) + if (user.avatar) { + user.avatar = this.vuex_host + user.avatar + } + let perms = []; + for (let key in user.perms) { + perms.push(key); + } + that.$u.vuex('vuex_perm', perms) + that.$u.api.hrmUserInfo().then(res => { + that.$u.vuex('vuex_employee', res) + if (res.type === 'employee') { + uni.reLaunch({ + url: '/pages/home/home_' + }) + } else { + //非正式员工 + if (res.id_number == '' || res.photo == '' || res.id_number == null || res.photo == null) { + //信息不完善,进入信息完善页面 + uni.reLaunch({ + url: '/pages/my/myInfoChange' + }) + } else { + //信息完善 + if (res.type === 'remployee') { + uni.reLaunch({ + url: '/pages/home/home_' + }) + } else { + uni.reLaunch({ + url: '/pages/workSpace/workSpace' + }) + } + } + } + }) + }) + // #ifdef APP-PLUS + let secret = that.ranStr(12) + let mySecret = { + 'username': obj.username, + 'secret': secret + } + that.$u.api.bindSecret({ + secret: secret + }).then(res => { + uni.setStorageSync('mySecret', JSON.stringify(mySecret)) + }).catch(e => {}) + // #endif + that.getUserRange(); }) - }, ranStr(e) { //形参e,需要产生随机字符串的长度 @@ -135,6 +190,60 @@ codeChange(text) { this.codeTips = text; }, + getUserRange() { + let that = this; + that.$u.api.deptList({ + page: 0, + type__in: 'rparty,dept', + query: '{id, name, parent, type}' + }).then(res => { + let list1 = res; + let list2 = []; + let reqList = []; + list1.forEach(function(item) { + reqList.push(that.$u.api.userList({ + page: 0, + belong_dept: item.id, + is_active: true, + query: '{id, name, belong_dept}' + })) + }) + Promise.all(reqList).then(res => { + for (let i = 0; i < res.length; i++) { + list1[i].children = res[i] + } + list1.forEach(item => { + if (item.type == 'dept') { + list2.push({ + ...item + }) + } + }) + that.$u.vuex('vuex_userRange', that.parseData(list1)) + that.$u.vuex('vuex_userRange2', that.parseData(list2)) + }) + }) + }, + parseData(data) { + // * 先生成parent建立父子关系 + const obj = {}; + data.forEach((item) => { + obj[item.id] = item; + }); + const parentList = []; + data.forEach((item) => { + const parent = obj[item.parent]; + if (parent) { + // * 当前项有父节点 + parent.children = parent.children || []; + parent.children.unshift(item); + } else { + parentList.push(item); + } + }); + return parentList; + }, + // 获取验证码 getCode(e) { // debugger;