|
|
|
@ -1,8 +1,24 @@ |
|
|
|
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, |
|
|
|
updateUserInfo |
|
|
|
} from "../api/ztb" |
|
|
|
import { |
|
|
|
pconfig |
|
|
|
} from "../api/payment" |
|
|
|
import { |
|
|
|
mconfig |
|
|
|
} from "../api/moment" |
|
|
|
import { |
|
|
|
sconfig, |
|
|
|
getOrderExists |
|
|
|
} from "../api/saas" |
|
|
|
const util = require('../../utils/util') |
|
|
|
const event = require('../../utils/event') |
|
|
|
const storage = require('../../utils/storage') |
|
|
|
@ -10,10 +26,24 @@ const app = getApp() |
|
|
|
|
|
|
|
Page({ |
|
|
|
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, |
|
|
|
safeBottom: app.globalData.safeBottom, |
|
|
|
@ -22,7 +52,8 @@ Page({ |
|
|
|
landInfo: null, |
|
|
|
visible: false, |
|
|
|
|
|
|
|
hasShowedLoginTag:false,//是否已展示过登陆标签填写页面
|
|
|
|
hasShowedLoginTag: false, //是否已展示过登陆标签填写页面
|
|
|
|
isTokenHaveStatus: false, |
|
|
|
}, |
|
|
|
/************************************** 初始化流程 ********************************************/ |
|
|
|
onLoad: function (options) { |
|
|
|
@ -35,20 +66,23 @@ Page({ |
|
|
|
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
|
|
|
|
updateManager.applyUpdate() |
|
|
|
}) |
|
|
|
if(options.url){ |
|
|
|
if (options.url) { |
|
|
|
this.data.path = options.url |
|
|
|
if(options.key && options.value){ |
|
|
|
if (options.key && options.value) { |
|
|
|
this.data.path += '?' + options.key + '=' + options.value |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
onReady: function () { |
|
|
|
wx.showLoading({ title: '获取中', mask: true }) |
|
|
|
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 |
|
|
|
// 顶部操作栏高度
|
|
|
|
@ -56,7 +90,7 @@ Page({ |
|
|
|
let windowHeight = e.windowHeight * (750 / e.windowWidth) |
|
|
|
|
|
|
|
let safeBottom = e.windowHeight - e.safeArea.bottom |
|
|
|
if(safeBottom > e.windowHeight){ |
|
|
|
if (safeBottom > e.windowHeight) { |
|
|
|
safeBottom = 34 |
|
|
|
} |
|
|
|
app.globalData.safeBottom = safeBottom * (750 / e.windowWidth) |
|
|
|
@ -71,10 +105,16 @@ Page({ |
|
|
|
|
|
|
|
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 }) |
|
|
|
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){ |
|
|
|
if (authorization) { |
|
|
|
app.globalData.token = authorization |
|
|
|
this.fetchUserInfo() |
|
|
|
} else { |
|
|
|
@ -92,45 +132,62 @@ Page({ |
|
|
|
} |
|
|
|
return false |
|
|
|
}, |
|
|
|
fetchUserInfo:function(){ |
|
|
|
config.header = { 'Authorization': 'QNT ' + app.globalData.token } |
|
|
|
fetchUserInfo: function () { |
|
|
|
config.header = { |
|
|
|
'Authorization': 'QNT ' + app.globalData.token |
|
|
|
} |
|
|
|
getUserInfo().then(result => { |
|
|
|
this.toIndex() |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
}) |
|
|
|
}, |
|
|
|
defaultIndex: function(){ |
|
|
|
defaultIndex: function () { |
|
|
|
this.onResume() |
|
|
|
if(this.data.path){ |
|
|
|
wx.navigateTo({ url: this.data.path }) |
|
|
|
if (this.data.path) { |
|
|
|
wx.navigateTo({ |
|
|
|
url: this.data.path |
|
|
|
}) |
|
|
|
} |
|
|
|
getPopupInfo().then(result => { |
|
|
|
if(result.data){ |
|
|
|
this.setData({ landInfo: result.data }) |
|
|
|
if (result.data) { |
|
|
|
this.setData({ |
|
|
|
landInfo: result.data |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
toIndex: function(){ |
|
|
|
if(!app.globalData.token){ |
|
|
|
toIndex: function () { |
|
|
|
if (!app.globalData.token) { |
|
|
|
wx.hideLoading() |
|
|
|
this.defaultIndex() |
|
|
|
return |
|
|
|
} |
|
|
|
loginToken({loginToken: app.globalData.token}).then(result => { |
|
|
|
zconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
|
pconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
|
mconfig.header = { 'Authorization': 'QNT ' + result.data.token } |
|
|
|
loginToken({ |
|
|
|
loginToken: app.globalData.token |
|
|
|
}).then(result => { |
|
|
|
zconfig.header = { |
|
|
|
'Authorization': 'QNT ' + result.data.token |
|
|
|
} |
|
|
|
pconfig.header = { |
|
|
|
'Authorization': 'QNT ' + result.data.token |
|
|
|
} |
|
|
|
mconfig.header = { |
|
|
|
'Authorization': 'QNT ' + result.data.token |
|
|
|
} |
|
|
|
this.setData({ |
|
|
|
isTokenHaveStatus: true |
|
|
|
}) |
|
|
|
getBaseInfo().then(result => { |
|
|
|
this.setData({ |
|
|
|
hasShowedLoginTag:result.data.hasShowedLoginTag |
|
|
|
hasShowedLoginTag: result.data.hasShowedLoginTag |
|
|
|
}) |
|
|
|
app.globalData.userInfo = result.data |
|
|
|
app.globalData.userInfo = result.data |
|
|
|
// 登录流程完成;
|
|
|
|
if(!util.isEmpty(result.data.userToken)){ |
|
|
|
if (!util.isEmpty(result.data.userToken)) { |
|
|
|
this.handleUserToken(result.data.userToken) |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
wx.hideLoading() |
|
|
|
this.defaultIndex() |
|
|
|
}).catch(err => { |
|
|
|
@ -142,14 +199,18 @@ Page({ |
|
|
|
this.defaultIndex() |
|
|
|
}) |
|
|
|
}, |
|
|
|
handleUserToken: function(userToken){ |
|
|
|
sconfig.header = {'user-token': userToken } |
|
|
|
handleUserToken: function (userToken) { |
|
|
|
sconfig.header = { |
|
|
|
'user-token': userToken |
|
|
|
} |
|
|
|
getOrderExists().then(result => { |
|
|
|
wx.hideLoading() |
|
|
|
if (Number(result.data) != 1 || !app.release) { |
|
|
|
if (Number(result.data) != 1 || !app.evn) { |
|
|
|
wx.navigateBack() |
|
|
|
} else { |
|
|
|
wx.reLaunch({ url: '/pages/paper/index' }) |
|
|
|
wx.reLaunch({ |
|
|
|
url: '/pages/paper/index' |
|
|
|
}) |
|
|
|
} |
|
|
|
}).catch(err => { |
|
|
|
wx.hideLoading() |
|
|
|
@ -157,68 +218,86 @@ Page({ |
|
|
|
this.defaultIndex() |
|
|
|
}) |
|
|
|
}, |
|
|
|
onResume: function(){ |
|
|
|
onResume: function () { |
|
|
|
var pageView = this.selectComponent('#' + this.data.TabList[this.data.pageIndex].value) |
|
|
|
if (pageView && this.data.inited) { |
|
|
|
pageView.onRestart() |
|
|
|
} |
|
|
|
}, |
|
|
|
//事件处理函数
|
|
|
|
onNavChange: function(e) { |
|
|
|
onNavChange: function (e) { |
|
|
|
// 处理用户的登录校验
|
|
|
|
this.setData({ pageIndex: Number(e.currentTarget.dataset.tab) }) |
|
|
|
this.setData({ |
|
|
|
pageIndex: Number(e.currentTarget.dataset.tab) |
|
|
|
}) |
|
|
|
this.onResume() |
|
|
|
}, |
|
|
|
/** |
|
|
|
* 生命周期函数--监听页面显示 |
|
|
|
*/ |
|
|
|
onShow: function () { |
|
|
|
if(this.data.inited){ |
|
|
|
if (this.data.inited) { |
|
|
|
this.onResume() |
|
|
|
} |
|
|
|
// wx.navigateTo({ url: '/pages/home/tab1/index' })
|
|
|
|
getBaseInfo().then(result => { |
|
|
|
this.setData({ |
|
|
|
hasShowedLoginTag:result.data.hasShowedLoginTag |
|
|
|
if (this.data.isTokenHaveStatus) { |
|
|
|
getBaseInfo().then(result => { |
|
|
|
this.setData({ |
|
|
|
hasShowedLoginTag: result.data.hasShowedLoginTag |
|
|
|
}) |
|
|
|
if (this.data.hasShowedLoginTag == false) { |
|
|
|
this.updateUserInfoFct({ |
|
|
|
hasShowedLoginTag: true |
|
|
|
}) |
|
|
|
wx.navigateTo({ |
|
|
|
url: '/pages/home/tab1/index' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
if(this.data.hasShowedLoginTag==false){ |
|
|
|
this.updateUserInfoFct({hasShowedLoginTag:true}) |
|
|
|
wx.navigateTo({ url: '/pages/home/tab1/index' }) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
updateUserInfoFct: function (model) { |
|
|
|
updateUserInfo(model).then(result => { |
|
|
|
}) |
|
|
|
updateUserInfo(model).then(result => {}) |
|
|
|
}, |
|
|
|
onEvent: function (message) { |
|
|
|
if(message.what == 250){ |
|
|
|
this.setData({ pageIndex: 0 }) |
|
|
|
} |
|
|
|
if (message.what == 250) { |
|
|
|
this.setData({ |
|
|
|
pageIndex: 0 |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
stopTouchMove: function(e){ |
|
|
|
stopTouchMove: function (e) { |
|
|
|
return false |
|
|
|
}, |
|
|
|
// 弹出框的处理;
|
|
|
|
onClose: function(){ |
|
|
|
this.setData({ visible: false, landInfo: null }) |
|
|
|
onClose: function () { |
|
|
|
this.setData({ |
|
|
|
visible: false, |
|
|
|
landInfo: null |
|
|
|
}) |
|
|
|
}, |
|
|
|
onImageLoad: function(){ |
|
|
|
this.setData({ visible: true }) |
|
|
|
onImageLoad: function () { |
|
|
|
this.setData({ |
|
|
|
visible: true |
|
|
|
}) |
|
|
|
}, |
|
|
|
onImageClick: function(){ |
|
|
|
if(this.data.landInfo.redirectInfo.targetView == 'showH5'){ |
|
|
|
onImageClick: function () { |
|
|
|
if (this.data.landInfo.redirectInfo.targetView == 'showH5') { |
|
|
|
util.navigateTo('/pages/html/html/index?link=' + this.data.landInfo.redirectInfo.params.id + '?title=' + this.data.landInfo.title) |
|
|
|
return |
|
|
|
} |
|
|
|
util.navigateTarget(this.data.landInfo.redirectInfo) |
|
|
|
this.setData({ visible: false, landInfo: null }) |
|
|
|
this.setData({ |
|
|
|
visible: false, |
|
|
|
landInfo: null |
|
|
|
}) |
|
|
|
}, |
|
|
|
toRule: function(){ |
|
|
|
if(this.data.landInfo.ruleRedirectInfo.targetView == 'showH5'){ |
|
|
|
toRule: function () { |
|
|
|
if (this.data.landInfo.ruleRedirectInfo.targetView == 'showH5') { |
|
|
|
util.navigateTo('/pages/html/html/index?link=' + this.data.landInfo.ruleRedirectInfo.params.id + '?title=' + this.data.landInfo.title) |
|
|
|
return |
|
|
|
} |
|
|
|
util.navigateTarget(this.data.landInfo.ruleRedirectInfo) |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |