From ae00f214aaeb74d8f3c8e9c6fb0a8c793816f892 Mon Sep 17 00:00:00 2001
From: web <candymxq888@outlook.com>
Date: 星期五, 11 七月 2025 16:37:25 +0800
Subject: [PATCH] fix:修改默认头像

---
 pages/user/index.vue |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/pages/user/index.vue b/pages/user/index.vue
index 3bdda58..1e866c9 100644
--- a/pages/user/index.vue
+++ b/pages/user/index.vue
@@ -3,10 +3,10 @@
 		<view class="content">
 			<view class="user" @click="setUser">
 				<view class="userImg">
-					<image :src="userInfo?.headImg" mode="widthFix"></image>
+					<image :src="userInfo?.headImg ? userInfo.headImg : defaultImg" mode="widthFix"></image>
 				</view>
 				<view class="info">
-					<text class="name">{{userInfo?.nickName}}</text>
+					<text class="name">{{userInfo?.nickName ? userInfo.nickName : '用户'}}</text>
 				</view>
 			</view>
 			<view class="typeList">
@@ -32,6 +32,8 @@
 
 <script setup>
 	import { onMounted, ref } from "vue";
+	import { onShow } from "@dcloudio/uni-app"
+	import defaultImg from '../../static/images/default-head.png'
 	
 	const topHeight = ref(0)
 	const userInfo = ref()
@@ -66,9 +68,12 @@
 		})
 	}
 	
+	onShow(() => {
+		userInfo.value = JSON.parse(uni.getStorageSync('userInfo'))
+	})
+	
 	onMounted(() => {
 		getTopHeight()
-		userInfo.value = JSON.parse(uni.getStorageSync('userInfo'))
 	})
 </script>
 
@@ -84,6 +89,7 @@
 				height: 80rpx;
 				image{
 					width: 100%;
+					height: 100%;
 					border-radius: 50%;
 				}
 			}

--
Gitblit v1.9.3