htc 1 день тому
батько
коміт
3a3530951f
2 змінених файлів з 103 додано та 74 видалено
  1. 4 4
      common/stores/user.js
  2. 99 70
      pages/my.vue

+ 4 - 4
common/stores/user.js

@@ -5,15 +5,14 @@ export const useUserStore = defineStore('user', {
 	state: () => ({
 		isRegister: true,     // 是否注册成功
 		isLogin: false,        // 用户是否已登录
-		showLoginModal: false, // 是否显示登录弹框
+		showLoginModal: false, // 是否显示登录弹框
+		token:'',
 		userInfo: null,        // 用户信息
 	}),
-	
 	getters: {
 		// 方便在模板中直接使用
 		isLoggedIn: (state) => state.isLogin,
 	},
-
 	actions: {
 		// 打开登录弹框
 		openLoginModal() {
@@ -44,7 +43,7 @@ export const useUserStore = defineStore('user', {
 			});
 		},
 
-		async login(loginDto) {
+		async login(loginDto) {
 			await new Promise(resolve => {
 				api.get('/wx/login',loginDto).then(({data:res})=>{
 					if(res.code !== 0){
@@ -55,6 +54,7 @@ export const useUserStore = defineStore('user', {
 					
 					this.showLoginModal = false;
 					this.isLogin = true;
+					this.token = res.data?.token;
 					this.userInfo = res.data;
 					uni.setStorageSync('token',this.userInfo?.token)
 					uni.setStorageSync('userInfo',JSON.stringify(this.userInfo))

+ 99 - 70
pages/my.vue

@@ -4,101 +4,101 @@
 			<template #left></template>
 		</up-navbar>
 		<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/9043fbbe-2e5d-4adb-ba36-039d33a9b694.png" class="top_bg_img" mode="widthFix"></image>
-		<div class="info">
-			<div class="info-top adfacjb">
-				<div class="info-top-left adfac">
-					<image class="avatar" :src="userInfo?userInfo.avatar:'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/6db27a79-235b-4595-87f2-89ff09fc66a5.png'"></image>
-					<div class="text">
-						<div class="text-top">{{userInfo?userInfo.name:'未登录'}}</div>
-						<div class="text-bottom" v-if="userInfo"></div>
-						<div class="text-bottom" v-else @tap="showLogin">去登录注册&nbsp;>></div>
-					</div>
-				</div>
-				<div class="info-top-right" @tap="handleTurnPage('/pagesMy/information')">
+		<view class="info">
+			<view class="info-top adfacjb">
+				<view class="info-top-left adfac">
+					<image class="avatar" :src="userInfo?.avatarPath||'https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/6db27a79-235b-4595-87f2-89ff09fc66a5.png'"></image>
+					<view class="text" @click="showLogin">
+						<view class="text-top">{{userInfo?userInfo?.realName:'未登录'}}</view>
+						<view class="text-bottom lv" v-if="userInfo">Lv&nbsp;&nbsp;&nbsp;{{userInfo?.userLevel||1}}&nbsp;&nbsp;></view>
+						<view class="text-bottom" v-else>去登录注册&nbsp;>></view>
+					</view>
+				</view>
+				<view class="info-top-right" @click="handleTurnPage('/pagesMy/information')">
 					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/d0319d8d-1445-47d6-94fa-cb934e022ab8.png"></image>
-				</div>
-			</div>
-			<div class="info-tip">
-				<div class="info-tip-pre adfacjb">
-					<div class="left">家庭公益名称:{{userInfo?userInfo.xxx:'暂无'}}</div>
-					<div class="right">
+				</view>
+			</view>
+			<view class="info-tip">
+				<view class="info-tip-pre adfacjb">
+					<view class="left">家庭公益名称:{{userInfo?userInfo.welfareName:'暂无'}}</view>
+					<view class="right">
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
-					</div>
-				</div>
-				<div class="info-tip-pre adfacjb">
-					<div class="left">家庭公益口号:{{userInfo?userInfo.xxx:'暂无'}}</div>
-					<div class="right">
+					</view>
+				</view>
+				<view class="info-tip-pre adfacjb">
+					<view class="left">家庭公益口号:{{userInfo?userInfo.welfareSlogan:'暂无'}}</view>
+					<view class="right">
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
-					</div>
-				</div>
-			</div>
-		</div>
-		<div class="box" style="margin-top: 40rpx;">
-			<div class="box-title">公益记录</div>
-			<div class="box-card adfacjb">
-				<div class="box-card-pre adffcac red" @tap="handleTurnPage('/pagesMy/heartNumber')">
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="box" style="margin-top: 40rpx;">
+			<view class="box-title">公益记录</view>
+			<view class="box-card adfacjb">
+				<view class="box-card-pre adffcac red" @click="handleTurnPage('/pagesMy/heartNumber')">
 					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/4e6e3db8-127f-433d-9644-66f1451a6d72.png"></image>
-					<div class="num">{{(heartNum||0).toFixed(2)}}</div>
-					<div class="text adf">
+					<view class="num">{{(heartNum||0).toFixed(2)}}</view>
+					<view class="text adf">
 						<text>我的爱心值</text>
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/35df3e58-7b8c-4d3c-8f09-41f252cb3805.png"></image>
-					</div>
-				</div>
-				<div class="box-card-pre adffcac purple" @tap="handleTurnPage('/pagesMy/archives')">
+					</view>
+				</view>
+				<view class="box-card-pre adffcac purple" @click="handleTurnPage('/pagesMy/archives')">
 					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/dc26c6af-2617-47b7-ab38-9ccbf2016c5c.png"></image>
-					<div class="num">{{(fileNum||0).toFixed(2)}}</div>
-					<div class="text adf">
+					<view class="num">{{(fileNum||0).toFixed(2)}}</view>
+					<view class="text adf">
 						<text>我的档案</text>
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/51adb43e-acdd-475e-9e3d-64cbeedd4fe4.png"></image>
-					</div>
-				</div>
-				<div class="box-card-pre adffcac orange" @tap="handleTurnPage('/pagesMy/volunteerHours')">
+					</view>
+				</view>
+				<view class="box-card-pre adffcac orange" @click="handleTurnPage('/pagesMy/volunteerHours')">
 					<image class="top" src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/c5048d96-826e-4bbf-a133-dd2115162746.png"></image>
-					<div class="num">{{(hourNum||0).toFixed(2)}}</div>
-					<div class="text adf">
+					<view class="num">{{(hourNum||0).toFixed(2)}}</view>
+					<view class="text adf">
 						<text>义工时长(h)</text>
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/9bdc2845-e4bc-4215-82d0-9582066b710f.png"></image>
-					</div>
-				</div>
-			</div>
-		</div>
-		<div class="box" @tap="handleTurnPage('/pagesMy/achievement')">
-			<div class="box-title">我的成就</div>
-			<div class="box-achievement adfacjb">
-				<div class="box-achievement-left">收获<span>{{achievement}}</span>项成就</div>
-				<div class="box-achievement-right adfacjb">
-					<div class="imgs"></div>
-					<div class="jt">
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="box" @click="handleTurnPage('/pagesMy/achievement')">
+			<view class="box-title">我的成就</view>
+			<view class="box-achievement adfacjb">
+				<view class="box-achievement-left">收获<span>{{achievement}}</span>项成就</view>
+				<view class="box-achievement-right adfacjb">
+					<view class="imgs"></view>
+					<view class="jt">
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/17/79079542-4711-44e8-9246-9cd1b8ea4e39.png"></image>
-					</div>
-				</div>
-			</div>
-		</div>
-		<div class="box">
-			<div class="box-title">其他功能</div>
-			<div class="box-other adfacjb">
-				<div class="box-other-pre adffcac" @tap="handleTurnPage('/pagesMy/practice')">
+					</view>
+				</view>
+			</view>
+		</view>
+		<view class="box">
+			<view class="box-title">其他功能</view>
+			<view class="box-other adfacjb">
+				<view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/practice')">
 					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/53fb5a7a-e7fb-4e5d-b902-f434cfc6d786.png"></image>
 					<text>申领社会实践记录</text>
-				</div>
-				<div class="box-other-pre adffcac" @tap="handleTurnPage('/pagesMy/familyMember')">
+				</view>
+				<view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/familyMember')">
 					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/06acc5f2-45e8-43ea-96a3-c17e79a190bc.png"></image>
 					<text>家庭成员</text>
-				</div>
-				<div class="box-other-pre adffcac" @tap="handleTurnPage('/pagesMy/exclusiveScroll')">
+				</view>
+				<view class="box-other-pre adffcac" @click="handleTurnPage('/pagesMy/exclusiveScroll')">
 					<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/18/7746f429-615d-4e1b-8564-c943f07882be.png"></image>
 					<text>我的专享卷</text>
-				</div>
-			</div>
-		</div>
+				</view>
+			</view>
+		</view>
 		<CusTabbar :tabbarIndex="2"></CusTabbar>
-		<login-register></login-register>
+		<login-register @loginSucc="loginSucc"></login-register>
 	</view>
 </template>
 
 <script setup name="">
 	import CusTabbar from '@/components/CusTabbar/index.vue'
-	import { ref, getCurrentInstance } from 'vue'
+	import { ref, onMounted, watch, getCurrentInstance } from 'vue'
 	const { proxy } = getCurrentInstance();
 	import { useUserStore } from '@/common/stores/user';
 	const userStore = useUserStore();
@@ -112,6 +112,7 @@
 	const achievement = ref(0)
 	
 	const showLogin = () => {
+		if(userInfo.value) return
 		userStore.openLoginModal();
 	}
 	
@@ -119,6 +120,20 @@
 		if(!isLogin()) return
 		uni.navigateTo({ url })
 	}
+	
+	const getUserInfo = () => {
+		if(uni.getStorageSync('userInfo')){
+			userInfo.value = JSON.parse(uni.getStorageSync('userInfo'));
+		}
+	}
+	
+	watch(()=>userStore.token,newVal=>{
+		getUserInfo()
+	})
+	
+	onMounted(()=>{
+		getUserInfo()
+	})
 </script>
 
 <style scoped lang="scss">
@@ -149,6 +164,20 @@
 							color: #151B29;
 							line-height: 26rpx;
 							margin-top: 26rpx;
+							&.lv{
+								width: 137rpx;
+								height: 42rpx;
+								background: url('https://transcend.ringzle.com/xiaozhi-app/profile/2025/11/17/0d460a9f-e13b-4469-b08d-dcc73e417ce9.png') no-repeat;
+								background-size: 100% 100%;
+								font-family: PingFangSC, PingFang SC;
+								font-weight: 600;
+								font-size: 26rpx;
+								color: #FFFFFF;
+								line-height: 38rpx;
+								padding-left: 16rpx;
+								box-sizing: border-box;
+								margin-top: 18rpx;
+							}
 						}
 					}
 				}