|
@@ -8,17 +8,17 @@
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
|
<view class="profile-container">
|
|
<view class="profile-container">
|
|
|
- {{ JSON.stringify(userStore.userInfo) }}
|
|
|
|
|
|
|
+ {{ JSON.stringify(userInfo) }}
|
|
|
<!-- 用户信息区域 -->
|
|
<!-- 用户信息区域 -->
|
|
|
<view class="user-info-section">
|
|
<view class="user-info-section">
|
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
<!-- #ifdef MP-WEIXIN -->
|
|
|
<button class="avatar-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
|
<button class="avatar-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
|
|
|
- <wd-img :src="userStore.userInfo.avatar" width="80px" height="80px" radius="50%"></wd-img>
|
|
|
|
|
|
|
+ <wd-img :src="userInfo.avatar" width="80px" height="80px" radius="50%"></wd-img>
|
|
|
</button>
|
|
</button>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
<!-- #ifndef MP-WEIXIN -->
|
|
<!-- #ifndef MP-WEIXIN -->
|
|
|
<view class="avatar-wrapper" @click="run">
|
|
<view class="avatar-wrapper" @click="run">
|
|
|
- <wd-img :src="userStore.userInfo.avatar" width="100%" height="100%" radius="50%"></wd-img>
|
|
|
|
|
|
|
+ <wd-img :src="userInfo.avatar" width="100%" height="100%" radius="50%"></wd-img>
|
|
|
</view>
|
|
</view>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
<view class="user-details">
|
|
<view class="user-details">
|
|
@@ -27,13 +27,13 @@
|
|
|
type="nickname"
|
|
type="nickname"
|
|
|
class="weui-input"
|
|
class="weui-input"
|
|
|
placeholder="请输入昵称"
|
|
placeholder="请输入昵称"
|
|
|
- v-model="userStore.userInfo.username"
|
|
|
|
|
|
|
+ v-model="userInfo.username"
|
|
|
/>
|
|
/>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
<!-- #ifndef MP-WEIXIN -->
|
|
<!-- #ifndef MP-WEIXIN -->
|
|
|
- <view class="username">{{ userStore.userInfo.username }}</view>
|
|
|
|
|
|
|
+ <view class="username">{{ userInfo.username }}</view>
|
|
|
<!-- #endif -->
|
|
<!-- #endif -->
|
|
|
- <view class="user-id">ID: {{ userStore.userInfo.id }}</view>
|
|
|
|
|
|
|
+ <view class="user-id">ID: {{ userInfo.id }}</view>
|
|
|
</view>
|
|
</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
|
|
@@ -93,7 +93,8 @@ import { storeToRefs } from 'pinia'
|
|
|
import { IUploadSuccessInfo } from '@/api/login.typings'
|
|
import { IUploadSuccessInfo } from '@/api/login.typings'
|
|
|
|
|
|
|
|
const userStore = useUserStore()
|
|
const userStore = useUserStore()
|
|
|
-
|
|
|
|
|
|
|
+// 使用storeToRefs解构userInfo
|
|
|
|
|
+const { userInfo } = storeToRefs(userStore)
|
|
|
const toast = useToast()
|
|
const toast = useToast()
|
|
|
const hasLogin = ref(false)
|
|
const hasLogin = ref(false)
|
|
|
|
|
|
|
@@ -142,7 +143,7 @@ const onChooseAvatar = (e: any) => {
|
|
|
{
|
|
{
|
|
|
onSuccess: (res) => {
|
|
onSuccess: (res) => {
|
|
|
console.log('头像上传成功', res)
|
|
console.log('头像上传成功', res)
|
|
|
- // 更新用户信息
|
|
|
|
|
|
|
+ useUserStore().setUserAvatar(res)
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
avatarUrl,
|
|
avatarUrl,
|