Przeglądaj źródła

Merge branch 'dev' of http://39.101.143.165:8090/haiyang/couponCenter_mpapp into dev

haiyang 6 dni temu
rodzic
commit
034207a7ee

+ 48 - 0
src/api/income.ts

@@ -0,0 +1,48 @@
+import { http } from '@/http/alova'
+
+/**
+ *
+ * 发券人账户表-通过userId查询账户信息
+ */
+
+// export function getCouponIssuerApplyById() {
+//     return http.Get<CouponIssuerApplyByIdResponse>('/couponCenter/APP/couponIssuerAccount/queryByUserId')
+// }
+
+export interface CouponIssuerAccountByPageMapForm {
+    pageNo: number
+    pageSize: number
+    startTime: string
+    endTime: string
+    status: number // 0-待结算, 1-已结算/成功
+    type: number // 明细类型: 1-佣金收入, 2-提现支出, 3-退款扣减, 4-系统调整
+}
+
+// 定义账户明细项接口
+export interface AccountDetailItem {
+    id: number
+    receiveUserName: string
+    couponName: string
+    changeAmount: number
+    settleTime: string
+    [key: string]: any
+}
+
+// 定义分页响应数据接口
+export interface PageMapResponse {
+    detailList: AccountDetailItem[]
+    [key: string]: any
+}
+
+// 获取账户明细分页数据(Map格式)
+export function getCouponIssuerAccountByPageMap(couponIssuerAccountByPageMapForm: CouponIssuerAccountByPageMapForm) {
+    return http.Post<PageMapResponse>('/couponCenter/APP/couponIssuerAccountDetail/pageMap', couponIssuerAccountByPageMapForm)
+}
+
+/**
+ *
+ * 发券人账户表-通过userId查询解锁收益
+ */
+export function getUnlockAmountByUserId() {
+    return http.Get<number>('/couponCenter/APP/couponIssuerAccount/queryUnlockAmountByUserId')
+}

+ 22 - 0
src/api/me.ts

@@ -0,0 +1,22 @@
+import type {
+    couponIssuerApplyByAddResponse,
+    CouponIssuerApplyByIdResponse
+} from '@/api/types/me'
+import { http } from '@/http/alova'
+
+/**
+ *
+ * 发卷人查询审核状态
+ */
+
+export function getCouponIssuerApplyById() {
+    return http.Get<CouponIssuerApplyByIdResponse>('/couponCenter/APP/couponIssuerApply/queryById')
+}
+
+export interface CouponIssuerApplyByAddForm {
+    name: string
+    phone: string
+}
+export function couponIssuerApplyByAdd(couponIssuerApplyByAddForm: CouponIssuerApplyByAddForm) {
+    return http.Post<couponIssuerApplyByAddResponse>('/couponCenter/APP/couponIssuerApply/add', couponIssuerApplyByAddForm)
+}

+ 3 - 0
src/api/types/coupon.ts

