纸通宝SAAS仓库
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.
 

75 lines
2.2 KiB

// pages/home/setting/index.js
import Scene from '../../index/scene'
import Dialog from '../../../components/dialog/dialog'
import util from '../../../utils/util'
import { finalizeToken } from "../../../api/user"
const event = require('../../../utils/event')
const storage = require('../../../utils/storage')
const app = getApp()
Scene({
/**
* 页面的初始数据
*/
data: {
userInfo: null,
avatarUrl: '/assets/image/ygImg.png',
version: app.version,
agenting: true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
var agenting = storage.get('saas-agenting' + app.userInfo.userId)
if(!util.isEmpty(agenting)){
app.globalData.agenting = agenting
}
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,
version: app.version,
agenting: app.globalData.agenting ? true : false
})
},
authrise: function(){
if(!app.userInfo.isAuth){
wx.navigateTo({ url: '/pages/setting/authory/index' })
}
},
settingAgent: function(){
var agenting = this.data.agenting ? 0 : 1
app.globalData.agenting = agenting
storage.put('saas-agenting' + app.userInfo.userId, agenting)
this.setData({ agenting: agenting ? true : false })
},
makeCall: function() {
wx.makePhoneCall({ phoneNumber: '020-82516486' })
},
loginOut: function () {
Dialog.confirm({ title: '温馨提示', message: '确定退出纸通宝账号?' }).then(() => {
storage.remove('Authorization')
app.globalData.token = null
app.userInfo = null
finalizeToken()
wx.reLaunch({ url: '/pages/login/index' })
event.emit('EventMessage', { what: 888, desc: 'Logout' })
}).catch(error => {
})
}
})