import User from "../../model/user"; import Api from "../../model/api"; import Route from "../../model/route"; import {getEventParam} from "../../utils/utils"; Page({ data: { info: null, user: null, isLogin:false, }, onShow(){ const isLogin = User.isLogin(); if (isLogin) { const user = User.getUserInfoByLocal(); this.setData({ info: { student: user } }); } }, async bindLogin(e){ const isLogin = getEventParam(e,"isLogin") this.setData({ isLogin }) if (isLogin) { await User.updateUserInfo(); const user = User.getUserInfoByLocal(); this.setData({ user }) let res = await Api.getUserInfo(); this.setData({ info: res.data, }) } }, toUserInfo(e) { Route.toUserInfo(); }, toScore(e) { Route.toScore(); }, async logout(e) { const res = await wx.showModal({ title: "确认退出登录", confirmText: '确认', cancelText: '取消' }) if (res.confirm) { await User.logout(); this.setData({ isLogin: false }) } } })