You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
2.9 KiB
93 lines
2.9 KiB
// pages/stock/index.js
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { finalizeToken } from "../../../api/user"
|
|
const util = require('../../../utils/util')
|
|
const event = require('../../../utils/event')
|
|
const storage = require('../../../utils/storage')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
height: app.globalData.safeFragmentHeight,
|
|
firstShow: false,
|
|
isAdmin: false,
|
|
userInfo: null,
|
|
avatarUrl: '/assets/image/ygImg.png',
|
|
creditInfo: { availableCreditLine: 0, creditLine: 0, usedCreditLine: 0.00 }
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
attached: function () {
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
detached: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
},
|
|
methods: {
|
|
// resume的处理;
|
|
onRestart: function () {
|
|
if(!this.data.firstShow) {
|
|
this.setData({CustomBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 80), height: app.globalData.safeFragmentHeight - 100})
|
|
}
|
|
this.setUserInfo()
|
|
this.data.firstShow = true
|
|
},
|
|
onEvent: function (message) {
|
|
if (message.what == 82) {
|
|
// 认证成功
|
|
this.setUserInfo()
|
|
}
|
|
},
|
|
setUserInfo: function(){
|
|
if(!app.userInfo){
|
|
return
|
|
}
|
|
var nickname = ''
|
|
if(app.userInfo.isAuth) {
|
|
nickname = app.userInfo.realName.substring(0, 14)
|
|
} else if(!util.isEmpty(app.userInfo.nickname)){
|
|
nickname = app.userInfo.nickname.substring(0, 14)
|
|
} else if(!util.isEmpty(app.userInfo.realName)){
|
|
nickname = app.userInfo.realName.substring(0, 14)
|
|
}
|
|
this.setData({
|
|
avatarUrl: util.isEmpty(app.userInfo.avatarUrl) ? '/assets/image/ygImg.png' : app.userInfo.avatarUrl,
|
|
userInfo: app.userInfo,
|
|
userName: nickname,
|
|
isAdmin: app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0,
|
|
})
|
|
},
|
|
toUserInfo: function(){
|
|
if(!app.userInfo){
|
|
return
|
|
}
|
|
wx.navigateTo({ url: '/pages/home/user-info/index' })
|
|
},
|
|
agentList: function(){
|
|
wx.navigateTo({ url: '/pages/process/agent-list/index' })
|
|
},
|
|
tipApply: function(){
|
|
wx.navigateTo({ url: '/pages/htmls/auths/index' })
|
|
},
|
|
loginOut: function () {
|
|
Dialog.confirm({ title: '温馨提示', message: '确定退出纸通宝账号?' }).then(() => {
|
|
storage.remove('Authorization')
|
|
app.globalData.token = null
|
|
app.userInfo = null
|
|
this.setData({ userInfo: null, avatarUrl: '/assets/image/ygImg.png' })
|
|
finalizeToken()
|
|
wx.redirectTo({ url: '/pages/login/index' })
|
|
event.emit('EventMessage', { what: 888, desc: 'Logout' })
|
|
}).catch(error => {
|
|
})
|
|
}
|
|
}
|
|
})
|