|
@@ -1,87 +1,59 @@
|
|
|
-const _Http = getApp().globalData.http;
|
|
|
-let count = 0; //接口完成数量
|
|
|
-
|
|
|
function loginMsg(res) {
|
|
|
wx.setStorageSync('account_list', res.account_list);
|
|
|
if (res.account_list.length == 1) {
|
|
|
- let item = res.account_list[0];
|
|
|
- wx.setStorageSync('userrole', item.usertype == 1 ? '业务员' : '经销商');
|
|
|
- wx.setStorageSync('userMsg', item)
|
|
|
- query_userauth();
|
|
|
+ wx.setStorageSync('userMsg', res.account_list[0])
|
|
|
+ init();
|
|
|
} else {
|
|
|
- wx.redirectTo({
|
|
|
- url: './selectSite',
|
|
|
- })
|
|
|
+ wx.redirectTo({
|
|
|
+ url: './selectSite',
|
|
|
+ })
|
|
|
}
|
|
|
}
|
|
|
-/* 获取用户权限 */
|
|
|
-function query_userauth() {
|
|
|
- query_adspacelist();
|
|
|
- querySite_Parameter();
|
|
|
- wx.setStorageSync('userauth', []);
|
|
|
- _Http.basic({
|
|
|
- "classname": "sysmanage.develop.userauth.userauth",
|
|
|
- "method": "query_userauth",
|
|
|
- content: {
|
|
|
- nocache: true
|
|
|
- }
|
|
|
- }).then(res => {
|
|
|
- console.log("查询权限", res.data)
|
|
|
- if (res.msg != '成功') return wx.showToast({
|
|
|
- title: '权限查询失败,请稍后再试',
|
|
|
- icon: "none"
|
|
|
- })
|
|
|
- wx.setStorageSync('userauth', res.data);
|
|
|
- count += 1;
|
|
|
- toHome();
|
|
|
- });
|
|
|
- if (!getApp().globalData.socketEstablish) getApp().initSocket();
|
|
|
-}
|
|
|
-/* 查询站点数据 */
|
|
|
-function querySite_Parameter() {
|
|
|
- _Http.basic({
|
|
|
- "classname": "webmanage.site.site",
|
|
|
- "method": "querySite_Parameter",
|
|
|
- "content": {}
|
|
|
- }).then(res => {
|
|
|
- if (res.msg != '成功') return wx.showToast({
|
|
|
- title: res.msg,
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- wx.setStorageSync('siteP', res.data);
|
|
|
- count += 1;
|
|
|
- toHome();
|
|
|
- })
|
|
|
-}
|
|
|
-/* 查询轮播图 */
|
|
|
-function query_adspacelist() {
|
|
|
- _Http.basic({
|
|
|
- "classname": "common.adspace.adspace",
|
|
|
- "method": "query_adspacelist",
|
|
|
- "content": {}
|
|
|
- }).then(res => {
|
|
|
- if (res.msg != '成功') return wx.showToast({
|
|
|
- title: res.msg,
|
|
|
- icon: "none"
|
|
|
- });
|
|
|
- wx.setStorageSync('banner_list', res.data)
|
|
|
- count += 1;
|
|
|
- toHome();
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
-function toHome() {
|
|
|
- if (count < 3) return;
|
|
|
- let pages = getCurrentPages();
|
|
|
- let prevPage = pages[pages.length - 2];
|
|
|
- if (prevPage && prevPage.__route__ == 'pages/tabbar/home/index') prevPage.refreshData();
|
|
|
- wx.switchTab({
|
|
|
- url: '/pages/tabbar/home/index'
|
|
|
+function init() {
|
|
|
+ const _Http = getApp().globalData.http;
|
|
|
+ Promise.all([{
|
|
|
+ "classname": "sysmanage.develop.userauth.userauth",
|
|
|
+ "method": "query_userauth", //获取用户权限
|
|
|
+ content: {
|
|
|
+ nocache: true
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ "classname": "webmanage.site.site",
|
|
|
+ "method": "querySite_Parameter", //查询站点数据
|
|
|
+ content: {
|
|
|
+ nocache: true
|
|
|
+ }
|
|
|
+ }, {
|
|
|
+ "classname": "common.adspace.adspace",
|
|
|
+ "method": "query_adspacelist", //查询轮播图
|
|
|
+ content: {
|
|
|
+ nocache: true
|
|
|
+ }
|
|
|
+ }].map(v => _Http.basic(v))).then(list => {
|
|
|
+ console.log("登录初始化", list)
|
|
|
+ if (list.some(res => res.msg != '成功')) return list.filter(res => {
|
|
|
+ if (res.msg != '成功') wx.showToast({
|
|
|
+ title: res.msg,
|
|
|
+ icon: "none",
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ })
|
|
|
+ wx.setStorageSync('userauth', list[0].data);
|
|
|
+ wx.setStorageSync('siteP', list[1].data);
|
|
|
+ wx.setStorageSync('banner_list', list[2].data)
|
|
|
+ if (!getApp().globalData.socketEstablish) getApp().initSocket();
|
|
|
+ let pages = getCurrentPages();
|
|
|
+ let prevPage = pages[pages.length - 2];
|
|
|
+ if (prevPage && prevPage.__route__ == 'pages/tabbar/home/index') prevPage.refreshData();
|
|
|
+ wx.switchTab({
|
|
|
+ url: '/pages/tabbar/home/index'
|
|
|
+ })
|
|
|
})
|
|
|
- count = 0;
|
|
|
}
|
|
|
+
|
|
|
/* 站点数据查询 */
|
|
|
module.exports = {
|
|
|
loginMsg,
|
|
|
- query_userauth
|
|
|
+ init
|
|
|
}
|