Browse Source

feat(mine/personal_message): 通讯录个人信息数据渲染

wangpx 1 year ago
parent
commit
cf1299b1f8
4 changed files with 28 additions and 36 deletions
  1. 0 12
      api/contacts.js
  2. 13 0
      api/mine.js
  3. 2 2
      pages/contacts/index.vue
  4. 13 22
      pages/mine/personal_message/personal_message.vue

+ 0 - 12
api/contacts.js

@@ -15,15 +15,3 @@ export function getContactAllUser(unitId) {
 		}
 	})
 }
-
-export function getUserInfo(useId) {
-	return request({
-    method: 'post',
-		data: {
-			'serviceId': 'eu_2013V01loadMe',
-			'params': {
-				"staffId": useId
-			}
-		}
-	})
-}

+ 13 - 0
api/mine.js

@@ -0,0 +1,13 @@
+import request from '@/utils/request.js'
+
+export function getUserInfo(useId) {
+	return request({
+    method: 'post',
+		data: {
+			'serviceId': 'eu_2013V01loadMe',
+			'params': {
+				"staffId": useId
+			}
+		}
+	})
+}

+ 2 - 2
pages/contacts/index.vue

@@ -62,7 +62,7 @@
 		for(let key in data) {
 			// hasOwnProperty 排除 __proto__等数据
 			if (data.hasOwnProperty(key)) {
-				// 过滤 userState 为 0 的 User
+				// 过滤 userState 为 0 的 user
 				data[key] = data[key].filter(user => user.userState !== '0')
 			} else {
 				continue
@@ -80,7 +80,7 @@
 	}
 	// 点击通讯录列表
 	function clickChat(e) {
-		$tab.navigateTo('/pages/mine/personal_message/personal_message?id=' + e.useId + '&name=' + e.name)
+		$tab.navigateTo('/pages/mine/personal_message/personal_message?useId=' + e.useId)
 	}
 </script>
 

+ 13 - 22
pages/mine/personal_message/personal_message.vue

@@ -52,15 +52,23 @@
 	import { ref } from 'vue';
 	import headImg from "@/static/images/mine/headImg.jpg";
 	import { onLoad } from '@dcloudio/uni-app'
+	import { getUserInfo } from '@/api/mine.js'
 	import { useUserStore } from '@/store/user.js'
 	const userStore = useUserStore()
-	const userInfo = userStore.user
+	const userInfo = ref({})
 	// 监听页面加载
 	onLoad((options) => {
-		// 获取传入的标题参数
-		const name = userInfo.name;
-		const useId = userInfo.useId;
-		console.log('useId', useId);
+		console.log('options.useId', options.useId);
+		console.log('options', !options.useId);
+		if (!options.useId) {
+			// 获取传入的标题参数
+			userInfo.value = userStore.user
+		} else {
+			getUserInfo(options.useId).then((res) => {
+				userInfo.value = res.returnParams[0]
+			})
+		}
+		const name = userInfo.value.name;
 		if (name) {
 			// 设置导航栏标题
 			uni.setNavigationBarTitle({
@@ -68,23 +76,6 @@
 			});
 		}
 	})
-	// 定义个人信息数据
-	// const userInfo = ref({
-	// 	name: "张三",
-	// 	department: [{
-	// 			departmentName: "研发部",
-	// 			position: '软件开发工程师'
-	// 		},
-	// 		{
-	// 			departmentName: "业务部",
-	// 			position: '销售经理'
-	// 		},
-	// 	],
-	// 	phone: "13579543684",
-	// 	email: "",
-	// 	gender: "男",
-	// 	birthday: "2000-01-10"
-	// });
 </script>
 
 <style lang="scss" scoped>