Kaynağa Gözat

用户管理还原

liyuliangjiazai 6 ay önce
ebeveyn
işleme
2962b4c33c
1 değiştirilmiş dosya ile 15 ekleme ve 35 silme
  1. 15 35
      code/ajyApp/pages/device/userManage/userManage.nvue

+ 15 - 35
code/ajyApp/pages/device/userManage/userManage.nvue

@@ -29,9 +29,9 @@
 									<text class="userAge" v-if="item.age">{{item.age}}岁</text>
 								</view>
 								<view class="bodyRow">
-									<text class="bodyTxt">身长:{{item.bodyHeight || item.shoulderHeight || '--'}}cm</text>
+									<text class="bodyTxt">肩高:{{item.shoulderHeight || '--'}}cm</text>
 									<text class="bodyTxt">肩宽:{{item.shoulderWidth || '--'}}cm</text>
-									<text class="bodyTxt">脊柱:{{item.spineLength || '--'}}cm</text>
+									<text class="bodyTxt">体重:{{item.weight || '--'}}kg</text>
 								</view>
 							</view>
 						</view>
@@ -72,7 +72,6 @@
 <script>
 import customPopup from '@/components/customPopup/customPopup.nvue'
 import ayToast from '@/components/ay-toast/ay-toast.nvue'
-import { getGroupMembers } from '@/utils/api/device'
 
 export default {
 	components: {
@@ -99,45 +98,21 @@ export default {
 		goBack() {
 			uni.navigateBack()
 		},
-		/** 从后端加载当前设备用户列表 */
-		async loadUsers() {
-			const currentDevice = uni.getStorageSync('current_device') || {}
-			let list = []
-			if (currentDevice.groupId) {
-				try {
-					const data = await getGroupMembers(currentDevice.groupId)
-					list = (data || []).map(this.normalizeMember)
-					uni.setStorageSync('user_manage_list', list)
-				} catch (e) {
-					console.error('加载群组成员失败,使用本地缓存', e)
-					list = uni.getStorageSync('user_manage_list') || []
-				}
-			} else {
-				const currentUser = uni.getStorageSync('current_manage_user') || currentDevice.profile
-				list = currentUser ? [this.normalizeMember(currentUser)] : []
-				uni.setStorageSync('user_manage_list', list)
-			}
+		/** 从本地存储加载用户列表 */
+		loadUsers() {
+			const list = uni.getStorageSync('user_manage_list') || []
 			this.userList = list
-			this.currentUserId = String(uni.getStorageSync('current_manage_user_id') || '')
+			this.currentUserId = uni.getStorageSync('current_manage_user_id') || ''
 			// 如果没有当前用户且列表不为空,默认选中第一个
 			if (!this.currentUserId && list.length > 0) {
-				this.currentUserId = String(list[0].id)
+				this.currentUserId = list[0].id
 				uni.setStorageSync('current_manage_user_id', this.currentUserId)
-				uni.setStorageSync('current_manage_user', list[0])
-			}
-		},
-		normalizeMember(item) {
-			return {
-				...item,
-				id: String(item.profileId || item.id),
-				bodyHeight: item.bodyHeight || item.shoulderHeight || '',
-				profileComplete: !!item.profileComplete
 			}
 		},
 		/** 切换用户 */
 		switchUser(item) {
-			this.currentUserId = String(item.id)
-			uni.setStorageSync('current_manage_user_id', this.currentUserId)
+			this.currentUserId = item.id
+			uni.setStorageSync('current_manage_user_id', item.id)
 			uni.setStorageSync('current_manage_user', item)
 			this.$refs.ayToast.success('已切换至用户:' + item.name)
 			setTimeout(() => {
@@ -162,7 +137,12 @@ export default {
 		},
 		/** 确认删除 */
 		confirmDelete(item) {
-			this.$refs.ayToast.error('暂不支持在App端删除群组成员')
+			if (this.userList.length <= 1) {
+				this.$refs.ayToast.error('至少保留一个用户')
+				return
+			}
+			this.deleteTarget = item
+			this.showDeletePopup = true
 		},
 		/** 录入指纹 */
 		enrollFingerprint(item) {