liyuliangjiazai 3 месяцев назад
Родитель
Сommit
4f453c5d35

+ 66 - 2
code/ajyApp/pages/device/detail/detail.nvue

@@ -23,9 +23,17 @@
 				<text class="gray">{{name}}</text>
 			</view>
 			<view class="menuitem">
-				<text>设备ID</text>
+				<text>设备编号</text>
 				<text class="gray device-id-text">{{deviceId}}</text>
 			</view>
+			<view class="menuitem">
+				<text>设备型号</text>
+				<text class="gray">{{deviceModel || '未知'}}</text>
+			</view>
+			<view class="menuitem">
+				<text>序列号</text>
+				<text class="gray">{{serialNo || '未知'}}</text>
+			</view>
 			<view class="menuitem">
 				<text>信号强度</text>
 				<view class="signal-value-wrap">
@@ -42,10 +50,20 @@
 				<text>固件版本</text>
 				<text class="gray">{{firmwareVersion || '未获取'}}</text>
 			</view>
-			<view class="menuitem lastItem">
+			<view class="menuitem">
 				<text>连接状态</text>
 				<text class="gray">{{connected ? '已连接' : '未连接'}}</text>
 			</view>
+			<view class="menuitem">
+				<text>在线状态</text>
+				<text class="gray">{{onlineStatus === 1 ? '在线' : '离线'}}</text>
+			</view>
+			<view class="menuitem lastItem menuitem-address">
+				<text>设备地址</text>
+				<view class="address-wrap">
+					<text class="gray address-text">{{address || '未设置'}}</text>
+				</view>
+			</view>
 
 			<text class="txt">设备操作</text>
 			<view class="menuitem" @click="disconnectDevice" v-if="connected">
@@ -68,6 +86,7 @@
 <script>
 import { useBleStore } from '@/stores/ble'
 import { BLE_STATE } from '@/utils/ble/constants.js'
