[AI Generated]: feat(*): 新增 OpenID 登录流程及启动自动跳转逻辑
This commit is contained in:
@@ -1,38 +1,93 @@
|
||||
/** 已配对设备模型 */
|
||||
import { get } from '../../utils/request/index'
|
||||
|
||||
/** API 返回的设备记录 */
|
||||
interface DeviceRecord {
|
||||
id: string
|
||||
userId: string
|
||||
parentUserId: string | null
|
||||
scaleDeviceId: string
|
||||
deviceId: string | null
|
||||
deviceType: string
|
||||
dataType: number
|
||||
userType: number
|
||||
idCard: string
|
||||
height: number
|
||||
weight: number
|
||||
birthday: string
|
||||
sex: number
|
||||
avatar: string | null
|
||||
phone: string | null
|
||||
thirdId: string
|
||||
realname: string
|
||||
bmi: number
|
||||
createBy: string
|
||||
createTime: string
|
||||
updateBy: string
|
||||
updateTime: string
|
||||
delFlag: number
|
||||
sn: string | null
|
||||
workNo: string
|
||||
remark: string | null
|
||||
relationType: string | null
|
||||
sex_dictText: string
|
||||
}
|
||||
|
||||
/** 展示用设备项 */
|
||||
interface DeviceItem {
|
||||
/** 设备唯一 id */
|
||||
id: string
|
||||
/** 设备名称 */
|
||||
name: string
|
||||
/** 是否已连接 */
|
||||
connected: boolean
|
||||
id: string
|
||||
scaleDeviceId: string
|
||||
realname: string
|
||||
/** 蓝牙连接状态,接口不返回,由业务层更新 */
|
||||
connected: boolean
|
||||
}
|
||||
|
||||
Page({
|
||||
data: {
|
||||
/* 已配对设备 mock 列表(后续接入真实接口时替换) */
|
||||
deviceList: [
|
||||
{ id: 'd1', name: '智能体重秤 Pro', connected: true },
|
||||
{ id: 'd2', name: '体重秤 Basic', connected: false },
|
||||
] as DeviceItem[],
|
||||
},
|
||||
data: {
|
||||
loading: false,
|
||||
deviceList: [] as DeviceItem[],
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
/* 页面进入时无副作用,设备列表后续接入真实接口 */
|
||||
},
|
||||
onLoad() {
|
||||
this.loadData()
|
||||
},
|
||||
|
||||
/* 点击「连接」:未连接卡片才会出现 —— 暂留空,待跳转逻辑接入 */
|
||||
onTapConnect() {
|
||||
// TODO: 跳转设备搜索/绑定流程
|
||||
},
|
||||
/** 拉取已绑定设备列表 */
|
||||
loadData() {
|
||||
this.setData({ loading: true })
|
||||
get<DeviceRecord[]>('weighingScale/v3/list/device')
|
||||
.then(res => {
|
||||
const list: DeviceItem[] = res.result.map(item => ({
|
||||
id: item.id,
|
||||
scaleDeviceId: item.scaleDeviceId,
|
||||
realname: item.realname,
|
||||
connected: false,
|
||||
}))
|
||||
this.setData({ deviceList: list })
|
||||
})
|
||||
.finally(() => {
|
||||
this.setData({ loading: false })
|
||||
})
|
||||
},
|
||||
|
||||
/* 点击「成员管理」:暂留空,待成员管理页接入 */
|
||||
onTapMember() {
|
||||
// TODO: 跳转成员管理页
|
||||
},
|
||||
/* 点击「连接」→ 跳转设备搜索页 */
|
||||
onTapConnect() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/connectedDevice/connectedDevice'
|
||||
})
|
||||
},
|
||||
|
||||
/* 点击「添加设备」:暂留空,待跳转逻辑接入 */
|
||||
onTapAdd() {
|
||||
// TODO: 跳转设备搜索页
|
||||
},
|
||||
/* 点击「成员管理」→ 跳转成员管理页 */
|
||||
onTapMember(e: WechatMiniprogram.TouchEvent) {
|
||||
const id = e.currentTarget.dataset.id as string
|
||||
wx.navigateTo({
|
||||
url: `/pages/equipmentMember/equipmentMember?id=${id}`
|
||||
})
|
||||
},
|
||||
|
||||
/* 点击「添加设备」→ 跳转设备搜索页 */
|
||||
onTapAdd() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/connectedDevice/connectedDevice'
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user