// 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: { agenting: true }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var agenting = storage.get('saas-agenting' + app.userInfo.userId) if(!util.isEmpty(agenting)){ app.globalData.agenting = agenting } this.setData({ agenting: app.globalData.agenting ? true : false }) }, 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 }) }, loginOut: function () { Dialog.confirm({ title: '温馨提示', message: '确定退出纸通宝账号?' }).then(() => { storage.remove('Authorization') app.globalData.token = null app.userInfo = null finalizeToken() wx.redirectTo({ url: '/pages/login/index' }) event.emit('EventMessage', { what: 888, desc: 'Logout' }) }).catch(error => { }) } })