[AI Generated]: feat(*): 新增 OpenID 登录流程及启动自动跳转逻辑

This commit is contained in:
17792275749
2026-05-14 11:56:43 +08:00
parent 89d4832c7c
commit 54fc0daf5a
9 changed files with 173 additions and 39 deletions
+84 -29
View File
@@ -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'
})
},
})
+3 -2
View File
@@ -8,11 +8,12 @@
<block wx:for="{{ deviceList }}" wx:key="id">
<view class="device-card">
<!-- 上半:图标 + 设备 + 状态(色点 + 文字) -->
<!-- 上半:图标 + 设备信息 + 状态(色点 + 文字) -->
<view class="card-top">
<view class="card-icon"></view>
<view class="card-info">
<view class="card-name">{{ item.name }}</view>
<view class="card-name">{{ item.scaleDeviceId }}</view>
<view class="card-user">{{ item.realname }}</view>
<view class="card-status">
<!-- 已连接:绿点 + "已连接" -->
<block wx:if="{{ item.connected }}">