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.
62 lines
1.4 KiB
62 lines
1.4 KiB
// pages/home/setting/index.js
|
|
import { $wuxDialog } from '../../../components/index'
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
kg: app.globalData.kg,
|
|
version: 2
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
var pages = getCurrentPages()
|
|
for (let index = 0; index < pages.length; index++) {
|
|
const element = pages[index]
|
|
if('pages/paper/index' == element.route){
|
|
this.data.version = 1
|
|
break
|
|
}
|
|
}
|
|
this.setData({
|
|
kg: app.globalData.kg,
|
|
version: this.data.version
|
|
})
|
|
},
|
|
checKg: function(e){
|
|
var kg = e.currentTarget.id == 'kg' ? 1 : 0
|
|
app.globalData.kg = kg
|
|
wx.setStorageSync('ztb-kg', kg)
|
|
event.emit('EventMessage', { what: 1001, desc: 'KGchange' })
|
|
this.setData({ kg })
|
|
},
|
|
|
|
loginOut: function () {
|
|
$wuxDialog().open({
|
|
resetOnClose: true,
|
|
title: '温馨提示',
|
|
content: '确定退出当前账号?',
|
|
buttons: [{
|
|
text: '取消'
|
|
}, {
|
|
text: '确定',
|
|
type: 'primary',
|
|
onTap(e) {
|
|
wx.removeStorageSync('accessToken')
|
|
wx.removeStorageSync('Authorization')
|
|
app.globalData.token = null
|
|
app.globalData.userInfo = null
|
|
event.emit('EventMessage', { what: 888, desc: 'Logout' })
|
|
wx.navigateBack()
|
|
}
|
|
}]
|
|
})
|
|
}
|
|
})
|