registerChange

This commit is contained in:
shijing 2022-11-01 17:03:11 +08:00
parent 0832c435bc
commit 7204416ef2
1 changed files with 117 additions and 8 deletions

View File

@ -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;