添加onPageLoadInitAuth函数判断登录
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
@@ -30,11 +30,11 @@ Page({
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
@@ -76,13 +76,20 @@ Page({
|
||||
} else {
|
||||
delete temp.process_state;
|
||||
}
|
||||
|
||||
post('Departments/list', temp).then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ list: list });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Departments/list', temp)
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ list: list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
@@ -113,7 +120,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
@@ -25,16 +25,17 @@ Page({
|
||||
{ value: '2', label: '已审核' },
|
||||
],
|
||||
sort: [{ label: '创建日期', value: 'create_date' }],
|
||||
isLogin: false,
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
const key = getDataSet(e).key;
|
||||
@@ -76,13 +77,20 @@ Page({
|
||||
} else {
|
||||
delete temp.process_state;
|
||||
}
|
||||
|
||||
post('Groups/list', temp).then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ list: list });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Groups/list', temp)
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ list: list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
onGroupTap(e: any) {
|
||||
@@ -122,7 +130,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import { getAuthInfo, toArray } from '@/utils/util';
|
||||
|
||||
Page({
|
||||
@@ -8,53 +8,62 @@ Page({
|
||||
data: {
|
||||
list: [] as any[],
|
||||
group_id: '',
|
||||
isLogin: false,
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
|
||||
getList() {
|
||||
post('Groups/getGrpRights', { group_id: this.data.group_id }).then((res: any) => {
|
||||
const list = toArray(res.right_tree);
|
||||
const rights = `${res.rights || ''}`.split(',');
|
||||
this.data.list.length = 0;
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Groups/getGrpRights', { group_id: this.data.group_id })
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.right_tree);
|
||||
const rights = `${res.rights || ''}`.split(',');
|
||||
this.data.list.length = 0;
|
||||
|
||||
toArray(list).forEach((menu) => {
|
||||
const arr: any[] = [];
|
||||
toArray(menu.children).forEach((menu2) => {
|
||||
let flag = false;
|
||||
toArray(menu2.children).forEach((fun) => {
|
||||
fun.web_checked = rights.includes(`${fun.function_id}`);
|
||||
if (fun.web_checked) {
|
||||
flag = true;
|
||||
toArray(list).forEach((menu) => {
|
||||
const arr: any[] = [];
|
||||
toArray(menu.children).forEach((menu2) => {
|
||||
let flag = false;
|
||||
toArray(menu2.children).forEach((fun) => {
|
||||
fun.web_checked = rights.includes(`${fun.function_id}`);
|
||||
if (fun.web_checked) {
|
||||
flag = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (flag) {
|
||||
arr.push({
|
||||
menu_ch_name: menu2.menu_ch_name,
|
||||
menu_id: menu2.menu_id,
|
||||
functions: toArray(menu2.children),
|
||||
});
|
||||
}
|
||||
});
|
||||
if (arr.length) {
|
||||
this.data.list.push({
|
||||
menu_ch_name: menu.menu_ch_name,
|
||||
menu_id: menu.menu_id,
|
||||
children: arr,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (flag) {
|
||||
arr.push({
|
||||
menu_ch_name: menu2.menu_ch_name,
|
||||
menu_id: menu2.menu_id,
|
||||
functions: toArray(menu2.children),
|
||||
});
|
||||
}
|
||||
// console.log(this.data.list);
|
||||
this.setData({ list: this.data.list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
if (arr.length) {
|
||||
this.data.list.push({
|
||||
menu_ch_name: menu.menu_ch_name,
|
||||
menu_id: menu.menu_id,
|
||||
children: arr,
|
||||
});
|
||||
}
|
||||
});
|
||||
// console.log(this.data.list);
|
||||
this.setData({ list: this.data.list });
|
||||
});
|
||||
},
|
||||
|
||||
@@ -65,7 +74,7 @@ Page({
|
||||
this.data.group_id = `${options.group_id}`;
|
||||
wx.setNavigationBarTitle({ title: `${decodeURIComponent(`${options.name}`)} 权限` });
|
||||
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import { getAuthInfo, toArray } from '@/utils/util';
|
||||
|
||||
Page({
|
||||
@@ -7,53 +7,62 @@ Page({
|
||||
*/
|
||||
data: {
|
||||
list: [] as any[],
|
||||
isLogin: false,
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
},
|
||||
|
||||
getList() {
|
||||
post('Groups/myAuth').then((res: any) => {
|
||||
const list = toArray(res.right_tree);
|
||||
const rights = `${res.rights || ''}`.split(',');
|
||||
this.data.list.length = 0;
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Groups/myAuth')
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.right_tree);
|
||||
const rights = `${res.rights || ''}`.split(',');
|
||||
this.data.list.length = 0;
|
||||
|
||||
toArray(list).forEach((menu) => {
|
||||
const arr: any[] = [];
|
||||
toArray(menu.children).forEach((menu2) => {
|
||||
let flag = false;
|
||||
toArray(menu2.children).forEach((fun) => {
|
||||
fun.web_checked = rights.includes(`${fun.function_id}`);
|
||||
if (fun.web_checked) {
|
||||
flag = true;
|
||||
toArray(list).forEach((menu) => {
|
||||
const arr: any[] = [];
|
||||
toArray(menu.children).forEach((menu2) => {
|
||||
let flag = false;
|
||||
toArray(menu2.children).forEach((fun) => {
|
||||
fun.web_checked = rights.includes(`${fun.function_id}`);
|
||||
if (fun.web_checked) {
|
||||
flag = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (flag) {
|
||||
arr.push({
|
||||
menu_ch_name: menu2.menu_ch_name,
|
||||
menu_id: menu2.menu_id,
|
||||
functions: toArray(menu2.children),
|
||||
});
|
||||
}
|
||||
});
|
||||
if (arr.length) {
|
||||
this.data.list.push({
|
||||
menu_ch_name: menu.menu_ch_name,
|
||||
menu_id: menu.menu_id,
|
||||
children: arr,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (flag) {
|
||||
arr.push({
|
||||
menu_ch_name: menu2.menu_ch_name,
|
||||
menu_id: menu2.menu_id,
|
||||
functions: toArray(menu2.children),
|
||||
});
|
||||
}
|
||||
// console.log(this.data.list);
|
||||
this.setData({ list: this.data.list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
if (arr.length) {
|
||||
this.data.list.push({
|
||||
menu_ch_name: menu.menu_ch_name,
|
||||
menu_id: menu.menu_id,
|
||||
children: arr,
|
||||
});
|
||||
}
|
||||
});
|
||||
// console.log(this.data.list);
|
||||
this.setData({ list: this.data.list });
|
||||
});
|
||||
},
|
||||
|
||||
@@ -61,7 +70,7 @@ Page({
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(_options) {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { loginStatusPage, post } from '@/utils/https';
|
||||
import { onPageLoadInitAuth, post } from '@/utils/https';
|
||||
import {
|
||||
cloneLite,
|
||||
getAuthInfo,
|
||||
@@ -31,16 +31,17 @@ Page({
|
||||
user_id: wx.getStorageSync('user_id'),
|
||||
depOption: [] as any[],
|
||||
groupsOption: [] as any[],
|
||||
isLogin: false,
|
||||
},
|
||||
handleLogin(e: any) {
|
||||
this.setData({ isLogin: e.detail });
|
||||
if (e.detail) {
|
||||
this.init();
|
||||
this.getList();
|
||||
}
|
||||
},
|
||||
init() {
|
||||
this.setData({ authInfo: getAuthInfo() });
|
||||
this.getList();
|
||||
this.getOrderStep();
|
||||
},
|
||||
searchChange(e: any) {
|
||||
@@ -106,13 +107,20 @@ Page({
|
||||
this.data.params.curr_page = curr;
|
||||
this.setData({ params: this.data.params });
|
||||
const temp = cloneLite(this.data.params);
|
||||
|
||||
post('Users/getStaff', temp).then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ count: toNumber(res.count), list: list });
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
post('Users/getStaff', temp)
|
||||
.then((res: any) => {
|
||||
const list = toArray(res.data);
|
||||
if (list.length == 0 && this.data.params.curr_page > 1) {
|
||||
this.getList(this.data.params.curr_page - 1);
|
||||
}
|
||||
this.setData({ count: toNumber(res.count), list: list, isLogin: true });
|
||||
resolve(res);
|
||||
})
|
||||
.catch((res) => {
|
||||
this.setData({ isLogin: false });
|
||||
reject(res);
|
||||
});
|
||||
});
|
||||
},
|
||||
onReinstatedStaff(e: any) {
|
||||
@@ -170,7 +178,7 @@ Page({
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
loginStatusPage(this);
|
||||
onPageLoadInitAuth(this, () => this.getList());
|
||||
},
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user