12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // pages/user/user.js
- import { navigateTo, getStorageSync, clearStorageSync, showModal } from '../../utils/util'
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- userInfo: null,
- hasUserInfo: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- },
- onShow: function () {
- const userInfo = getStorageSync('USERINFO')
- if (userInfo) {
- this.setData({
- userInfo,
- hasUserInfo: true
- })
- } else {
- this.setData({
- userInfo: null,
- hasUserInfo: false
- })
- }
- },
- onAboutTap: function () {
- navigateTo('/pages/about/about')
- },
- login: function () {
- navigateTo('/pages/login/login')
- },
- logout: function() {
- showModal({
- content: '确定退出登录',
- showCancel: true,
- cancelText: '取消',
- cancelColor: '#000000',
- confirmText: '确定',
- confirmColor: '#3CC51F',
- success: (result) => {
- if(result.confirm){
- clearStorageSync('USERINFO')
- this.setData({
- userInfo: null,
- hasUserInfo: false
- })
- }
- }
- })
- }
- })
|