+import { getDeviceDetail } from '@/utils/api/device.js'
 import ayToast from '@/components/ay-toast/ay-toast.nvue'
 
 export default {
@@ -79,7 +98,13 @@ export default {
 			statusBarHeight: 44,
 			name: '',
 			deviceId: '',
+			deviceCode: '',
+			deviceModel: '',
+			serialNo: '',
+			onlineStatus: 0,
+			address: '',
 			rssi: '',
+			id:'',
 			connected: false,
 			connecting: false,
 			firmwareVersion: '',
@@ -113,6 +138,11 @@ export default {
 		this.name = decodeURIComponent(options.name || '')
 		this.deviceId = decodeURIComponent(options.deviceId || '')
 		this.rssi = decodeURIComponent(options.rssi || '')
+		this.id = decodeURIComponent(options.id || '')
+		// 获取设备详情
+		if (this.id) {
+			this.fetchDeviceDetail()
+		}
 	},
 	async onShow() {
 		const bleStore = useBleStore()
@@ -158,6 +188,21 @@ export default {
 		this._cleanListeners()
 	},
 	methods: {
+		async fetchDeviceDetail() {
+			try {
+				const res = await getDeviceDetail(this.id)
+				if (res) {
+					this.name = res.deviceName || this.name
+					this.deviceModel = res.deviceModel || ''
+					this.serialNo = res.serialNo || ''
+					this.firmwareVersion = res.firmwareVersion || this.firmwareVersion
+					this.onlineStatus = res.onlineStatus || 0
+					this.address = res.address || ''
+				}
+			} catch (e) {
+				console.log('获取设备详情失败', e)
+			}
+		},
 		goBack() {
 			uni.navigateBack()
 		},
@@ -395,6 +440,25 @@ export default {
 	height: 40rpx;
 }
 
+.menuitem-address {
+	height: auto;
+	min-height: 104rpx;
+	padding-top: 24rpx;
+	padding-bottom: 24rpx;
+}
+
+.address-wrap {
+	flex: 1;
+	margin-left: 20rpx;
+}
+
+.address-text {
+	font-size: 28rpx;
+	color: #9BA5B7;
+	text-align: right;
+	lines: 0;
+}
+
 .delbtn {
 	width: 654rpx;
 	height: 96rpx;

+ 3 - 1
code/ajyApp/pages/device/deviceInfo/deviceInfo.nvue

@@ -12,7 +12,7 @@
 					<view class="userSwitchBtn" @click="goUserManage">
 						<text class="userSwitchTxt">{{currentUserName || '选择用户'}}</text>
 					</view>
-					<navigator :url="'/pages/device/detail/detail?name='+deviceName+'&deviceId='+deviceId+'&rssi='+rssi"
+					<navigator :url="'/pages/device/detail/detail?name='+deviceName+'&deviceId='+deviceId+'&rssi='+rssi+'&id='+id"
 						class="plus">
 						<image v-if="picMode===1" src="/static/public/view-list.png" mode="aspectFill" class="menuimg"></image>
 					</navigator>
@@ -337,6 +337,7 @@ export default {
 			statusBarHeight: 44,
 			deviceId: '',
 			deviceName: '',
+			id:'',
 			rssi: '',
 			isShowDrawer2: false,
 			modelist: ['无艾灸模式', '专业模式', '自定义模式', '延年圣手模式'],
@@ -369,6 +370,7 @@ export default {
 		this.deviceId = decodeURIComponent(options.deviceId || '')
 		this.deviceName = decodeURIComponent(options.name || '')
 		this.rssi = decodeURIComponent(options.rssi || '')
+		this.id= decodeURIComponent(options.id || '')
 
 		// TODO: 后续接口确定后实现 - 下载穴位列表
 		// TODO: 后续接口确定后实现 - 下载专业模式推荐方案

+ 1 - 1
code/ajyApp/pages/device/list/list.nvue

@@ -80,7 +80,7 @@ export default {
 		},
 		goDeviceInfo(item) {
 			uni.navigateTo({
-				url: '/pages/device/deviceInfo/deviceInfo?name=' + encodeURIComponent(item.deviceName || item.name || '') + '&deviceId=' + encodeURIComponent(item.deviceId || '') + '&deviceCode=' + encodeURIComponent(item.deviceCode || '') + '&rssi=' + encodeURIComponent(item.RSSI || '')
+				url: '/pages/device/deviceInfo/deviceInfo?name=' + encodeURIComponent(item.deviceName || item.name || '') + '&deviceId=' + encodeURIComponent(item.deviceId || '') + '&deviceCode=' + encodeURIComponent(item.deviceCode || '') + '&rssi=' + encodeURIComponent(item.RSSI || '')+'&id=' + encodeURIComponent(item.id || '')
 			})
 		},
 		/** 如果设备已连接,实时获取RSSI并更新缓存 */

+ 3 - 1
code/ajyApp/pages/device/search/search.nvue

@@ -155,6 +155,7 @@ export default {
 			console.log("要操作的设备",device)
 			let deviceList = []
 			try {
+				// uni.removeStorageSync('deviceList')
 				const data = uni.getStorageSync('deviceList')
 				console.log("deviceList",data)
 				if (data && data.length > 0) {
@@ -177,7 +178,8 @@ export default {
 				deviceList.push({
 					deviceId: device.deviceId,
 					name: device.name || '艾灸椅',
-					RSSI: device.RSSI
+					RSSI: device.RSSI,
+					id:res.id
 				})
 				uni.setStorageSync('deviceList', deviceList)
 				this.$refs.ayToast.success('设备添加成功')

+ 9 - 0
code/ajyApp/utils/api/device.js

@@ -21,3 +21,12 @@ export function bindDeviceByCode(deviceCode) {
 	console.log("请求参数",deviceCode)
 	return http.post('/app/user/device/bind-by-code', {deviceCode },{showError:true})
 }
+
+/**
+ * 获取设备详情
+ * @param {string|number} id - 设备ID
+ * @returns {Promise<{id, deviceCode, deviceName, deviceModel, deviceType, serialNo, firmwareVersion, onlineStatus, lastOnlineTime, provinceCode, cityCode, districtCode, address, remark, createTime, updateTime}>}
+ */
+export function getDeviceDetail(id) {
+	return http.get(`/app/device/${id}`, {showError: true})
+}