const { sessionStore } = require('../../stores') const { formatDateTime } = require('../../utils/util') Page({ data: { submitting: false, form: { nickname: '', mobile: '' }, mockHint: `请求层已接好,可把接口替换为真实后端。当前时间:${formatDateTime(new Date())}` }, handleNicknameChange(event) { this.setData({ 'form.nickname': event.detail.value }) }, handleMobileChange(event) { this.setData({ 'form.mobile': event.detail.value }) }, handleMockLogin() { const { nickname, mobile } = this.data.form if (!nickname.trim()) { wx.showToast({ title: '请输入昵称', icon: 'none' }) return } this.setData({ submitting: true }) sessionStore.setSession({ token: `mock_${Date.now()}`, userInfo: { nickname: nickname.trim(), mobile: mobile.trim() }, permissions: ['workbench:view', 'profile:update'] }) wx.showToast({ title: '模拟登录成功', icon: 'success' }) this.setData({ submitting: false }) setTimeout(() => { wx.reLaunch({ url: '/pages/home/index' }) }, 300) }, handleClearSession() { sessionStore.clearSession() this.setData({ form: { nickname: '', mobile: '' } }) wx.showToast({ title: '已清理', icon: 'success' }) } })