feat(equipment): 接入运维模式开关与编辑用户 mode 字段

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
17792275749
2026-08-25 14:12:29 +08:00
co-authored by Claude Opus 4.7
parent 2e07a7fcee
commit f6d6591c69
5 changed files with 30 additions and 11 deletions
+3 -1
View File
@@ -1,5 +1,7 @@
App<IAppOption>({ App<IAppOption>({
globalData: {}, globalData: {
operationsEngineer: false
},
onLaunch() { onLaunch() {
// 已登录则跳过登录页 // 已登录则跳过登录页
+3 -2
View File
@@ -16,11 +16,11 @@ interface MemberForm {
/** 员工编号查询接口(页面私有) */ /** 员工编号查询接口(页面私有) */
const getEmployeeByWorkNo = (sn: string, workNo: string) => const getEmployeeByWorkNo = (sn: string, workNo: string) =>
get<any>('weighingScale/v5/getUserInfoByWkno', { sn, workNo }) get<any>('weighingScale/v6/getUserInfoByWkno', { sn, workNo })
/** 添加/编辑用户接口(页面私有) */ /** 添加/编辑用户接口(页面私有) */
const addUser = (data: Record<string, any>) => const addUser = (data: Record<string, any>) =>
put('weighingScale/v5/edit/user', data) put('weighingScale/v6/edit/user', data)
/** 目标设备 SN(由 userManagement 跳转传入) */ /** 目标设备 SN(由 userManagement 跳转传入) */
let targetSn = '' let targetSn = ''
@@ -306,6 +306,7 @@ Page({
birthday: this.data.birthday, birthday: this.data.birthday,
height: heightNum, height: heightNum,
weight: isNaN(weightNum) ? 0 : weightNum, weight: isNaN(weightNum) ? 0 : weightNum,
mode: getApp<IAppOption>().globalData.operationsEngineer ? 'ops' : 'normal',
} }
addUser(payload) addUser(payload)
+10 -1
View File
@@ -42,6 +42,7 @@ let scanTimer: number | null = null
Page({ Page({
data: { data: {
operationsEngineer: false,
devices: [] as DeviceItem[], devices: [] as DeviceItem[],
loadingShow: false, loadingShow: false,
loadingTitle: '正在连接设备', loadingTitle: '正在连接设备',
@@ -49,6 +50,7 @@ Page({
}, },
onShow() { onShow() {
this.setData({ operationsEngineer: getApp<IAppOption>().globalData.operationsEngineer ?? false })
this.loadDevices() this.loadDevices()
this._subscribeDisconnected() this._subscribeDisconnected()
}, },
@@ -240,9 +242,16 @@ Page({
wx.navigateTo({ url: '/pages/connectedDevice/connectedDevice' }) wx.navigateTo({ url: '/pages/connectedDevice/connectedDevice' })
}, },
/** 长按 banner 打开运维模式 */
onLongPressBanner() {
getApp<IAppOption>().globalData.operationsEngineer = true
this.setData({ operationsEngineer: true })
},
/** 关闭运维模式 */ /** 关闭运维模式 */
onCloseOps() { onCloseOps() {
// 关闭运维模式(待接入) getApp<IAppOption>().globalData.operationsEngineer = false
this.setData({ operationsEngineer: false })
}, },
/** 取消全部配对:解除所有设备绑定 */ /** 取消全部配对:解除所有设备绑定 */
+10 -6
View File
@@ -1,12 +1,14 @@
<view class="equipment"> <view class="equipment">
<!-- 运维模式提示行 --> <!-- 运维模式提示行 -->
<view class="ops-bar"> <block wx:if="{{ operationsEngineer }}">
<view class="ops-mode">当前为:运维模式</view> <view class="ops-bar">
<view class="ops-btn ops-btn--blue" bind:tap="onCloseOps">关闭运维模式</view> <view class="ops-mode">当前为:运维模式</view>
</view> <view class="ops-btn ops-btn--blue" bind:tap="onCloseOps">关闭运维模式</view>
</view>
</block>
<!-- 顶部卡片(渐变背景 + 设备图片占位) --> <!-- 顶部卡片(渐变背景 + 设备图片占位) -->
<view class="top-banner"> <view class="top-banner" bind:longpress="onLongPressBanner">
<image src="/images/equipment/bg.png"/> <image src="/images/equipment/bg.png"/>
</view> </view>
@@ -18,7 +20,9 @@
</view> </view>
<view class="section-title">已配对设备</view> <view class="section-title">已配对设备</view>
</view> </view>
<view class="ops-btn ops-btn--red" bind:tap="onUnpairAll">取消全部配对</view> <block wx:if="{{ operationsEngineer }}">
<view class="ops-btn ops-btn--red" bind:tap="onUnpairAll">取消全部配对</view>
</block>
</view> </view>
<!-- 设备列表 --> <!-- 设备列表 -->
+4 -1
View File
@@ -1,7 +1,10 @@
/// <reference path="./types/index.d.ts" /> /// <reference path="./types/index.d.ts" />
interface IAppOption { interface IAppOption {
globalData: {} globalData: {
operationsEngineer?: boolean
[key: string]: any
}
userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback userInfoReadyCallback?: WechatMiniprogram.GetUserInfoSuccessCallback
/** 获取微信登录临时 code */ /** 获取微信登录临时 code */
getWxLoginCode(): Promise<string> getWxLoginCode(): Promise<string>