|
|
@ -1,24 +1,7 @@ |
|
|
import { |
|
|
|
|
|
config, |
|
|
|
|
|
getUserInfo |
|
|
|
|
|
} from "../api/user" |
|
|
|
|
|
import { |
|
|
|
|
|
zconfig, |
|
|
|
|
|
loginToken, |
|
|
|
|
|
getBaseInfo, |
|
|
|
|
|
getPopupInfo, |
|
|
|
|
|
updateUserInfo |
|
|
|
|
|
} from "../api/ztb" |
|
|
|
|
|
import { |
|
|
|
|
|
pconfig |
|
|
|
|
|
} from "../api/payment" |
|
|
|
|
|
import { |
|
|
|
|
|
mconfig |
|
|
|
|
|
} from "../api/moment" |
|
|
|
|
|
import { |
|
|
|
|
|
sconfig, |
|
|
|
|
|
getOrderExists |
|
|
|
|
|
} from "../api/saas" |
|
|
|
|
|
|
|
|
import { config, getUserInfo } from "../api/user" |
|
|
|
|
|
import { zconfig, loginToken, getBaseInfo, getPopupInfo } from "../api/ztb" |
|
|
|
|
|
import { pconfig } from "../api/payment" |
|
|
|
|
|
import { mconfig } from "../api/moment" |
|
|
const util = require('../../utils/util') |
|
|
const util = require('../../utils/util') |
|
|
const event = require('../../utils/event') |
|
|
const event = require('../../utils/event') |
|
|
const storage = require('../../utils/storage') |
|
|
const storage = require('../../utils/storage') |
|
|
@ -26,47 +9,19 @@ const app = getApp() |
|
|
|
|
|
|
|
|
Page({ |
|
|
Page({ |
|
|
data: { |
|
|
data: { |
|
|
TabList: [{ |
|
|
|
|
|
index: 0, |
|
|
|
|
|
value: 'article', |
|
|
|
|
|
badge: 0, |
|
|
|
|
|
name: '情报' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
index: 1, |
|
|
|
|
|
value: 'mall', |
|
|
|
|
|
badge: 0, |
|
|
|
|
|
name: '交易' |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
index: 2, |
|
|
|
|
|
value: 'home', |
|
|
|
|
|
badge: 0, |
|
|
|
|
|
name: '我的' |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
TabList: [{ index: 0, value: 'article', badge: 0, name: '情报' }, |
|
|
|
|
|
{ index: 1, value: 'mall', badge: 0, name: '交易' }, |
|
|
|
|
|
{ index: 2, value: 'home', badge: 0, name: '我的' } |
|
|
], |
|
|
], |
|
|
pageIndex: 1, |
|
|
pageIndex: 1, |
|
|
safeBottom: app.globalData.safeBottom, |
|
|
safeBottom: app.globalData.safeBottom, |
|
|
inited: false, |
|
|
inited: false, |
|
|
path: null, |
|
|
path: null, |
|
|
landInfo: null, |
|
|
landInfo: null, |
|
|
visible: false, |
|
|
|
|
|
|
|
|
|
|
|
hasShowedLoginTag: false, //是否已展示过登陆标签填写页面
|
|
|
|
|
|
isTokenHaveStatus: false, |
|
|
|
|
|
|
|
|
visible: false |
|
|
}, |
|
|
}, |
|
|
/************************************** 初始化流程 ********************************************/ |
|
|
/************************************** 初始化流程 ********************************************/ |
|
|
onLoad: function (options) { |
|
|
onLoad: function (options) { |
|
|
storage.put('isTokenHaveStatus', false) |
|
|
|
|
|
const updateManager = wx.getUpdateManager() |
|
|
|
|
|
updateManager.onCheckForUpdate(function (res) { |
|
|
|
|
|
// 请求完新版本信息的回调
|
|
|
|
|
|
// console.log('updateManager>>>' + res.hasUpdate)
|
|
|
|
|
|
}) |
|
|
|
|
|
updateManager.onUpdateReady(function () { |
|
|
|
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
|
|
updateManager.applyUpdate() |
|
|
|
|
|
}) |
|
|
|
|
|
if (options.url) { |
|
|
if (options.url) { |
|
|
this.data.path = options.url |
|
|
this.data.path = options.url |
|
|
if (options.key && options.value) { |
|
|
if (options.key && options.value) { |
|
|
@ -74,70 +29,20 @@ Page({ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
event.on('EventMessage', this, this.onEvent) |
|
|
}, |
|
|
|
|
|
onReady: function () { |
|
|
|
|
|
wx.showLoading({ |
|
|
|
|
|
title: '获取中', |
|
|
|
|
|
mask: true |
|
|
|
|
|
}) |
|
|
|
|
|
wx.getSystemInfo({ |
|
|
|
|
|
success: e => { |
|
|
|
|
|
app.globalData.isIos = this.checkIos(e) |
|
|
|
|
|
app.globalData.dev = e.platform == 'devtools' |
|
|
|
|
|
|
|
|
|
|
|
let custom = wx.getMenuButtonBoundingClientRect() |
|
|
|
|
|
app.globalData.Custom = custom |
|
|
|
|
|
// 顶部操作栏高度
|
|
|
|
|
|
app.globalData.CustomBar = custom.bottom + custom.top - e.statusBarHeight + (app.globalData.isIos ? 4 : 0) |
|
|
|
|
|
let windowHeight = e.windowHeight * (750 / e.windowWidth) |
|
|
|
|
|
|
|
|
|
|
|
let safeBottom = e.windowHeight - e.safeArea.bottom |
|
|
|
|
|
if (safeBottom > e.windowHeight) { |
|
|
|
|
|
safeBottom = 34 |
|
|
|
|
|
} |
|
|
|
|
|
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth) |
|
|
|
|
|
// 状态栏高度
|
|
|
|
|
|
app.globalData.StatusBar = e.statusBarHeight * (750 / e.windowWidth) |
|
|
|
|
|
let statusBarHeight = app.globalData.CustomBar * (750 / e.windowWidth) |
|
|
|
|
|
app.globalData.statusBarHeight = statusBarHeight |
|
|
|
|
|
// fragmentHeight:指的是整个页面statusBarHeight以下的高度
|
|
|
|
|
|
app.globalData.fragmentHeight = windowHeight - statusBarHeight |
|
|
|
|
|
app.globalData.safeFragmentHeight = windowHeight - statusBarHeight - app.globalData.safeBottom |
|
|
|
|
|
app.globalData.windowWidth = e.windowWidth |
|
|
|
|
|
|
|
|
|
|
|
this.data.inited = true |
|
|
|
|
|
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100 |
|
|
|
|
|
event.emit('InitMessage', { |
|
|
|
|
|
what: 8, |
|
|
|
|
|
desc: 'Logined' |
|
|
|
|
|
}) |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
fragment: fheght, |
|
|
|
|
|
safeBottom: app.globalData.safeBottom |
|
|
|
|
|
}) |
|
|
|
|
|
var authorization = app.globalData.token || storage.get('Authorization') |
|
|
|
|
|
if (authorization) { |
|
|
|
|
|
app.globalData.token = authorization |
|
|
|
|
|
this.fetchUserInfo() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.toIndex() |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
checkIos: function (e) { |
|
|
|
|
|
if ('ios' === e.platform) { |
|
|
|
|
|
return true |
|
|
|
|
|
} |
|
|
|
|
|
if (e.system.startsWith('iOS')) { |
|
|
|
|
|
return true |
|
|
|
|
|
|
|
|
this.data.inited = true |
|
|
|
|
|
wx.showLoading({ title: '获取中', mask: true }) |
|
|
|
|
|
const fheght = (app.globalData.safeFragmentHeight + app.globalData.statusBarHeight) - 100 |
|
|
|
|
|
this.setData({ fragment: fheght, safeBottom: app.globalData.safeBottom }) |
|
|
|
|
|
var authorization = app.globalData.token || storage.get('Authorization') |
|
|
|
|
|
if (authorization) { |
|
|
|
|
|
app.globalData.token = authorization |
|
|
|
|
|
this.fetchUserInfo() |
|
|
|
|
|
} else { |
|
|
|
|
|
this.toIndex() |
|
|
} |
|
|
} |
|
|
return false |
|
|
|
|
|
}, |
|
|
}, |
|
|
fetchUserInfo: function () { |
|
|
fetchUserInfo: function () { |
|
|
config.header = { |
|
|
|
|
|
'Authorization': 'QNT ' + app.globalData.token |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
config.header = { 'Authorization': 'QNT ' + app.globalData.token } |
|
|
getUserInfo().then(result => { |
|
|
getUserInfo().then(result => { |
|
|
this.toIndex() |
|
|
this.toIndex() |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
@ -147,15 +52,11 @@ Page({ |
|
|
defaultIndex: function () { |
|
|
defaultIndex: function () { |
|
|
this.onResume() |
|
|
this.onResume() |
|
|
if (this.data.path) { |
|
|
if (this.data.path) { |
|
|
wx.navigateTo({ |
|
|
|
|
|
url: this.data.path |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
wx.navigateTo({ url: this.data.path }) |
|
|
} |
|
|
} |
|
|
getPopupInfo().then(result => { |
|
|
getPopupInfo().then(result => { |
|
|
if (result.data) { |
|
|
if (result.data) { |
|
|
this.setData({ |
|
|
|
|
|
landInfo: result.data |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ landInfo: result.data }) |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
@ -169,15 +70,12 @@ Page({ |
|
|
zconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
zconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
pconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
pconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
mconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
mconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
storage.put('isTokenHaveStatus', true) |
|
|
|
|
|
// 登录流程完成;
|
|
|
|
|
|
if(!util.isEmpty(result.data.userToken)){ |
|
|
|
|
|
this.handleUserToken(result.data.userToken) |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
|
|
|
getBaseInfo().then(result => { |
|
|
getBaseInfo().then(result => { |
|
|
app.globalData.userInfo = result.data |
|
|
app.globalData.userInfo = result.data |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
|
|
|
if(app.globalData.userInfo.hasShowedLoginTag == false){ |
|
|
|
|
|
wx.navigateTo({ url: '/pages/home/tab1/index' }) |
|
|
|
|
|
} |
|
|
this.defaultIndex() |
|
|
this.defaultIndex() |
|
|
}).catch(err => { |
|
|
}).catch(err => { |
|
|
wx.hideLoading() |
|
|
wx.hideLoading() |
|
|
@ -188,36 +86,6 @@ Page({ |
|
|
this.defaultIndex() |
|
|
this.defaultIndex() |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
}, |
|
|
handleUserToken: function (userToken) { |
|
|
|
|
|
sconfig.header = { |
|
|
|
|
|
'user-token': userToken |
|
|
|
|
|
} |
|
|
|
|
|
getOrderExists().then(result => { |
|
|
|
|
|
if (Number(result.data) != 1 || !app.evn) { |
|
|
|
|
|
getBaseInfo().then(result => { |
|
|
|
|
|
app.globalData.userInfo = result.data |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
this.defaultIndex() |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
this.defaultIndex() |
|
|
|
|
|
}) |
|
|
|
|
|
} else { |
|
|
|
|
|
getBaseInfo().then(result => { |
|
|
|
|
|
app.globalData.userInfo = result.data |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
wx.redirectTo({ url: '/pages/paper/index' }) |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
wx.redirectTo({ url: '/pages/paper/index' }) |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}).catch(err => { |
|
|
|
|
|
wx.hideLoading() |
|
|
|
|
|
util.showToast(err) |
|
|
|
|
|
this.defaultIndex() |
|
|
|
|
|
}) |
|
|
|
|
|
}, |
|
|
|
|
|
onResume: function () { |
|
|
onResume: function () { |
|
|
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) |
|
|
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) |
|
|
if (pageView && this.data.inited) { |
|
|
if (pageView && this.data.inited) { |
|
|
@ -227,9 +95,7 @@ Page({ |
|
|
//事件处理函数
|
|
|
//事件处理函数
|
|
|
onNavChange: function (e) { |
|
|
onNavChange: function (e) { |
|
|
// 处理用户的登录校验
|
|
|
// 处理用户的登录校验
|
|
|
this.setData({ |
|
|
|
|
|
pageIndex: Number(e.currentTarget.dataset.tab) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) |
|
|
this.onResume() |
|
|
this.onResume() |
|
|
}, |
|
|
}, |
|
|
/** |
|
|
/** |
|
|
@ -239,33 +105,13 @@ Page({ |
|
|
if (this.data.inited) { |
|
|
if (this.data.inited) { |
|
|
this.onResume() |
|
|
this.onResume() |
|
|
} |
|
|
} |
|
|
// wx.navigateTo({ url: '/pages/home/tab1/index' })
|
|
|
|
|
|
var a=storage.get('isTokenHaveStatus') |
|
|
|
|
|
if(a==true && app.globalData.token){ |
|
|
|
|
|
getBaseInfo().then(result => { |
|
|
|
|
|
this.setData({ |
|
|
|
|
|
hasShowedLoginTag: result.data.hasShowedLoginTag |
|
|
|
|
|
}) |
|
|
|
|
|
if (this.data.hasShowedLoginTag == false) { |
|
|
|
|
|
this.updateUserInfoFct({ |
|
|
|
|
|
hasShowedLoginTag: true |
|
|
|
|
|
}) |
|
|
|
|
|
storage.put('isfirstlogin',true) |
|
|
|
|
|
wx.navigateTo({ |
|
|
|
|
|
url: '/pages/home/tab1/index' |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
if(app.globalData.userInfo && app.globalData.userInfo.hasShowedLoginTag == false){ |
|
|
|
|
|
wx.navigateTo({ url: '/pages/home/tab1/index' }) |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
updateUserInfoFct: function (model) { |
|
|
|
|
|
updateUserInfo(model).then(result => {}) |
|
|
|
|
|
}, |
|
|
|
|
|
onEvent: function (message) { |
|
|
onEvent: function (message) { |
|
|
if(message.what == 250){ |
|
|
if(message.what == 250){ |
|
|
this.setData({ pageIndex: 0 }) |
|
|
this.setData({ pageIndex: 0 }) |
|
|
} else if(message.what == 884){ |
|
|
|
|
|
wx.navigateBack() |
|
|
|
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
stopTouchMove: function (e) { |
|
|
stopTouchMove: function (e) { |
|
|
@ -273,15 +119,10 @@ Page({ |
|
|
}, |
|
|
}, |
|
|
// 弹出框的处理;
|
|
|
// 弹出框的处理;
|
|
|
onClose: function () { |
|
|
onClose: function () { |
|
|
this.setData({ |
|
|
|
|
|
visible: false, |
|
|
|
|
|
landInfo: null |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ visible: false, landInfo: null }) |
|
|
}, |
|
|
}, |
|
|
onImageLoad: function () { |
|
|
onImageLoad: function () { |
|
|
this.setData({ |
|
|
|
|
|
visible: true |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ visible: true }) |
|
|
}, |
|
|
}, |
|
|
onImageClick: function () { |
|
|
onImageClick: function () { |
|
|
if (this.data.landInfo.redirectInfo.targetView == 'showH5') { |
|
|
if (this.data.landInfo.redirectInfo.targetView == 'showH5') { |
|
|
@ -289,10 +130,7 @@ Page({ |
|
|
return |
|
|
return |
|
|
} |
|
|
} |
|
|
util.navigateTarget(this.data.landInfo.redirectInfo) |
|
|
util.navigateTarget(this.data.landInfo.redirectInfo) |
|
|
this.setData({ |
|
|
|
|
|
visible: false, |
|
|
|
|
|
landInfo: null |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
this.setData({ visible: false, landInfo: null }) |
|
|
}, |
|
|
}, |
|
|
toRule: function () { |
|
|
toRule: function () { |
|
|
if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') { |
|
|
if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') { |
|
|
|