refactor: 项目重构,仅保留 login 和 supplementPersonal 页面

删除 11 个旧页面、组件、lefu SDK、旧资源文件。
新增 request 封装(GET/POST/PUT)、api 层、utils/common 身份证工具。
重写 login(登录流程提取到 app.ts) 和 supplementPersonal(简化表单逻辑)。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-10 14:21:00 +08:00
co-authored by Claude Sonnet 4.6
parent 439f560218
commit 83d909b95b
96 changed files with 370 additions and 9040 deletions
@@ -1,4 +0,0 @@
{
"navigationBarTitleText": "WiFi连接",
"usingComponents": {}
}
@@ -1,389 +0,0 @@
.connectedWifi {
width: 100%;
height: 100%;
display: flex;
flex-flow: column;
padding: 30rpx 30rpx 0;
box-sizing: border-box;
background-color: #FFFFFF;
}
.setWifi {
width: 100%;
height: 100%;
padding: 30rpx 10rpx 0;
box-sizing: border-box;
}
.setWifi-title {
color: #252535;
width: 100%;
height: 48rpx;
font-size: 48rpx;
font-weight: bold;
line-height: 48rpx;
margin-bottom: 48rpx;
}
.setWifi-form {
width: 100%;
margin-bottom: 64rpx;
}
.setWifi-form>view {
width: 100%;
height: 96rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 0 24rpx;
box-sizing: border-box;
border-radius: 16rpx;
background-color: #F6F6F6;
}
.setWifi-form>view:first-of-type {
margin-bottom: 32rpx;
}
.setWifi-form>view>view:nth-of-type(1) {
color: #252535;
width: 100rpx;
height: 96rpx;
line-height: 96rpx;
font-size: 32rpx;
font-weight: bold;
}
.setWifi-form>view:first-of-type>view:nth-of-type(1) {
padding: 24rpx 45rpx 24rpx 7rpx;
box-sizing: border-box;
display: flex;
align-items: center;
}
.setWifi-form>view>view:nth-of-type(2) {
color: #252535;
flex: 1;
width: 0;
height: 96rpx;
font-size: 32rpx;
line-height: 96rpx;
}
.setWifi-form>view>view:nth-of-type(2) input {
color: #252535;
width: 100%;
height: 96rpx;
font-size: 32rpx;
line-height: 96rpx;
}
.placeholderClass {
color: #B6B6B6;
height: 96rpx;
font-size: 32rpx;
line-height: 96rpx;
}
.setWifi-form>view>view:nth-of-type(3) {
width: 56rpx;
height: 56rpx;
}
.setWifi-btn {
width: 100%;
height: 88rpx;
padding: 0 15rpx;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
box-sizing: border-box;
}
.setWifi-btn>view {
color: #FFFFFF;
width: 300rpx;
height: 88rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
border-radius: 44rpx;
line-height: 84rpx;
box-sizing: border-box;
background-color: #1385FA;
border: 2rpx solid #1385FA;
&:first-of-type {
color: #1385FA;
background-color: #FFFFFF;
}
}
/* 顶部已连接设备卡 */
.deviceCard {
width: 100%;
height: 150rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 30rpx;
box-sizing: border-box;
border: 2rpx solid #E6E6EA;
border-radius: 16rpx;
background-color: #FFFFFF;
margin-bottom: 46rpx;
/* 设备图标占位 */
>view:nth-of-type(1) {
width: 90rpx;
height: 90rpx;
overflow: hidden;
margin-right: 24rpx;
border-radius: 24rpx;
flex-shrink: 0;
}
/* 右侧信息 */
>view:nth-of-type(2) {
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
/* 设备名 */
>view:nth-of-type(1) {
color: #252535;
height: 32rpx;
font-size: 32rpx;
font-weight: bold;
line-height: 32rpx;
margin-bottom: 16rpx;
}
/* 状态行 */
>view:nth-of-type(2) {
display: flex;
flex-wrap: nowrap;
align-items: center;
}
}
}
.status-dot {
width: 12rpx;
height: 12rpx;
border-radius: 50%;
margin-right: 14rpx;
flex-shrink: 0;
&--green { background-color: #2AC79F; }
&--red { background-color: #F24439; }
&--gray { background-color: #999999; }
}
.status-text {
height: 28rpx;
font-size: 28rpx;
font-weight: 500;
line-height: 28rpx;
&--green { color: #2AC79F; }
&--red { color: #F24439; }
&--gray { color: #999999; }
}
/* idle / searching 两态:居中文案 */
.wifiIdle,
.wifiSearching {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
color: #B6B6B6;
font-size: 32rpx;
line-height: 32rpx;
}
/* 附近WiFi 标题区:title 行 + 副标题 */
.wifiHeader {
width: 100%;
padding: 0 12rpx;
box-sizing: border-box;
/* 标题行:附近WiFi + 可选「刷新」 */
>view:nth-of-type(1) {
width: 100%;
display: flex;
flex-wrap: nowrap;
justify-content: space-between;
align-items: center;
margin-bottom: 24rpx;
>view:nth-of-type(1) {
color: #252535;
height: 36rpx;
font-size: 36rpx;
font-weight: bold;
line-height: 36rpx;
}
>view:nth-of-type(2) {
color: #1385FA;
height: 36rpx;
font-size: 28rpx;
font-weight: 500;
line-height: 36rpx;
}
}
/* 副标题 */
>view:nth-of-type(2) {
color: #B6B6B6;
height: 30rpx;
font-size: 28rpx;
line-height: 30rpx;
margin-bottom: 32rpx;
}
}
/* WiFi 列表:scroll-view Y 轴滚动,撑满剩余高度 */
.wifiList {
width: 100%;
flex: 1;
min-height: 0;
padding: 0 12rpx;
box-sizing: border-box;
}
.arrow {
&::after {
right: 4rpx;
}
}
/* 列表项:普通态 */
.wifiItem {
width: 100%;
height: 80rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
margin-bottom: 32rpx;
/* 左侧 wifi 图标容器 */
>view:nth-of-type(1) {
width: 80rpx;
height: 80rpx;
margin-right: 24rpx;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
image {
width: 100%;
height: 100%;
}
}
/* WiFi 名称 */
>text {
flex: 1;
color: #252535;
height: 32rpx;
font-size: 32rpx;
font-weight: 500;
line-height: 32rpx;
}
/* 右箭头 */
>view:nth-of-type(2) {
width: 20rpx;
height: 18rpx;
}
}
/* 列表项:已连接态 */
.wifiItem-connected {
>text {
color: #1385FA;
}
/* 右侧「已连接」+ 勾 */
>view:nth-of-type(2) {
width: auto;
height: auto;
display: flex;
flex-wrap: nowrap;
align-items: center;
background-color: transparent;
>text {
color: #2AC79F;
font-size: 24rpx;
font-weight: 500;
line-height: 24rpx;
margin-right: 5rpx;
}
/* 右箭头 */
>view {
width: 20rpx;
height: 18rpx;
}
}
}
/* 列表态底部「确认」按钮:贴底 */
.wifiBtn {
width: 100%;
height: 120rpx;
display: flex;
align-items: center;
justify-content: center;
>view {
color: #FFFFFF;
width: 580rpx;
height: 88rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
line-height: 88rpx;
border-radius: 44rpx;
background-color: #1385FA;
}
.wifiBtn-disabled {
background-color: #A8C9F0;
}
}
/* 空态 */
.wifiEmpty {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
align-items: center;
padding: 39rpx 42rpx 0;
box-sizing: border-box;
>view {
width: 566rpx;
height: 499rpx;
margin-bottom: 40rpx;
border-radius: 16rpx;
background-color: #F5F8FF;
}
>text {
color: #1385FA;
font-size: 36rpx;
font-weight: bold;
line-height: 36rpx;
margin-top: 8rpx;
}
}
@@ -1,134 +0,0 @@
import { lefuService } from '../../lefu/index'
import type { LeFuWifiItem } from '../../lefu/index'
interface WifiItem {
ssid: string
connected: boolean
}
type WifiStatus = 'idle' | 'searching' | 'list' | 'empty' | 'password' | 'configuring'
type BleStatus = 'connected' | 'failed' | 'connecting'
Page({
data: {
status: 'idle' as WifiStatus,
deviceName: '智能体重秤',
bleStatus: 'connecting' as BleStatus,
wifiList: [] as WifiItem[],
hasConnected: false,
selectedSsid: '',
selectWifiPWD: '',
type: true,
},
_toBleStatus(state: string): BleStatus {
const bs = lefuService.BLUE_STATE
if (state === bs.CONNECTSUCCESS || state === bs.WIFISUCCESS) return 'connected'
if (state === bs.CONNECTFAILED || state === bs.UNAVAILABLE) return 'failed'
return 'connecting'
},
onLoad() {
// 尽早注册 deviceInfo 回调,防止 onShow 前已触发而错过
lefuService.onDeviceInfo((info) => {
this.setData({ deviceName: info.modelNumber })
})
// 设备断开即退出配网页
lefuService.onDisconnected(() => {
wx.showToast({ title: '设备已断开连接', icon: 'none', duration: 1500 })
setTimeout(() => wx.navigateBack(), 1500)
})
this.setData({
bleStatus: this._toBleStatus(lefuService.connectState),
deviceName: lefuService.deviceInfo?.modelNumber ?? '智能体重秤',
})
this.onStartSearch()
},
onShow() {
lefuService.onConnectState((state) => {
this.setData({ bleStatus: this._toBleStatus(state) })
})
},
onUnload() {
wx.hideLoading()
lefuService.onDisconnected(() => {})
if (this.data.status === 'configuring') {
lefuService.disconnect()
}
},
onStartSearch() {
this.setData({ status: 'searching', wifiList: [] })
wx.showLoading({ title: '正在获取 WiFi 列表...', mask: true })
lefuService.getWifiList()
.then((items: LeFuWifiItem[]) => {
wx.hideLoading()
if (!items.length) {
this.setData({ status: 'empty' })
return
}
this.setData({
status: 'list',
wifiList: items.map(item => ({ ssid: item.ssid, connected: false })),
})
})
.catch(() => {
wx.hideLoading()
this.setData({ status: 'empty' })
})
},
onRefresh() {
this.onStartSearch()
},
onTapWifi(e: WechatMiniprogram.TouchEvent) {
const ssid = e.currentTarget.dataset.ssid as string
const target = this.data.wifiList.find(item => item.ssid === ssid)
if (!target || target.connected) return
this.setData({ status: 'password', selectedSsid: ssid, selectWifiPWD: '', type: true })
},
passwordInput(e: WechatMiniprogram.Input) {
this.setData({ selectWifiPWD: e.detail.value })
},
inputTypeChange() {
this.setData({ type: !this.data.type })
},
onCancelPwd() {
this.setData({ status: 'list', selectedSsid: '', selectWifiPWD: '' })
},
onConfirmPwd() {
const { selectedSsid, selectWifiPWD } = this.data
if (!selectedSsid) return
this.setData({ status: 'configuring' })
wx.showLoading({ title: '正在配网...', mask: true })
lefuService.configWifi(selectedSsid, selectWifiPWD)
.then(() => {
wx.hideLoading()
this.setData({
status: 'list',
wifiList: this.data.wifiList.map(item => ({ ...item, connected: item.ssid === selectedSsid })),
hasConnected: true,
selectedSsid: '',
selectWifiPWD: '',
})
})
.catch((err: Error) => {
wx.hideLoading()
wx.showToast({ title: err.message || '配网失败,请重试', icon: 'none' })
this.setData({ status: 'password' })
})
},
onConfirm() {
if (!this.data.hasConnected) return
wx.navigateTo({ url: '/pages/supplementPersonal/supplementPersonal' })
},
})
@@ -1,134 +0,0 @@
<view class="connectedWifi">
<block wx:if="{{status === 'password'}}">
<view class="setWifi">
<view class="setWifi-title">输入Wi-Fi密码</view>
<view class="setWifi-form">
<view>
<view>
<image src="/images/connectedWifi/wifiPwd.png"/>
</view>
<view>{{selectedSsid}}</view>
</view>
<view>
<view>密码</view>
<view>
<block wx:if="{{type}}">
<input
password="{{true}}"
value="{{selectWifiPWD}}"
bind:input="passwordInput"
placeholder="输入您的wi-fi密码"
placeholder-class="placeholderClass"/>
</block>
<block wx:else>
<input
password="{{false}}"
value="{{selectWifiPWD}}"
bind:input="passwordInput"
placeholder="输入您的wi-fi密码"
placeholder-class="placeholderClass"/>
</block>
</view>
<view bind:tap="inputTypeChange">
<image src="/images/connectedWifi/{{type ? 'open' : 'close'}}.png"/>
</view>
</view>
</view>
<view class="setWifi-btn">
<view bind:tap="onCancelPwd">取消</view>
<view bind:tap="onConfirmPwd">连接</view>
</view>
</view>
</block>
<block wx:else>
<!-- 顶部已连接设备卡 -->
<view class="deviceCard">
<view class="card-icon">
<image src="/images/device/{{deviceName}}.png" mode="aspectFit" style="width:100%;height:100%;"></image>
</view>
<view>
<view>{{deviceName}}</view>
<view>
<block wx:if="{{bleStatus === 'connected'}}">
<view class="status-dot status-dot--green"></view>
<text class="status-text status-text--green">已连接</text>
</block>
<block wx:elif="{{bleStatus === 'failed'}}">
<view class="status-dot status-dot--red"></view>
<text class="status-text status-text--red">连接断开</text>
</block>
<block wx:else>
<view class="status-dot status-dot--gray"></view>
<text class="status-text status-text--gray">连接中...</text>
</block>
</view>
</view>
</view>
<block wx:if="{{status === 'idle'}}">
<view class="wifiIdle">
查找周边WiFi
</view>
</block>
<block wx:if="{{status === 'searching'}}">
<view class="wifiSearching">
搜索中...
</view>
</block>
<block wx:if="{{status === 'list'}}">
<view class="wifiHeader">
<view>
<view>附近WiFi</view>
</view>
<view>网络列表(请选择一个网络进行连接)</view>
</view>
<scroll-view class="wifiList" scroll-y>
<block wx:for="{{wifiList}}" wx:key="ssid">
<block wx:if="{{item.connected}}">
<view class="wifiItem wifiItem-connected" data-ssid="{{item.ssid}}" bind:tap="onTapWifi">
<view>
<image src="/images/connectedWifi/wifi.png" mode="aspectFit"/>
</view>
<text>{{item.ssid}}</text>
<view>
<text>已连接</text>
<view class="arrow"></view>
</view>
</view>
</block>
<block wx:else>
<view class="wifiItem" data-ssid="{{item.ssid}}" bind:tap="onTapWifi">
<view>
<image src="/images/connectedWifi/wifi.png" mode="aspectFit"/>
</view>
<text>{{item.ssid}}</text>
<view class="arrow"></view>
</view>
</block>
</block>
</scroll-view>
<view class="wifiBtn">
<view class="{{hasConnected ? '' : 'wifiBtn-disabled'}}" bind:tap="onConfirm">确认</view>
</view>
</block>
<block wx:if="{{status === 'empty'}}">
<view class="wifiHeader">
<view>
<view>附近WiFi</view>
<view bind:tap="onRefresh">刷新</view>
</view>
<view>网络列表(请选择一个网络进行连接)</view>
</view>
<view class="wifiEmpty">
<view>
<image src="/images/connectedWifi/noData.png" mode="aspectFit"/>
</view>
<text>未查找到可用wifi,请重试</text>
</view>
</block>
</block>
</view>