- 详细报告按 scaleType 区分 4/8 电极渲染,节段卡片 8 电极专属 - 设备列表改为接口驱动并新增空态 - 登录后统一跳首页,请求层兼容 code 0 返回风格 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { checkOpenIdLogin } from '../../api/index'
|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
Page({
|
|
data: {
|
|
loading: false,
|
|
},
|
|
|
|
onShareAppMessage(): WechatMiniprogram.Page.ICustomShareContent {
|
|
return {
|
|
title: '智能蓝牙秤',
|
|
path: '/pages/login/login',
|
|
imageUrl: '/images/share/share.jpg',
|
|
}
|
|
},
|
|
|
|
/* 微信一键登录 */
|
|
onLogin() {
|
|
if (this.data.loading) return
|
|
this.setData({ loading: true })
|
|
|
|
// 获取微信临时 code → 调用 OpenID 登录接口
|
|
app.getWxLoginCode().then((code) => checkOpenIdLogin(code)).then((res) => {
|
|
const { token, user } = res.result
|
|
// 持久化登录凭证和用户信息
|
|
wx.setStorageSync('token', token)
|
|
// if (user) {
|
|
// wx.setStorageSync('userInfo', user)
|
|
wx.reLaunch({ url: '/pages/home/home' })
|
|
// } else {
|
|
// wx.reLaunch({ url: '/pages/supplementPersonal/supplementPersonal' })
|
|
// }
|
|
}).catch((err) => {
|
|
wx.showToast({ title: err.msg || '登录失败,请重试', icon: 'none' })
|
|
}).finally(() => {
|
|
this.setData({ loading: false })
|
|
})
|
|
},
|
|
})
|