[AI Generated]: chore(*): 统一页面后缀为TS+LESS并清理searchDevice页

This commit is contained in:
17792275749
2026-05-12 09:47:40 +08:00
parent 3b4a5e1b0d
commit 441baf66ad
12 changed files with 89 additions and 27 deletions
+1 -2
View File
@@ -1,9 +1,8 @@
{
"pages": [
"pages/connectedWifi/connectedWifi",
"pages/login/login",
"pages/searchDevice/searchDevice",
"pages/connectedDevice/connectedDevice",
"pages/connectedWifi/connectedWifi",
"pages/supplementPersonal/supplementPersonal",
"pages/home/home",
"pages/equipment/equipment",
@@ -1,3 +1,18 @@
/** 设备项模型 */
interface DeviceItem {
/** 设备唯一 id */
id: string
/** 设备名称 */
name: string
/** 设备图标 */
icon: string
/** 是否已连接 */
connected: boolean
}
/** 页面状态 */
type DeviceStatus = 'idle' | 'searching' | 'found' | 'empty'
// 是否 mock 能搜索到设备,false 则走空状态
const MOCK_HAS_DEVICES = true
@@ -5,6 +20,9 @@ const MOCK_HAS_DEVICES = true
const MOCK_SEARCH_DURATION = 2000
Page({
/* 搜索定时器引用,onUnload 时清理 */
_searchTimer: null as number | null,
data: {
/**
*
@@ -13,10 +31,10 @@ Page({
* - found: 搜索完成且有设备
* - empty: 搜索完成但无设备
*/
status: 'idle',
status: 'idle' as DeviceStatus,
/* 设备列表(包含已连接和未连接,每项含 connected: boolean) */
deviceList: [],
deviceList: [] as DeviceItem[],
},
onLoad() {
@@ -56,7 +74,7 @@ Page({
},
/* 连接某台设备:同时只能一台已连接,自动断开其他设备 */
onConnect(e) {
onConnect(e: WechatMiniprogram.TouchEvent) {
const { id } = e.currentTarget.dataset
const deviceList = this.data.deviceList.map(item => ({
...item,
@@ -1,3 +1,32 @@
/** WiFi 项模型 */
interface WifiItem {
/** WiFi 唯一 id */
id: string
/** WiFi 名称(SSID) */
name: string
/** 是否已通过本页配网成功 */
connected: boolean
}
/** 当前已连接设备(顶部卡片) */
interface CurrentDevice {
/** 设备唯一 id */
id: string
/** 设备名称 */
name: string
}
/** 密码态选中的 WiFi */
interface SelectedWifi {
/** WiFi id,空字符串表示未选中 */
id: string
/** WiFi 名称 */
name: string
}
/** 页面状态 */
type WifiStatus = 'idle' | 'searching' | 'list' | 'empty' | 'password'
// 是否 mock 能搜索到 WiFi,false 则走空状态
const MOCK_HAS_WIFI = true
@@ -5,6 +34,9 @@ const MOCK_HAS_WIFI = true
const MOCK_SEARCH_DURATION = 600
Page({
/* 搜索定时器引用,onUnload 时清理 */
_searchTimer: null as number | null,
data: {
/**
*
@@ -14,16 +46,16 @@ Page({
* - empty: 搜索完成但无 WiFi
* - password: 从列表选中某项后进入密码输入态
*/
status: 'idle',
status: 'idle' as WifiStatus,
/* 当前已连接的设备(从上一页带过来的固定卡片信息) */
currentDevice: {
id: 'mock-device',
name: '智能体重秤 Pro',
},
} as CurrentDevice,
/* WiFi 列表(connected: true 表示已通过本页配网成功的网络) */
wifiList: [],
wifiList: [] as WifiItem[],
/* 是否已有任一 WiFi 配网成功,决定底部「确认」按钮是否可点击 */
hasConnected: false,
@@ -32,7 +64,7 @@ Page({
selectedWifi: {
id: '',
name: '',
},
} as SelectedWifi,
/* 密码输入框值 */
selectWifiPWD: '',
@@ -82,8 +114,8 @@ Page({
},
/* 点击某个 WiFi 项 → 进密码态 */
onTapWifi(e) {
const id = e.currentTarget.dataset.id
onTapWifi(e: WechatMiniprogram.TouchEvent) {
const id = e.currentTarget.dataset.id as string
const target = this.data.wifiList.find(item => item.id === id)
if (!target) return
@@ -99,7 +131,7 @@ Page({
},
/* 密码输入 */
passwordInput(e) {
passwordInput(e: WechatMiniprogram.Input) {
this.setData({ selectWifiPWD: e.detail.value })
},
@@ -1,4 +0,0 @@
Page({
data: {},
onLoad() {}
})
@@ -1,3 +0,0 @@
{
"usingComponents": {}
}
@@ -1 +0,0 @@
<view class="page">searchDevice 占位</view>
@@ -1,3 +1,25 @@
/** 表单数据模型 */
interface PersonalForm {
/** 姓名 */
name: string
/** 身份证号 */
idCard: string
/** 性别(由身份证解析,只读) */
gender: string
/** 年龄(由身份证解析,只读) */
age: string
/** 身高(cm) */
height: string
}
/** 身份证解析结果 */
interface IdCardParsed {
/** 性别,空字符串表示解析失败 */
gender: string
/** 年龄,空字符串表示解析失败 */
age: string
}
/**
*
* ,
@@ -12,13 +34,13 @@ Page({
gender: '', // 性别(由身份证解析,只读)
age: '', // 年龄(由身份证解析,只读)
height: '' // 身高(cm)
}
} as PersonalForm
},
/**
*
*/
onNameInput(e) {
onNameInput(e: WechatMiniprogram.Input) {
this.setData({
'form.name': e.detail.value
});
@@ -28,7 +50,7 @@ Page({
*
* 18 ,
*/
onIdCardInput(e) {
onIdCardInput(e: WechatMiniprogram.Input) {
const idCard = (e.detail.value || '').trim().toUpperCase();
const parsed = this.parseIdCard(idCard);
@@ -42,7 +64,7 @@ Page({
/**
*
*/
onHeightInput(e) {
onHeightInput(e: WechatMiniprogram.Input) {
this.setData({
'form.height': e.detail.value
});
@@ -50,10 +72,9 @@ Page({
/**
* ,
* @param {string} idCard 18
* @returns {{ gender: string, age: string }}
* @param idCard 18
*/
parseIdCard(idCard) {
parseIdCard(idCard: string): IdCardParsed {
// 简单校验:18 位且前 17 位为数字
const reg = /^\d{17}[\dX]$/;
if (!reg.test(idCard)) {