ソースを参照

个人资料回显

htc 1 日 前
コミット
10a35348e3
2 ファイル変更54 行追加48 行削除
  1. 2 2
      pages/my.vue
  2. 52 46
      pagesMy/information.vue

+ 2 - 2
pages/my.vue

@@ -19,13 +19,13 @@
 				</view>
 			</view>
 			<view class="info-tip">
-				<view class="info-tip-pre adfacjb">
+				<view class="info-tip-pre adfacjb" @click="handleTurnPage('/pagesMy/information')">
 					<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>
 					</view>
 				</view>
-				<view class="info-tip-pre adfacjb">
+				<view class="info-tip-pre adfacjb" @click="handleTurnPage('/pagesMy/information')">
 					<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>

+ 52 - 46
pagesMy/information.vue

@@ -1,10 +1,10 @@
 <template>
 	<view class="common_page" :style="{'height':h+'px', 'padding-top':mt+'px'}">
 		<cus-header title="个人资料" bgColor="#FFFFFF"></cus-header>
-		<div class="form">
-			<div class="avatar">
-				<div class="title">头像</div>
-				<div class="imgbox">
+		<view class="form" v-if="userInfo">
+			<view class="avatar">
+				<view class="title">头像</view>
+				<view class="imgbox">
 					<up-upload
 						:fileList="fileList"
 						@afterRead="afterRead"
@@ -17,58 +17,52 @@
 						<image src="https://transcend.ringzle.com/xiaozhi-app/profile/2025/09/29/b04d6b0e-0d30-4043-a2b1-d639e15e2aac.png" 
 						mode="widthFix" style="width: 122rpx;height: 122rpx;"></image>
 					</up-upload>
-				</div>
-			</div>
-			<div class="item adfacjb">
-				<div class="left">用户名</div>
-				<div class="right">
-					<up-input v-model="userInfo.username" border="none" placeholder="请输入用户名"></up-input>
-				</div>
-			</div>
-			<div class="item adfacjb">
-				<div class="left">手机号码</div>
-				<div class="right">
+				</view>
+			</view>
+			<view class="item adfacjb">
+				<view class="left">用户名</view>
+				<view class="right">
+					<up-input v-model="userInfo.realName" border="none" placeholder="请输入用户名"></up-input>
+				</view>
+			</view>
+			<!-- <view class="item adfacjb">
+				<view class="left">手机号码</view>
+				<view class="right">
 					<up-input v-model="userInfo.phone" border="none" placeholder="请输入手机号码"></up-input>
-				</div>
-			</div>
-			<div class="item adfacjb">
-				<div class="left">家庭公益名称</div>
-				<div class="right">
-					<up-input v-model="userInfo.nonprofitName" border="none" placeholder="请输入家庭公益名称"></up-input>
-				</div>
-			</div>
-			<div class="item adfacjb">
-				<div class="left">家庭公益口号</div>
-				<div class="right">
-					<up-input v-model="userInfo.nonprofitNo" border="none" placeholder="请输入家庭公益口号"></up-input>
-				</div>
-			</div>
-		</div>
-		<div class="btn" @tap="save">保存</div>
+				</view>
+			</view> -->
+			<view class="item adfacjb">
+				<view class="left">家庭公益名称</view>
+				<view class="right">
+					<up-input v-model="userInfo.welfareName" border="none" placeholder="请输入家庭公益名称"></up-input>
+				</view>
+			</view>
+			<view class="item adfacjb">
+				<view class="left">家庭公益口号</view>
+				<view class="right">
+					<up-input v-model="userInfo.welfareSlogan" border="none" placeholder="请输入家庭公益口号"></up-input>
+				</view>
+			</view>
+		</view>
+		<view class="btn" @click="save">保存</view>
 	</view>
 </template>
 
 <script setup name="">
+	import { BaseApi } from '../common/api/baseApi';
 	import CusHeader from '@/components/CusHeader/index.vue'
 	import { ref, onMounted, getCurrentInstance } from 'vue'
 	const { proxy } = getCurrentInstance()
 	
 	const fileList = ref([])
-	const userInfo = ref({
-		avatar:'',
-		username:'',
-		phone:'',
-		nonprofitName:'',
-		nonprofitNo:''
-	})
+	const userInfo = ref(null)
 	
 	const save = () => {
-		if(!userInfo.value.avatar) return proxy.$showToast('请上传用户头像')
-		if(!userInfo.value.username) return proxy.$showToast('请输入用户名')
-		if(!proxy.$reg.mobile(userInfo.value.phone)) return proxy.$showToast('请输入正确的手机号')
-		if(!userInfo.value.nonprofitName) return proxy.$showToast('请输入家庭公益名称')
-		if(!userInfo.value.nonprofitNo) return proxy.$showToast('请输入家庭公益口号')
-		console.log(userInfo.value,'userInfo');
+		if(!userInfo.value?.avatarPath) return proxy.$showToast('请上传用户头像')
+		if(!userInfo.value?.realName) return proxy.$showToast('请输入用户名')
+		// if(!proxy.$reg.mobile(userInfo.value.phone)) return proxy.$showToast('请输入正确的手机号')
+		if(!userInfo.value?.welfareName) return proxy.$showToast('请输入家庭公益名称')
+		if(!userInfo.value?.welfareSlogan) return proxy.$showToast('请输入家庭公益口号')
 	}
 	
 	const deletePic = (event) => {
@@ -103,7 +97,7 @@
 	const uploadFilePromise = (url) => {
 	  return new Promise((resolve, reject) => {
 	    let a = uni.uploadFile({
-	      url: 'http://192.168.2.21:7001/upload', // 仅为示例,非真实的接口地址
+	      url: BaseApi+'/uploadFile', // 仅为示例,非真实的接口地址
 	      filePath: url,
 	      name: 'file',
 	      formData: {
@@ -118,8 +112,20 @@
 	  });
 	};
 	
+	const getUserInfo = () => {
+		try{
+			proxy.$api.get(`/wx/${JSON.parse(uni.getStorageSync('userInfo')).id}`).then(({data:res})=>{
+				if(res.code!==0) return this.$showToast(res.msg)
+				userInfo.value = res.data;
+				if(userInfo.value?.avatarPath) fileList.value = [{name:'',url:userInfo.value?.avatarPath}];
+			})
+		}catch(e){
+			userInfo.value = null
+		}
+	}
+	
 	onMounted(()=>{
-		
+		getUserInfo()
 	})
 </script>