@@ -5,6 +5,9 @@ export interface CouponList {
 
 export interface AccountCount {
     balance: number
+    status: number
+    withdrawableAmount: number
+    unsettledAmount: number
 }
 
 export interface CouponSituation {

+ 15 - 0
src/api/types/income.ts

@@ -0,0 +1,15 @@
+export interface couponIssuerApplyApplyByAddResponse {
+    name: string
+    phone: string
+    status: string
+    applyReason: string
+    auditBy: string
+    auditRemark: string
+    auditTime: string
+}
+
+export interface accountCountData {
+    balance: number
+    withdrawableAmount: number
+    unsettledAmount: number
+}

+ 14 - 0
src/api/types/me.ts

@@ -0,0 +1,14 @@
+export interface CouponIssuerApplyByIdResponse {
+    name: string
+    phone: string
+    status: string
+    applyReason: string
+    auditBy: string
+    auditRemark: string
+    auditTime: string
+}
+
+export interface couponIssuerApplyByAddResponse {
+    name: string
+    phone: string
+}

+ 137 - 103
src/pages-A/applyForm/index.vue

@@ -1,6 +1,18 @@
 <script lang="ts" setup>
-import { reactive, ref } from 'vue'
-import { useUserStore } from '@/store'
+import {
+    useRequest
+} from 'alova/client'
+import {
+    reactive,
+    ref
+} from 'vue'
+import {
+    couponIssuerApplyByAdd,
+    getCouponIssuerApplyById
+} from '@/api/me'
+import {
+    useUserStore
+} from '@/store'
 
 definePage({
     style: {
@@ -10,11 +22,11 @@ definePage({
 
 const userStore = useUserStore()
 
-const model = reactive({
+let model = reactive({
     name: '',
     phone: '',
-    result: '',
-    description: '',
+    status: '0',
+    auditRemark: '',
 })
 const rules = reactive({
     name: {
@@ -31,21 +43,68 @@ const rules = reactive({
         trigger: ['blur', 'change'],
     },
 })
+// 发卷人查询审核状态
+const {
+    send: getCouponIssuerApplyByIdRequest,
+    data: couponIssuerApplyByIdData,
+} = useRequest(getCouponIssuerApplyById, {
+    immediate: false,
+})
+const formResult = ref(null)
+onLoad(async (options) => {
+    await getCouponIssuerApplyByIdRequest()
+    console.log(999999, couponIssuerApplyByIdData.value.status)
+    if (couponIssuerApplyByIdData.value && couponIssuerApplyByIdData.value.status === '1') {
+        formResult.value = couponIssuerApplyByIdData.value
+        model = couponIssuerApplyByIdData.value
+    }
+})
 
 // 使用 ref 创建响应式引用
 const uFormRef = ref(null)
 
+// 发劵人审核-添加
+const {
+    send: couponIssuerApplyByAddRequest,
+    data: couponIssuerApplyByAddData,
+} = useRequest(couponIssuerApplyByAdd, {
+    immediate: false,
+})
+
 function submitForm() {
     uFormRef.value.validate().then((valid) => {
         if (valid) {
-            uni.$u.toast('校验通过')
+            const couponIssuerApplyByAddForm = {
+                name: model.name,
+                phone: model.phone,
+            }
+            couponIssuerApplyByAddRequest(couponIssuerApplyByAddForm).then(() => {
+                // 返回上一页
+                console.log('提交成功:', couponIssuerApplyByAddData)
+                uni.showToast({
+                    title: '校验通过',
+                    icon: 'success',
+                })
+                uni.navigateBack()
+            }).catch(() => {
+                uni.showToast({
+                    title: '校验失败',
+                    icon: 'error',
+                })
+            })
         }
         else {
-            uni.$u.toast('校验失败')
+            uni.showToast({
+                title: '校验失败',
+                icon: 'error',
+            })
         }
     }).catch(() => {
         // 处理验证错误
-        uni.$u.toast('校验失败')
+        uni.showToast({
+            title: '校验失败',
+            icon: 'error',
+        })
     })
 }
 </script>
@@ -53,65 +112,29 @@ function submitForm() {
 <template>
     <view class="form-container">
         <view class="form-wrapper">
-            <u-form
-                ref="uFormRef"
-                label-position="left"
-                :model="model"
-                :rules="rules"
-            >
-                <u-form-item
-                    ref="item1"
-                    label="申请人姓名"
-                    prop="name"
-                    :border-bottom="true"
-                >
-                    <u-input
-                        v-model="model.name"
-                        border="none"
-                        placeholder="请输入申请人姓名"
-                    />
+            <u-form ref="uFormRef" label-position="left" :model="model" :rules="rules">
+                <u-form-item ref="item1" label="申请人姓名" prop="name" :border-bottom="true">
+                    <u-input v-model="model.name" border="none" disabled="formResult" placeholder="请输入申请人姓名" />
                 </u-form-item>
-                <u-form-item
-                    ref="item2"
-                    label="电话"
-                    prop="phone"
-                    :border-bottom="true"
-                >
-                    <u-input
-                        v-model="model.phone"
-                        border="none"
-                        placeholder="请输入小程序登录的手机号"
-                    />
+                <u-form-item ref="item2" label="电话" prop="phone" :border-bottom="true">
+                    <u-input v-model="model.phone" border="none" disabled="formResult" placeholder="请输入小程序登录的手机号" />
                 </u-form-item>
-                <u-form-item
-                    ref="item3"
-                    label="申请结果"
-                    :border-bottom="true"
-                >
-                    <view class="form-item-result u-text-danger">
+                <u-form-item v-if="formResult" ref="item3" label="申请结果" :border-bottom="true">
+                    <view v-if="formResult.status === '2'" class="form-item-result u-text-danger">
                         已拒绝
                     </view>
-                    <view class="form-item-result u-text-success">
+                    <view v-else class="form-item-result u-text-success">
                         已通过
                     </view>
                 </u-form-item>
-                <view class="form-item-des">
-                    <u-form-item
-                        ref="item4"
-                        label="拒绝说明"
-                        :border-bottom="true"
-                    >
-                        <u-textarea
-                            v-model="model.description"
-                            placeholder="此处显示拒绝说明"
-                            border="none"
-                            disabled
-                        />
+                <view v-if="formResult && formResult.status === '2'" class="form-item-des">
+                    <u-form-item ref="item4" label="拒绝说明" :border-bottom="true">
+                        <u-textarea v-model="model.auditRemark" placeholder="此处显示拒绝说明" border="none" disabled />
                     </u-form-item>
                 </view>
             </u-form>
 
-            <view class="form-btn" @click="submitForm">
+            <view v-if="formResult && formResult.status !== '1'" class="form-btn" @click="submitForm">
                 提交申请
             </view>
         </view>
@@ -120,75 +143,86 @@ function submitForm() {
 
 <style lang="scss" scoped>
 ::v-deep .u-form-item__body__left {
-  width: 150rpx !important;
-  font-weight: 400 !important;
-  font-size: 26rpx !important;
-  color: #333333 !important;
+    width: 150rpx !important;
+    font-weight: 400 !important;
+    font-size: 26rpx !important;
+    color: #333333 !important;
 }
+
 ::v-deep .u-input__content__field-wrapper__field {
-  text-align: right !important;
+    text-align: right !important;
 }
+
 ::v-deep .u-form-item__body__left__content__label {
-  color: #333333 !important;
-  font-size: 26rpx !important;
-  font-weight: 400 !important;
+    color: #333333 !important;
+    font-size: 26rpx !important;
+    font-weight: 400 !important;
 }
+
 ::v-deep .u-line {
-  border-color: #eeeeee !important;
+    border-color: #eeeeee !important;
 }
 
 ::v-deep .u-form-item__body__right__content__slot {
-  display: flex;
-  justify-content: flex-end;
+    display: flex;
+    justify-content: flex-end;
 }
+
+/* 为禁用状态的input添加白色背景 */
+::v-deep .u-input__content__field-wrapper__field {
+    background-color: #fff !important;
+}
+
 .form-container {
-  background-color: #f5f5f5;
-  min-height: 100vh;
-  padding: 20rpx;
+    background-color: #f5f5f5;
+    min-height: 100vh;
+    padding: 20rpx;
 }
 
 .form-wrapper {
-  background-color: #fff;
-  border-radius: 12rpx;
-  padding: 0 32rpx;
+    background-color: #fff;
+    border-radius: 12rpx;
+    padding: 0 32rpx;
 }
 
 .form-item-result {
-  width: 112rpx;
-  height: 44rpx;
-  line-height: 44rpx;
-  border-radius: 10rpx;
-  text-align: center;
-  &.u-text-danger {
-    color: #ff3333;
-    background: rgba(#ff7171, 0.2);
-  }
-  &.u-text-success {
-    color: #64a6ff;
-    background: rgba(#64a6ff, 0.2);
-  }
+    width: 112rpx;
+    height: 44rpx;
+    line-height: 44rpx;
+    border-radius: 10rpx;
+    text-align: center;
+
+    &.u-text-danger {
+        color: #ff3333;
+        background: rgba(#ff7171, 0.2);
+    }
+
+    &.u-text-success {
+        color: #64a6ff;
+        background: rgba(#64a6ff, 0.2);
+    }
 }
 
 .form-item-des {
-  ::v-deep .u-form-item__body {
-    flex-direction: column !important;
-    gap: 32rpx !important;
-  }
+    ::v-deep .u-form-item__body {
+        flex-direction: column !important;
+        gap: 32rpx !important;
+    }
 }
 
 .form-btn {
-  width: 600rpx;
-  height: 80rpx;
-  line-height: 80rpx;
-  background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
-  border-radius: 10rpx;
-  position: fixed;
-  bottom: 52rpx;
-  left: 50%;
-  transform: translateX(-50%);
-  font-weight: 400;
-  font-size: 30rpx;
-  color: #ffffff;
-  text-align: center;
+    width: 600rpx;
+    height: 80rpx;
+    line-height: 80rpx;
+    background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
+    border-radius: 10rpx;
+    position: fixed;
+    bottom: 52rpx;
+    left: 50%;
+    transform: translateX(-50%);
+    font-weight: 400;
+    font-size: 30rpx;
+    color: #ffffff;
+    text-align: center;
 }
 </style>

+ 67 - 17
src/pages-A/unlockRewards/index.vue

@@ -1,6 +1,9 @@
 <script lang="ts" setup>
+import { useRequest } from 'alova/client'
 import { storeToRefs } from 'pinia'
 import { ref } from 'vue'
+import { getAccountCount } from '@/api/home'
+import { getUnlockAmountByUserId } from '@/api/income'
 import CustomNavigationBar from '@/components/CustomNavigationBar.vue'
 import { LOGIN_PAGE } from '@/router/config'
 import { useUserStore } from '@/store'
@@ -16,13 +19,15 @@ definePage({
 
 const userStore = useUserStore()
 const tokenStore = useTokenStore()
+const { hasLogin } = storeToRefs(tokenStore)
+
 // 使用storeToRefs解构userInfo
 const { userInfo } = storeToRefs(userStore)
 
 function menuClick(page: string) {
-  uni.navigateTo({
-    url: `/pages-A/${page}/index`,
-  })
+    uni.navigateTo({
+        url: `/pages-A/${page}/index`,
+    })
 }
 
 const show = ref(false)
@@ -37,6 +42,26 @@ function cancel() {
 function close() {
     show.value = false
 }
+const unlockAmount = ref(0)
+
+// 发券人账户表-通过userId查询账户信息
+const { send: getAccountCountRequest, data: accountCountData } = useRequest(getAccountCount, {
+    immediate: false,
+})
+
+const { send: getUnlockAmountByUserIdRequest, data: unlockAmountData } = useRequest(getUnlockAmountByUserId, {
+    immediate: false,
+})
+// 移除重复声明,已在下方统一声明
+onShow(async () => {
+    // 登录后查询收益数据
+    if (hasLogin) {
+        await getAccountCountRequest()
+        await getUnlockAmountByUserIdRequest()
+        unlockAmount.value = unlockAmountData
+    }
+})
+
 function showTimeFilter() {
     show.value = true
 }
@@ -45,8 +70,13 @@ const activeTab = ref('pending')
 function changeTab(tab: string) {
     activeTab.value = tab
 }
-
-const unlockAmount = ref('')
+function submitPay() {
+    // 提示联系管理员
+    uni.showToast({
+        title: '联系管理员解锁收益!',
+        icon: 'none',
+    })
+}
 </script>
 
 <template>
@@ -55,14 +85,20 @@ const unlockAmount = ref('')
         <CustomNavigationBar title="解锁收益" background-color="transparent" />
 
         <!-- 顶部区域 -->
-        <view class="income-header" style="background: url('../../static/images/income/income-bg.png') no-repeat center center; background-size: cover;">
-            <view class="income-header-avatar-info" :style="{ paddingTop: `${safeAreaInsets.top + menuButtonInfo.height + 12}px` }">
+        <view
+            class="income-header"
+            style="background: url('../../static/images/income/income-bg.png') no-repeat center center; background-size: cover;"
+        >
+            <view
+                class="income-header-avatar-info"
+                :style="{ paddingTop: `${safeAreaInsets.top + menuButtonInfo.height + 12}px` }"
+            >
                 <view class="income-header-balance">
                     锁定余额(元)
                 </view>
                 <view class="income-header-balance-num">
                     <view class="income-header-balance-num-amount">
-                        7297491.08
+                        {{ accountCountData?.balance }}
                     </view>
                     <view class="income-header-balance-num-btns">
                         <view class="income-header-balance-num-btn js">
@@ -74,7 +110,7 @@ const unlockAmount = ref('')
             <view class="income-header-tips">
                 <view class="income-header-tips-item">
                     <view class="income-header-tips-item-num">
-                        729000.00
+                        {{ accountCountData?.withdrawableAmount }}
                     </view>
                     <view class="income-header-tips-item-des">
                         锁定金额
@@ -82,7 +118,7 @@ const unlockAmount = ref('')
                 </view>
                 <view class="income-header-tips-item">
                     <view class="income-header-tips-item-num">
-                        1,125
+                        {{ accountCountData?.unsettledAmount }}
                     </view>
                     <view class="income-header-tips-item-des">
                         未结算金额
@@ -97,15 +133,10 @@ const unlockAmount = ref('')
             </view>
             <view class="income-header-menu-input">
                 <text class="income-header-menu-input-symbol">¥</text>
-                <u-input
-                    v-model="unlockAmount"
-                    type="number"
-                    border="none"
-                    placeholder="请输入解锁金额"
-                />
+                <u-input v-model="unlockAmount" type="number" border="none" />
             </view>
         </view>
-        <view class="income-header-menu-btn">
+        <view class="income-header-menu-btn" @click="submitPay">
             立即充值
         </view>
     </view>
@@ -116,45 +147,55 @@ const unlockAmount = ref('')
   height: 80rpx !important;
   font-size: 80rpx !important;
 }
+
 .profile-container {
   font-family: Alibaba PuHuiTi;
   min-height: 100vh;
   background-color: #f5f5f5;
   line-height: 1;
+
   //   padding-top: 44px; /* 为固定导航栏留出空间 */
   .income-header {
     height: 525rpx;
+
     .income-header-avatar-info {
       display: flex;
       flex-direction: column;
       gap: 30rpx;
       padding: 0 24rpx;
+
       .income-header-balance {
         font-weight: 400;
         font-size: 26rpx;
         color: #ffffff;
       }
+
       .income-header-balance-num {
         display: flex;
         justify-content: space-between;
         align-items: center;
+
         .income-header-balance-num-amount {
           font-weight: 500;
           font-size: 65rpx;
           color: #ffffff;
         }
+
         .income-header-balance-num-btns {
           display: flex;
           gap: 15rpx;
+
           .income-header-balance-num-btn {
             padding: 20rpx 40rpx;
             border-radius: 33rpx;
             font-weight: 400;
             font-size: 26rpx;
+
             &.js {
               background: #da4c47;
               color: #ffffff;
             }
+
             &.tx {
               background: #bfbfbf;
               color: #747474;
@@ -163,12 +204,14 @@ const unlockAmount = ref('')
         }
       }
     }
+
     .income-header-tips {
       height: 124rpx;
       display: flex;
       background: linear-gradient(114deg, #f67873, #fb847f, #f67873);
       border-radius: 10rpx;
       margin: 47rpx 24rpx 0 24rpx;
+
       .income-header-tips-item {
         flex: 1;
         display: flex;
@@ -181,6 +224,7 @@ const unlockAmount = ref('')
         color: #ffffff;
         line-height: 1;
         position: relative;
+
         &:first-child:after {
           content: '';
           position: absolute;
@@ -191,9 +235,11 @@ const unlockAmount = ref('')
           height: 40rpx;
           background: #ffffff;
         }
+
         .income-header-tips-item-num {
           font-weight: bold;
         }
+
         .income-header-tips-item-des {
           font-weight: 400;
           font-size: 24rpx;
@@ -208,6 +254,7 @@ const unlockAmount = ref('')
     border-radius: 10rpx;
     margin: 24rpx 24rpx 0;
     margin-top: -30rpx;
+
     .income-header-menu-title {
       font-weight: 400;
       font-size: 26rpx;
@@ -215,11 +262,13 @@ const unlockAmount = ref('')
       padding: 34rpx 20rpx;
       border-bottom: 2rpx solid #eeeeee;
     }
+
     .income-header-menu-input {
       display: flex;
       align-items: flex-end;
       gap: 17rpx;
       padding: 66rpx 20rpx;
+
       .income-header-menu-input-symbol {
         font-weight: 400;
         font-size: 60rpx;
@@ -227,6 +276,7 @@ const unlockAmount = ref('')
       }
     }
   }
+
   .income-header-menu-btn {
     width: 600rpx;
     line-height: 80rpx;

+ 140 - 118
src/pages/income/income.vue

@@ -1,164 +1,150 @@
 <script lang="ts" setup>
+import type { AccountDetailItem } from '@/api/income'
+import { useRequest } from 'alova/client'
 import { storeToRefs } from 'pinia'
 import { ref } from 'vue'
+import { getAccountCount } from '@/api/home'
+import { getCouponIssuerAccountByPageMap, PageMapResponse } from '@/api/income'
+
 import { LOGIN_PAGE } from '@/router/config'
 import { useUserStore } from '@/store'
 import { useTokenStore } from '@/store/token'
 import { changtime, menuButtonInfo, safeAreaInsets, systemInfo } from '@/utils'
 
 definePage({
-  style: {
-    navigationBarTitleText: '收益',
-    navigationStyle: 'custom',
-  },
+    style: {
+        navigationBarTitleText: '收益',
+        navigationStyle: 'custom',
+    },
 })
 
 const userStore = useUserStore()
 const tokenStore = useTokenStore()
 // 使用storeToRefs解构userInfo
 const { userInfo } = storeToRefs(userStore)
-
-// 微信小程序下登录
-async function handleLogin() {
-  // #ifdef MP-WEIXIN
-  // 微信登录
-  await tokenStore.wxLogin()
-
-  // #endif
-  // #ifndef MP-WEIXIN
-  uni.navigateTo({
-    url: `${LOGIN_PAGE}`,
-  })
-  // #endif
-}
-
-function handleLogout() {
-  uni.showModal({
-    title: '提示',
-    content: '确定要退出登录吗?',
-    success: (res) => {
-      if (res.confirm) {
-        // 清空用户信息
-        useTokenStore().logout()
-        // 执行退出登录逻辑
-        uni.showToast({
-          title: '退出登录成功',
-          icon: 'success',
-        })
-        // #ifdef MP-WEIXIN
-        // 微信小程序,去首页
-        // uni.reLaunch({ url: '/pages/index/index' })
-        // #endif
-        // #ifndef MP-WEIXIN
-        // 非微信小程序,去登录页
-        // uni.navigateTo({ url: LOGIN_PAGE })
-        // #endif
-      }
-    },
-  })
-}
-
-function menuClick(page: string) {
-  uni.navigateTo({
-    url: `/pages-A/${page}/index`,
-  })
-}
+const { hasLogin } = storeToRefs(tokenStore)
 
 const show = ref(false)
 const filterValue = ref(Number(new Date()))
 function confirm() {
-  // 函数实现
-  show.value = false
+    // 函数实现
+    show.value = false
 }
 function cancel() {
-  show.value = false
+    show.value = false
 }
 function close() {
-  show.value = false
+    show.value = false
 }
+// 发券人账户表-通过userId查询账户信息
+const { send: getAccountCountRequest, data: accountCountData } = useRequest(getAccountCount, {
+    immediate: false,
+})
+
+const queryForm = ref({
+    pageNo: 1,
+    pageSize: 10,
+    startTime: '',
+    endTime: '',
+    status: 0, // 0-待结算, 1-已结算/成功
+    type: 1, // 明细类型: 1-佣金收入, 2-提现支出, 3-退款扣减, 4-系统调整
+})
+
+// 获取账户明细分页数据(Map格式)
+const { send: getCouponIssuerAccountByPageMapRequest, data: couponIssuerAccountByPageMapData } = useRequest(
+    getCouponIssuerAccountByPageMap,
+    { immediate: false },
+)
+const list = ref<AccountDetailItem[]>([])
+
+onShow(async () => {
+    // 登录后查询收益数据
+    if (hasLogin) {
+        try {
+            await getAccountCountRequest()
+            await getCouponIssuerAccountByPageMapRequest(queryForm.value)
+            // 使用可选链和空值合并运算符避免undefined错误,直接赋值而非展开运算符
+            list.value = couponIssuerAccountByPageMapData.value?.detailList || []
+        }
+        catch (error) {
+            console.error('获取收益数据失败:', error)
+            uni.showToast({ title: '获取数据失败', icon: 'error' })
+            list.value = []
+        }
+    }
+})
+
 function showTimeFilter() {
-  show.value = true
+    show.value = true
 }
-const wjsList = ref([
-  {
-    id: 1,
-    nickName: '昵称1',
-    name: '优惠券1',
-    price: 1000,
-    date: '2023-08-01 10:00:00',
-  },
-  {
-    id: 2,
-    nickName: '昵称2',
-    name: '优惠券2',
-    price: 1300,
-    date: '2023-10-01 10:00:00',
-  },
-])
-const yjsList = ref([
-  {
-    id: 1,
-    nickName: '昵称3',
-    name: '优惠券3',
-    price: 2300,
-    date: '2023-10-01 10:00:00',
-  },
-  {
-    id: 2,
-    nickName: '昵称4',
-    name: '优惠券4',
-    price: 300,
-    date: '2023-10-01 10:00:00',
-  },
-])
-const list = ref([])
+const wjsList = ref<AccountDetailItem[]>([])
+const yjsList = ref<AccountDetailItem[]>([])
 onLoad(() => {
-  list.value = [...wjsList.value]
+    list.value = wjsList.value
 })
 const activeTab = ref('pending')
-function changeTab(tab: string) {
+async function changeTab(tab: string) {
+    console.log(999, activeTab.value, tab)
+    if (activeTab.value === tab)
+        return
     activeTab.value = tab
-    if (tab === 'pending') {
-        list.value = [...wjsList.value]
+    queryForm.value.status = tab === 'pending' ? 0 : 1
+
+    try {
+        await getCouponIssuerAccountByPageMapRequest(queryForm.value)
+        // 使用可选链和空值合并运算符避免undefined错误,直接赋值而非展开运算符
+        list.value = couponIssuerAccountByPageMapData.value?.detailList || []
     }
-    else {
-        list.value = [...yjsList.value]
+    catch (error) {
+        console.error('切换标签页失败:', error)
+        uni.showToast({ title: '获取数据失败', icon: 'error' })
+        list.value = []
     }
 }
 
 function goPage(page: string) {
-  uni.navigateTo({
-    url: `/pages-A/${page}/index`,
-  })
+    uni.navigateTo({
+        url: `/pages-A/${page}/index`,
+    })
 }
 </script>
 
 <template>
     <view class="profile-container">
         <!-- 顶部区域 -->
-        <view class="income-header" style="background: url('../../static/images/income/income-bg.png') no-repeat center center; background-size: cover;">
-            <view class="income-header-avatar-info" :style="{ paddingTop: `${safeAreaInsets.top + menuButtonInfo.height + 12}px` }">
+        <view
+            class="income-header"
+            style="background: url('../../static/images/income/income-bg.png') no-repeat center center; background-size: cover;"
+        >
+            <view
+                class="income-header-avatar-info"
+                :style="{ paddingTop: `${safeAreaInsets.top + menuButtonInfo.height + 12}px` }"
+            >
                 <view class="income-header-balance">
                     当前账户余额(元)
                 </view>
                 <view class="income-header-balance-num">
                     <view class="income-header-balance-num-amount">
-                        7297491.08
+                        {{ accountCountData?.balance }}
                     </view>
                     <view class="income-header-balance-num-btns">
-                        <view class="income-header-balance-num-btn js" @click="goPage('unlockRewards')">
+                        <view
+                            v-if="accountCountData?.status === 0"
+                            class="income-header-balance-num-btn js"
+                            @click="goPage('unlockRewards')"
+                        >
                             解锁
                         </view>
-                        <view class="income-header-balance-num-btn tx" @click="goPage('withdraw')">
+                        <!-- <view class="income-header-balance-num-btn tx" @click="goPage('withdraw')">
                             提现
-                        </view>
+                        </view> -->
                     </view>
                 </view>
             </view>
             <view class="income-header-tips">
                 <view class="income-header-tips-item">
                     <view class="income-header-tips-item-num">
-                        729000.00
+                        {{ accountCountData?.withdrawableAmount }}
                     </view>
                     <view class="income-header-tips-item-des">
                         可提现金额
@@ -166,7 +152,7 @@ function goPage(page: string) {
                 </view>
                 <view class="income-header-tips-item">
                     <view class="income-header-tips-item-num">
-                        1,125
+                        {{ accountCountData?.unsettledAmount }}
                     </view>
                     <view class="income-header-tips-item-des">
                         未结算金额
@@ -187,10 +173,16 @@ function goPage(page: string) {
         <view class="income-header-menu">
             <!-- 结算筛选 -->
             <view class="income-header-menu-filter">
-                <view class="income-header-menu-filter-item" :class="[activeTab === 'pending' ? 'active' : '']" @click="changeTab('pending')">
+                <view
+                    class="income-header-menu-filter-item" :class="[activeTab === 'pending' ? 'active' : '']"
+                    @click="changeTab('pending')"
+                >
                     待结算
                 </view>
-                <view class="income-header-menu-filter-item" :class="[activeTab === 'settled' ? 'active' : '']" @click="changeTab('settled')">
+                <view
+                    class="income-header-menu-filter-item" :class="[activeTab === 'settled' ? 'active' : '']"
+                    @click="changeTab('settled')"
+                >
                     已结算
                 </view>
             </view>
@@ -200,7 +192,7 @@ function goPage(page: string) {
                     <text>{{ changtime(filterValue) }}</text>
                     <up-icon name="arrow-down" color="#666666" size="14" />
                 </view>
-                <view>合计:¥4396.00</view>
+                <view>合计:¥{{ couponIssuerAccountByPageMapData?.totalAmount || 0 }}</view>
             </view>
             <!-- 优惠券列表 -->
             <view class="income-header-menu-list">
@@ -210,29 +202,25 @@ function goPage(page: string) {
                         <image v-else src="@/static/images/income/djs.png" mode="aspectFit" />
                         <view class="income-header-menu-text">
                             <view class="income-header-menu-text-nickname">
-                                {{ item.nickName }}
+                                {{ item.receiveUserName }}
                             </view>
-                            <view>{{ item.name }}</view>
+                            <view>{{ item.couponName }}</view>
                         </view>
                     </view>
                     <view class="income-header-menu-left">
                         <view class="income-header-menu-left-amount">
-                            ¥{{ item.price }}
+                            ¥{{ item.changeAmount }}
                         </view>
                         <view class="income-header-menu-left-time">
-                            {{ item.date }}
+                            {{ item.settleTime }}
                         </view>
                     </view>
                 </view>
             </view>
         </view>
         <up-datetime-picker
-            v-model="filterValue"
-            :show="show"
-            mode="year-month"
-            close-on-click-overlay
-            @confirm="confirm"
-            @cancel="cancel"
+            v-model="filterValue" :show="show" mode="year-month" close-on-click-overlay
+            @confirm="confirm" @cancel="cancel"
         />
     </view>
 </template>
@@ -243,39 +231,48 @@ function goPage(page: string) {
   min-height: 100vh;
   background-color: #f5f5f5;
   line-height: 1;
+
   .income-header {
     height: 525rpx;
+
     .income-header-avatar-info {
       display: flex;
       flex-direction: column;
       gap: 30rpx;
       padding: 0 24rpx;
+
       .income-header-balance {
         font-weight: 400;
         font-size: 26rpx;
         color: #ffffff;
       }
+
       .income-header-balance-num {
         display: flex;
         justify-content: space-between;
         align-items: center;
+
         .income-header-balance-num-amount {
           font-weight: 500;
           font-size: 65rpx;
           color: #ffffff;
         }
+
         .income-header-balance-num-btns {
           display: flex;
           gap: 15rpx;
+
           .income-header-balance-num-btn {
             padding: 20rpx 40rpx;
             border-radius: 33rpx;
             font-weight: 400;
             font-size: 26rpx;
+
             &.js {
               background: #da4c47;
               color: #ffffff;
             }
+
             &.tx {
               background: #bfbfbf;
               color: #747474;
@@ -284,12 +281,14 @@ function goPage(page: string) {
         }
       }
     }
+
     .income-header-tips {
       height: 124rpx;
       display: flex;
       background: linear-gradient(114deg, #f67873, #fb847f, #f67873);
       border-radius: 10rpx;
       margin: 47rpx 24rpx 0 24rpx;
+
       .income-header-tips-item {
         flex: 1;
         display: flex;
@@ -302,6 +301,7 @@ function goPage(page: string) {
         color: #ffffff;
         line-height: 1;
         position: relative;
+
         &:first-child:after {
           content: '';
           position: absolute;
@@ -312,9 +312,11 @@ function goPage(page: string) {
           height: 40rpx;
           background: #ffffff;
         }
+
         .income-header-tips-item-num {
           font-weight: bold;
         }
+
         .income-header-tips-item-des {
           font-weight: 400;
           font-size: 24rpx;
@@ -332,18 +334,22 @@ function goPage(page: string) {
     align-items: center;
     gap: 20rpx;
     padding: 28rpx 20rpx;
+
     .income-header-notice-icon {
       width: 52rpx;
       height: 35rpx;
+
       image {
         width: 100%;
         height: 100%;
       }
     }
+
     .income-header-notice-content {
       font-weight: 400;
       font-size: 24rpx;
       color: #333333;
+
       text {
         color: #c52d27;
       }
@@ -354,6 +360,7 @@ function goPage(page: string) {
     // background: #ffffff;
     border-radius: 10rpx 10rpx 0rpx 0rpx;
     margin: 24rpx 24rpx 0;
+
     .income-header-menu-filter {
       display: flex;
       justify-content: space-between;
@@ -365,6 +372,7 @@ function goPage(page: string) {
       background: #ffffff;
       box-shadow: 0rpx 3rpx 7rpx 0rpx rgba(213, 213, 213, 0.29);
       border-radius: 10rpx 10rpx 0rpx 0rpx;
+
       .income-header-menu-filter-item {
         flex: 1;
         display: flex;
@@ -372,8 +380,10 @@ function goPage(page: string) {
         align-items: center;
         position: relative;
         height: 100%;
+
         &.active {
           color: #ed6b66;
+
           &:after {
             content: '';
             position: absolute;
@@ -388,6 +398,7 @@ function goPage(page: string) {
         }
       }
     }
+
     .income-menu-time-filter {
       display: flex;
       justify-content: space-between;
@@ -398,6 +409,7 @@ function goPage(page: string) {
       padding: 50rpx 20rpx 14rpx;
       background: #ffffff;
       margin-top: 4rpx;
+
       .income-menu-time-filter-text {
         font-weight: 400;
         font-size: 26rpx;
@@ -407,8 +419,10 @@ function goPage(page: string) {
         gap: 12rpx;
       }
     }
+
     .income-header-menu-list {
       background: #ffffff;
+
       .income-header-menu-item {
         height: 88rpx;
         display: flex;
@@ -417,22 +431,27 @@ function goPage(page: string) {
         border-bottom: 1px solid #eeeeee;
         padding: 32rpx 0 29rpx;
         margin: 0 20rpx;
+
         &:last-child {
           border-bottom: none;
         }
+
         .income-header-menu-icon {
           display: flex;
           justify-content: center;
           align-items: center;
           gap: 19rpx;
+
           image {
             width: 60rpx;
             height: 60rpx;
           }
+
           .income-header-menu-text {
             font-weight: 400;
             font-size: 24rpx;
             color: #888888;
+
             .income-header-menu-text-nickname {
               font-size: 28rpx;
               color: #222222;
@@ -440,14 +459,17 @@ function goPage(page: string) {
             }
           }
         }
+
         .income-header-menu-left {
           font-weight: 400;
           font-size: 24rpx;
           color: #888888;
+
           .income-header-menu-left-amount {
             font-size: 28rpx;
             color: #222222;
             margin-bottom: 18rpx;
+            text-align: right;
           }
         }
       }

+ 259 - 121
src/pages/me/me.vue

@@ -1,6 +1,9 @@
 <script lang="ts" setup>
+import { useRequest } from 'alova/client'
 import { storeToRefs } from 'pinia'
-import { ref } from 'vue'
+import { computed, ref } from 'vue'
+import { getCouponSituation } from '@/api/home'
+import { getCouponIssuerApplyById } from '@/api/me'
 import { LOGIN_PAGE } from '@/router/config'
 import { useUserStore } from '@/store'
 import { useTokenStore } from '@/store/token'
@@ -16,6 +19,38 @@ const userStore = useUserStore()
 const tokenStore = useTokenStore()
 // 使用storeToRefs解构userInfo
 const { userInfo } = storeToRefs(userStore)
+const { hasLogin } = storeToRefs(tokenStore)
+console.log('Login:', userInfo.value, hasLogin.value)
+
+// 用户优惠券统计数据
+const { send: getCouponSituationRequest, data: couponSituationData } = useRequest(getCouponSituation, {
+    immediate: false,
+})
+// 发卷人查询审核状态
+const { send: getCouponIssuerApplyByIdRequest, data: couponIssuerApplyByIdData } = useRequest(getCouponIssuerApplyById, {
+    immediate: false,
+})
+// 昵称输入值
+const nicknameInput = ref('')
+onShow(() => {
+    // 登录后查询收益数据
+    if (hasLogin) {
+        // 获取用户信息
+        userStore.fetchUserInfo().then((data) => {
+            // #ifdef MP-WEIXIN
+            // 初始化昵称输入框
+            console.log('用户信息:', data)
+            nicknameInput.value = data?.userInfo.nickname || ''
+            // #endif
+        })
+        getCouponSituationRequest()
+        getCouponIssuerApplyByIdRequest()
+        if (couponIssuerApplyByIdData.value?.status === '0') {
+            console.log('优惠券统计数据:', couponSituationData.value)
+            open()
+        }
+    }
+})
 
 // 微信小程序下登录
 async function handleLogin() {
@@ -59,6 +94,12 @@ function handleLogout() {
 
 // 顶部导航栏高度,设置banner位置
 const navigationBarHeight = ref(0)
+// 头像默认图片
+const defaultAvatar = '../../static/images/me/me-bg.png'
+// 计算头像显示
+const avatarDisplay = computed(() => {
+    return userInfo.value?.avatar || defaultAvatar
+})
 // #ifdef MP-WEIXIN
 function getNavigationBarHeight() {
     uni.getSystemInfo({
@@ -71,9 +112,65 @@ function getNavigationBarHeight() {
     })
 }
 getNavigationBarHeight()
+
+// 处理点击头像获取用户头像
+async function handleGetAvatar(e) {
+    const { avatarUrl } = e.detail
+    if (avatarUrl) {
+        userStore.setUserAvatar(avatarUrl)
+        uni.showToast({
+            title: '头像获取成功',
+            icon: 'success',
+        })
+        // 验证本地存储是否已更新
+        const updatedUser = uni.getStorageSync('user')
+        console.log('验证本地存储头像更新:', updatedUser?.avatar)
+    }
+}
+
+// 保存昵称
+function saveNickname(e: any) {
+    console.log('保存昵称:', e.detail)
+    // 直接使用nicknameInput.value,因为input已经通过v-model绑定
+    const nickname = nicknameInput.value.trim()
+    if (nickname) {
+        try {
+            // 更新用户信息到store
+            userStore.setUserInfo({
+                ...userInfo.value,
+                nickname,
+            })
+
+            uni.showToast({
+                title: '昵称保存成功',
+                icon: 'success',
+                duration: 1500,
+            })
+
+            // 验证本地存储是否已更新
+            const updatedUser = uni.getStorageSync('user')
+            console.log('本地存储昵称已更新:', updatedUser?.nickname)
+        }
+        catch (error) {
+            console.error('保存昵称失败:', error)
+            uni.showToast({
+                title: '保存失败,请重试',
+                icon: 'error',
+                duration: 1500,
+            })
+        }
+    }
+    else {
+        uni.showToast({
+            title: '昵称不能为空',
+            icon: 'none',
+            duration: 1500,
+        })
+    }
+}
 // #endif
 
-const show = ref(true)
+const show = ref(false)
 function close() {
     show.value = false
 }
@@ -81,8 +178,12 @@ function open() {
     show.value = true
 }
 function menuClick(page) {
+    if (couponIssuerApplyByIdData.value?.status === '0') {
+        open()
+        return
+    }
     uni.navigateTo({
-        url: `/pages-A/${page}/index`,
+        url: `/pages-A/${page}/index?couponSituation=${JSON.stringify(couponSituationData.value)}`,
     })
 }
 </script>
@@ -90,14 +191,22 @@ function menuClick(page) {
 <template>
     <view class="profile-container">
         <!-- 顶部区域 -->
-        <view class="me-header" style="background: url('../../static/images/me/me-bg.png') no-repeat center center; background-size: cover;">
+        <view class="me-header"
+            style="background: url('../../static/images/me/me-bg.png') no-repeat center center; background-size: cover;">
             <view class="me-header-avatar-info" :style="{ paddingTop: `${navigationBarHeight}px` }">
-                <view class="me-header-avatar">
-                    <image src="https://picsum.photos/200/200" mode="" />
-                </view>
+                <button class="me-header-avatar" open-type="chooseAvatar" @click="handleGetAvatar">
+                    <image :src="avatarDisplay" mode="aspectFill" />
+                </button>
                 <view class="me-header-info">
                     <view class="me-header-name">
-                        {{ userInfo.value?.nickName || '用户' }}
+                        <!-- #ifdef MP-WEIXIN -->
+                        <input v-model="nicknameInput" type="nickname" placeholder="用户昵称"
+                            placeholder-style="color: #fff; opacity: 0.7;" class="nickname-input"
+                            @confirm="saveNickname" @blur="saveNickname">
+                        <!-- #endif -->
+                        <!-- #ifndef MP-WEIXIN -->
+                        {{ userInfo.value?.nickname || '用户' }}
+                        <!-- #endif -->
                     </view>
                 </view>
             </view>
@@ -132,7 +241,7 @@ function menuClick(page) {
         <view class="me-header-menu">
             <view class="me-header-menu-item" @click="menuClick('applyForm')">
                 <view class="me-header-menu-icon">
-                    <image src="@/static/images/me/coupon-need.png" mode="" />
+                    <image src="@/static/images/me/coupon-need.png" mode="aspectFill" />
                     <view class="me-header-menu-text">
                         发券人申请
                     </view>
@@ -143,7 +252,7 @@ function menuClick(page) {
             </view>
             <view class="me-header-menu-item" @click="handleLogout">
                 <view class="me-header-menu-icon">
-                    <image src="@/static/images/me/loginOut.png" mode="" />
+                    <image src="@/static/images/me/loginOut.png" mode="aspectFill" />
                     <view class="me-header-menu-text">
                         退出登录
                     </view>
@@ -154,11 +263,7 @@ function menuClick(page) {
             </view>
         </view>
         <!-- 申请中的提示框 -->
-        <up-modal
-            content="您已提交申请,请耐心等待!"
-            title="提示"
-            :show="show"
-        >
+        <up-modal content="您已提交申请,请耐心等待!" title="提示" :show="show">
             <template #confirmButton>
                 <view class="rounded" style="margin-top: 20rpx;" @click="show = false">
                     我知道了
@@ -171,126 +276,159 @@ function menuClick(page) {
 <style lang="scss" scoped>
 // 提示框
 ::v-deep .u-modal {
-  width: 580rpx !important;
-  //   height: 376rpx !important;
-  border-radius: 20rpx !important;
+    width: 580rpx !important;
+    //   height: 376rpx !important;
+    border-radius: 20rpx !important;
 }
+
 ::v-deep .u-modal__title {
-  font-weight: 500 !important;
-  font-size: 34rpx !important;
-  color: #333333 !important;
-  padding-top: 29rpx !important;
-  padding-bottom: 28rpx !important;
+    font-weight: 500 !important;
+    font-size: 34rpx !important;
+    color: #333333 !important;
+    padding-top: 29rpx !important;
+    padding-bottom: 28rpx !important;
 }
+
 ::v-deep .u-modal__content {
-  border-top: 1px solid #eeeeee;
-  border-bottom: 1px solid #eeeeee;
-  padding-top: 82rpx !important;
-  padding-bottom: 64rpx !important;
+    border-top: 1px solid #eeeeee;
+    border-bottom: 1px solid #eeeeee;
+    padding-top: 82rpx !important;
+    padding-bottom: 64rpx !important;
 }
+
 ::v-deep .u-modal__content__text {
-  font-weight: 500 !important;
-  font-size: 32rpx !important;
-  color: #333333 !important;
-  text-align: center !important;
+    font-weight: 500 !important;
+    font-size: 32rpx !important;
+    color: #333333 !important;
+    text-align: center !important;
 }
+
 .rounded {
-  width: 300rpx;
-  line-height: 69rpx;
-  background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
-  border-radius: 35rpx;
-  font-weight: 400;
-  font-size: 30rpx;
-  color: #ffffff;
-  text-align: center;
-  margin: 0 auto;
+    width: 300rpx;
+    line-height: 69rpx;
+    background: linear-gradient(90deg, #ee6b67 0%, #ff7d78 100%);
+    border-radius: 35rpx;
+    font-weight: 400;
+    font-size: 30rpx;
+    color: #ffffff;
+    text-align: center;
+    margin: 0 auto;
 }
+
 .profile-container {
-  font-family: Alibaba PuHuiTi;
-  .me-header {
-    height: 575rpx;
-    .me-header-avatar-info {
-      display: flex;
-      flex-direction: column;
-      justify-content: center;
-      align-items: center;
-      gap: 24rpx;
-      .me-header-avatar {
-        width: 128rpx;
-        height: 128rpx;
-        border-radius: 50%;
-        overflow: hidden;
-        image {
-          width: 100%;
-          height: 100%;
-          object-fit: cover;
-        }
-      }
-      .me-header-info {
-        .me-header-name {
-          font-weight: 500;
-          font-size: 30rpx;
-          color: #ffffff;
-        }
-      }
-    }
-    .me-header-tips {
-      display: flex;
-      margin-top: 49rpx;
-      .me-header-tips-item {
-        flex: 1;
-        display: flex;
-        flex-direction: column;
-        justify-content: center;
-        align-items: center;
-        gap: 15rpx;
-        font-weight: 500;
-        font-size: 34rpx;
-        color: #ffffff;
-        line-height: 1;
-        .me-header-tips-item-num {
-          font-weight: bold;
+    font-family: Alibaba PuHuiTi;
+
+    .me-header {
+        height: 575rpx;
+
+        .me-header-avatar-info {
+            display: flex;
+            flex-direction: column;
+            justify-content: center;
+            align-items: center;
+            gap: 24rpx;
+
+            .me-header-avatar {
+                width: 128rpx;
+                height: 128rpx;
+                border-radius: 50%;
+                overflow: hidden;
+
+                image {
+                    width: 100%;
+                    height: 100%;
+                    object-fit: cover;
+                }
+            }
+
+            .me-header-info {
+                .me-header-name {
+                    font-weight: 500;
+                    font-size: 30rpx;
+                    color: #ffffff;
+                }
+            }
         }
-        .me-header-tips-item-des {
-          font-weight: 400;
-          font-size: 24rpx;
-          color: #ffffff;
+
+        .me-header-tips {
+            display: flex;
+            margin-top: 49rpx;
+
+            .me-header-tips-item {
+                flex: 1;
+                display: flex;
+                flex-direction: column;
+                justify-content: center;
+                align-items: center;
+                gap: 15rpx;
+                font-weight: 500;
+                font-size: 34rpx;
+                color: #ffffff;
+                line-height: 1;
+
+                .me-header-tips-item-num {
+                    font-weight: bold;
+                }
+
+                .me-header-tips-item-des {
+                    font-weight: 400;
+                    font-size: 24rpx;
+                    color: #ffffff;
+                }
+            }
         }
-      }
     }
-  }
-  .me-header-menu {
-    background: #ffffff;
-    border-radius: 10rpx 10rpx 0rpx 0rpx;
-    margin: -50rpx 24rpx 0;
-    padding: 0 20rpx;
-    .me-header-menu-item {
-      height: 88rpx;
-      display: flex;
-      justify-content: space-between;
-      align-items: center;
-      border-bottom: 1px solid #eeeeee;
-      &:last-child {
-        border-bottom: none;
-      }
-      .me-header-menu-icon {
-        display: flex;
-        justify-content: center;
-        align-items: center;
-        gap: 13rpx;
-        image {
-          width: 40rpx;
-          height: 40rpx;
-        }
-        .me-header-menu-text {
-          font-weight: 400;
-          font-size: 26rpx;
-          color: #333333;
+
+    .me-header-menu {
+        background: #ffffff;
+        border-radius: 10rpx 10rpx 0rpx 0rpx;
+        margin: -50rpx 24rpx 0;
+        padding: 0 20rpx;
+
+        .me-header-menu-item {
+            height: 88rpx;
+            display: flex;
+            justify-content: space-between;
+            align-items: center;
+            border-bottom: 1px solid #eeeeee;
+
+            &:last-child {
+                border-bottom: none;
+            }
+
+            .me-header-menu-icon {
+                display: flex;
+                justify-content: center;
+                align-items: center;
+                gap: 13rpx;
+
+                image {
+                    width: 40rpx;
+                    height: 40rpx;
+                }
+
+                .me-header-menu-text {
+                    font-weight: 400;
+                    font-size: 26rpx;
+                    color: #333333;
+                }
+            }
+
+            .me-header-menu-left {}
         }
-      }
-      .me-header-menu-left {
-      }
     }
-  }
+}
+
+/* 昵称输入框样式 */
+.nickname-input {
+    width: 100%;
+    height: 100%;
+    font-weight: 500;
+    font-size: 30rpx;
+    color: #ffffff;
+    background: transparent;
+    border: none;
+    outline: none;
+    text-align: center;
 }
 </style>

+ 13 - 4
src/store/user.ts

@@ -26,11 +26,21 @@ export const useUserStore = defineStore(
                 val.avatar = userInfoState.avatar
             }
             userInfo.value = val
+            // 直接更新本地存储(无论本地是否已有用户信息)
+            const currentUser = uni.getStorageSync('user')
+            const updatedUser = currentUser ? { ...currentUser, ...val } : val
+            uni.setStorageSync('user', updatedUser)
+            console.log('本地存储用户信息已更新', updatedUser)
         }
         const setUserAvatar = (avatar: string) => {
             userInfo.value.avatar = avatar
             console.log('设置用户头像', avatar)
             console.log('userInfo', userInfo.value)
+            // 直接更新本地存储(无论本地是否已有用户信息)
+            const currentUser = uni.getStorageSync('user')
+            const updatedUser = currentUser ? { ...currentUser, avatar } : { ...userInfo.value }
+            uni.setStorageSync('user', updatedUser)
+            console.log('本地存储用户头像已更新', updatedUser)
         }
         // 删除用户信息
         const clearUserInfo = () => {
@@ -39,11 +49,10 @@ export const useUserStore = defineStore(
         }
 
         /**
-             * 获取用户信息
-             */
+                                 * 获取用户信息
+                                 */
         const fetchUserInfo = async () => {
-            const res = await getUserInfo()
-            setUserInfo(res)
+            const res = JSON.parse(uni.getStorageSync('user'))
             return res
         }