소스 검색

fix: 退出登录时清除用户信息

- 修改config.js中PAYMENT_TYPE默认值为wechat
- 移除Recharge.vue中从localStorage获取用户信息的冗余代码
- 优化退出登录时清除的用户信息字段
- 格式化代码结构提升可读性
wangxl 1 주 전
부모
커밋
01234686f1
2개의 변경된 파일317개의 추가작업 그리고 217개의 파일을 삭제
  1. 1 1
      src/utils/config.js
  2. 316 216
      src/views/Recharge.vue

+ 1 - 1
src/utils/config.js

@@ -7,7 +7,7 @@ export const API_BASE_URL = isDev
   : "https://gbyy91.com/api"; // 生产环境
 
 // 支付方式切换参数 ('wechat' | 'alipay')
-export const PAYMENT_TYPE = "alipay";
+export const PAYMENT_TYPE = "wechat";
 
 // 支付宝支付自定义金额模块开关
 export const ALI_CUSTOM = false;

+ 316 - 216
src/views/Recharge.vue

@@ -5,7 +5,11 @@
       <div class="header-content">
         <div class="logo-wrapper">
           <div class="logo-container">
-            <img src="@/assets/images/logo.png" alt="告白语音" class="logo-image" />
+            <img
+              src="@/assets/images/logo.png"
+              alt="告白语音"
+              class="logo-image"
+            />
           </div>
         </div>
       </div>
@@ -23,18 +27,30 @@
           </div>-->
         </div>
         <div class="user-details">
-          <div class="user-name">{{ userInfo.nickname || '未知用户' }}</div>
+          <div class="user-name">{{ userInfo.nickname || "未知用户" }}</div>
           <div class="user-id">
             <img src="@/assets/images/id.png" alt="ID" class="id-icon" />
-            <span>{{ userInfo.id || '未知ID' }}</span>
+            <span>{{ userInfo.id || "未知ID" }}</span>
           </div>
         </div>
         <div class="action-buttons">
-          <van-button v-if="canExchange === 'true'" type="primary" size="small" round @click="goToCoinExchange"
-            class="action-btn">
+          <van-button
+            v-if="canExchange === 'true'"
+            type="primary"
+            size="small"
+            round
+            @click="goToCoinExchange"
+            class="action-btn"
+          >
             金币兑换
           </van-button>
-          <van-button type="primary" size="small" round @click="logout" class="action-btn logout-btn">
+          <van-button
+            type="primary"
+            size="small"
+            round
+            @click="logout"
+            class="action-btn logout-btn"
+          >
             退出登录
           </van-button>
         </div>
@@ -46,10 +62,19 @@
       <h2 class="section-title">充值金额</h2>
 
       <div class="recharge-grid">
-        <div v-for="(item, index) in rechargeOptionsWithCustom" :key="index" class="recharge-item"
-          :class="{ active: selectedRecharge === index }" @click="selectRecharge(index)">
+        <div
+          v-for="(item, index) in rechargeOptionsWithCustom"
+          :key="index"
+          class="recharge-item"
+          :class="{ active: selectedRecharge === index }"
+          @click="selectRecharge(index)"
+        >
           <div class="diamond-icon">
-            <img src="@/assets/images/recharge_zuanshi.png" alt="钻石" class="diamond-img" />
+            <img
+              src="@/assets/images/recharge_zuanshi.png"
+              alt="钻石"
+              class="diamond-img"
+            />
           </div>
           <template v-if="!item.isCustom">
             <div class="recharge-amount">{{ item.amount }}</div>
@@ -63,7 +88,13 @@
       </div>
 
       <div v-if="isCustomSelected" class="custom-input">
-        <van-field v-model="customAmount" type="number" input-align="center" placeholder="请输入自定义金额(元)" clearable />
+        <van-field
+          v-model="customAmount"
+          type="number"
+          input-align="center"
+          placeholder="请输入自定义金额(元)"
+          clearable
+        />
       </div>
     </div>
 
@@ -71,7 +102,11 @@
     <div class="payment-section">
       <div v-if="paymentType === 'alipay'" class="payment-option">
         <div class="payment-icon">
-          <img src="@/assets/images/recharge_paypal.png" alt="支付宝支付" class="alipay-icon" />
+          <img
+            src="@/assets/images/recharge_paypal.png"
+            alt="支付宝支付"
+            class="alipay-icon"
+          />
         </div>
         <div class="payment-name">支付宝支付</div>
         <div class="payment-selected">
@@ -80,7 +115,11 @@
       </div>
       <div v-if="paymentType === 'wechat'" class="payment-option">
         <div class="payment-icon">
-          <img src="@/assets/images/recharge_wechat.png" alt="微信支付" class="wechat-icon" />
+          <img
+            src="@/assets/images/recharge_wechat.png"
+            alt="微信支付"
+            class="wechat-icon"
+          />
         </div>
         <div class="payment-name">微信支付</div>
         <div class="payment-selected">
@@ -93,35 +132,62 @@
     <div class="tips-section">
       <div class="tips-title">温馨提示:</div>
       <div class="tips-content">
-        <div class="tip-item">1. 充值前请确定您已满18周岁并具有完全民事行为能力。</div>
-        <div class="tip-item">2. 安全账号转账、理赔转账、刷单、代充均为骗局,请认真核实并确认</div>
-        <div class="tip-item" v-if="paymentType === 'wechat'">3. 大额充值,支付方式可选择"零钱通"</div>
-        <div class="tip-item" v-if="paymentType === 'alipay'">3. 大额充值,请确保支付宝账户余额充足</div>
+        <div class="tip-item">
+          1. 充值前请确定您已满18周岁并具有完全民事行为能力。
+        </div>
+        <div class="tip-item">
+          2. 安全账号转账、理赔转账、刷单、代充均为骗局,请认真核实并确认
+        </div>
+        <div class="tip-item" v-if="paymentType === 'wechat'">
+          3. 大额充值,支付方式可选择"零钱通"
+        </div>
+        <div class="tip-item" v-if="paymentType === 'alipay'">
+          3. 大额充值,请确保支付宝账户余额充足
+        </div>
         <div class="tip-item">4. 如有疑问,请联系服务号客服</div>
       </div>
 
       <!-- 协议勾选 -->
       <div class="agreement-checkbox" @click="toggleAgreement">
         <div class="checkbox-wrapper" :class="{ checked: agreementChecked }">
-          <van-icon v-if="agreementChecked" name="success" size="14" color="#fff" />
+          <van-icon
+            v-if="agreementChecked"
+            name="success"
+            size="14"
+            color="#fff"
+          />
         </div>
         <div class="agreement-text">
-          我已阅读并同意 <span class="agreement-link" @click.stop="showAgreement">《用户充值协议》</span>
+          我已阅读并同意
+          <span class="agreement-link" @click.stop="showAgreement"
+            >《用户充值协议》</span
+          >
         </div>
       </div>
     </div>
 
     <!-- 支付按钮 -->
     <div class="pay-button">
-      <van-button type="primary" block round @click="confirmPay">确认支付</van-button>
+      <van-button type="primary" block round @click="confirmPay"
+        >确认支付</van-button
+      >
     </div>
 
     <!-- 协议弹框 -->
-    <van-dialog v-model="agreementVisible" title="用户充值协议" confirm-button-text="我已阅读" @confirm="agreementChecked = true"
-      :show-cancel-button="false">
+    <van-dialog
+      v-model="agreementVisible"
+      title="用户充值协议"
+      confirm-button-text="我已阅读"
+      @confirm="agreementChecked = true"
+      :show-cancel-button="false"
+    >
       <div class="agreement-content">
-        <iframe v-if="agreementVisible" src="https://gbyy91.com/agreement/recharge.html" frameborder="0"
-          class="agreement-iframe"></iframe>
+        <iframe
+          v-if="agreementVisible"
+          src="https://gbyy91.com/agreement/recharge.html"
+          frameborder="0"
+          class="agreement-iframe"
+        ></iframe>
       </div>
     </van-dialog>
   </div>
@@ -129,130 +195,138 @@
 
 <script>
 // eslint-disable-next-line no-undef
-import { getProductList } from '@/api/product'
-import { getUserInfo } from '@/api/user'
-import { aliPayCoin, aliPayH5 } from '@/api/pay'
-import { ahtuCodeApi, wechatPayCoin, wxPay } from '@/api/pay'
-import { getDevicePayWayId, getPlatformType, ALI_CUSTOM, PAYMENT_TYPE } from '@/utils/config'
+import { getProductList } from "@/api/product";
+import { getUserInfo } from "@/api/user";
+import { aliPayCoin, aliPayH5 } from "@/api/pay";
+import { ahtuCodeApi, wechatPayCoin, wxPay } from "@/api/pay";
+import {
+  getDevicePayWayId,
+  getPlatformType,
+  ALI_CUSTOM,
+  PAYMENT_TYPE,
+} from "@/utils/config";
 
 export default {
-  name: 'RechargePage',
+  name: "RechargePage",
   data() {
     return {
       resultDataMess: {},
-      userCode: '', // 用于微信支付
-      userInfo: { // 用于支付宝支付
-        id: '',
-        nickname: '',
-        avatar: ''
+      userCode: "", // 用于微信支付
+      userInfo: {
+        // 用于支付宝支付
+        id: "",
+        nickname: "",
+        avatar: "",
       },
       rechargeOptions: [],
       selectedRecharge: 0,
-      paymentMethod: 'alipay',
+      paymentMethod: "alipay",
       isLoading: false,
       agreementChecked: false,
       agreementVisible: false,
       // 自定义金额
-      customAmount: '',
+      customAmount: "",
       // 支付方式类型
       paymentType: PAYMENT_TYPE,
       // 金币兑换权限
-      canExchange: localStorage.getItem('canExchange') || 'false'
-    }
+      canExchange: localStorage.getItem("canExchange") || "false",
+    };
   },
   computed: {
     selectedRechargeOption() {
-      return this.rechargeOptionsWithCustom[this.selectedRecharge] || null
+      return this.rechargeOptionsWithCustom[this.selectedRecharge] || null;
     },
     // 显示列表 = 产品列表 + 自定义
     rechargeOptionsWithCustom() {
-      if (ALI_CUSTOM && this.paymentType === 'alipay') {
-        return [...(this.rechargeOptions || []), { isCustom: true }]
+      if (ALI_CUSTOM && this.paymentType === "alipay") {
+        return [...(this.rechargeOptions || []), { isCustom: true }];
       } else {
-        return [...(this.rechargeOptions || [])]
+        return [...(this.rechargeOptions || [])];
       }
     },
     // 是否选择了自定义
     isCustomSelected() {
-      return this.selectedRecharge === this.rechargeOptionsWithCustom.length - 1
-    }
+      return (
+        this.selectedRecharge === this.rechargeOptionsWithCustom.length - 1
+      );
+    },
   },
   created() {
     // 获取用户信息
-    this.initUserInfo()
+    this.initUserInfo();
     // 获取产品列表
-    this.fetchProductList()
-    if (this.paymentType === 'wechat') {
-      this.listenWeixinBridge() // 监听桥梁加载
+    this.fetchProductList();
+    if (this.paymentType === "wechat") {
+      this.listenWeixinBridge(); // 监听桥梁加载
     }
   },
   methods: {
     // 初始化用户信息
     async initUserInfo() {
       // 从路由参数获取用户信息
-      const { id, nickname, avatar } = this.$route.query
-      if (this.paymentType === 'wechat') {
-        this.userCode = this.$route.query.userCode
+      const { id, nickname, avatar } = this.$route.query;
+      if (this.paymentType === "wechat") {
+        this.userCode = this.$route.query.userCode;
       }
       if (id) {
         // 如果路由参数中有用户ID,直接使用
-        this.userInfo.id = id
-        this.userInfo.nickname = nickname || '未知用户'
-        this.userInfo.avatar = avatar || ''
+        this.userInfo.id = id;
+        this.userInfo.nickname = nickname || "未知用户";
+        this.userInfo.avatar = avatar || "";
       } else {
         // 如果没有用户ID,尝试从本地存储获取
-        const savedUserId = localStorage.getItem('lastUserId')
-        if (savedUserId) {
-          try {
-            // 从API获取用户信息
-            const res = await getUserInfo(savedUserId)
-            if (res.data && res.data.userId) {
-              this.userInfo.id = res.data.userId
-              this.userInfo.nickname = res.data.userName || '未知用户'
-              this.userInfo.avatar = res.data.avatar || ''
-            } else {
-              this.$toast('未找到用户信息')
-              this.$router.replace('/')
-            }
-          } catch (error) {
-            console.error('获取用户信息失败:', error)
-            this.$toast('获取用户信息失败')
-            this.$router.replace('/')
-          }
-        } else {
-          // 没有用户ID,返回搜索页面
-          this.$toast('请先登录')
-          this.$router.replace('/')
-        }
+        // const savedUserId = localStorage.getItem('lastUserId')
+        // if (savedUserId) {
+        //   try {
+        //     // 从API获取用户信息
+        //     const res = await getUserInfo(savedUserId)
+        //     if (res.data && res.data.userId) {
+        //       this.userInfo.id = res.data.userId
+        //       this.userInfo.nickname = res.data.userName || '未知用户'
+        //       this.userInfo.avatar = res.data.avatar || ''
+        //     } else {
+        //       this.$toast('未找到用户信息')
+        //       this.$router.replace('/')
+        //     }
+        //   } catch (error) {
+        //     console.error('获取用户信息失败:', error)
+        //     this.$toast('获取用户信息失败')
+        //     this.$router.replace('/')
+        //   }
+        // } else {
+        // 没有用户ID,返回搜索页面
+        this.$toast("请先登录");
+        this.$router.replace("/");
+        // }
       }
 
       // 保存最后使用的用户ID
-      if (this.userInfo.id) {
-        localStorage.setItem('lastUserId', this.userInfo.id)
-      }
+      // if (this.userInfo.id) {
+      //   localStorage.setItem("lastUserId", this.userInfo.id);
+      // }
     },
     // 监听 weixinJSBridge 加载
     listenWeixinBridge() {
       if (window.WeixinJSBridge) {
-        this.onWeixinBridgeReady()
+        this.onWeixinBridgeReady();
       } else {
-        const listener = () => this.onWeixinBridgeReady()
-        document.addEventListener('WeixinJSBridgeReady', listener, false)
+        const listener = () => this.onWeixinBridgeReady();
+        document.addEventListener("WeixinJSBridgeReady", listener, false);
       }
     },
     // weixinJSBridge 加载成功回调
     onWeixinBridgeReady() {
-      this.bridgeReady = true
-      console.log('weixinJSBridge 加载成功')
+      this.bridgeReady = true;
+      console.log("weixinJSBridge 加载成功");
     },
     // 获取产品列表
     async fetchProductList() {
       try {
-        const payWayId = getDevicePayWayId()
-        const res = await getProductList(payWayId)
-        this.rechargeOptions = res.data || []
+        const payWayId = getDevicePayWayId();
+        const res = await getProductList(payWayId);
+        this.rechargeOptions = res.data || [];
       } catch (error) {
-        console.error('获取产品列表失败:', error)
+        console.error("获取产品列表失败:", error);
         // 设置默认数据,以防接口调用失败
         this.rechargeOptions = [
           { amount: 60, price: 6 },
@@ -263,54 +337,59 @@ export default {
           { amount: 2000, price: 6 },
           { amount: 3800, price: 6 },
           { amount: 5000, price: 6 },
-          { amount: 10000, price: 6 }
-        ]
+          { amount: 10000, price: 6 },
+        ];
       }
     },
     selectRecharge(index) {
-      this.selectedRecharge = index
+      this.selectedRecharge = index;
     },
     // 切换用户
     switchUser() {
-      this.$router.push('/')
+      this.$router.push("/");
     },
     // 切换协议勾选状态
     toggleAgreement() {
-      this.agreementChecked = !this.agreementChecked
+      this.agreementChecked = !this.agreementChecked;
     },
     // 显示协议弹框
     showAgreement() {
-      this.agreementVisible = true
+      this.agreementVisible = true;
     },
     confirmPay() {
-      if (this.isLoading) return // 防止重复点击
+      if (this.isLoading) return; // 防止重复点击
 
       if (!this.userInfo.id) {
-        this.$toast('请先选择用户')
-        return
+        this.$toast("请先选择用户");
+        return;
       }
 
       // 检查协议是否勾选
       if (!this.agreementChecked) {
-        this.$toast('请阅读并同意充值协议')
-        return
+        this.$toast("请阅读并同意充值协议");
+        return;
       }
 
       // 自定义金额校验
       if (this.isCustomSelected) {
-        const amountNumber = Number(this.customAmount)
-        if (!this.customAmount || Number.isNaN(amountNumber) || amountNumber <= 0) {
-          this.$toast('请输入有效的自定义金额')
-          return
+        const amountNumber = Number(this.customAmount);
+        if (
+          !this.customAmount ||
+          Number.isNaN(amountNumber) ||
+          amountNumber <= 0
+        ) {
+          this.$toast("请输入有效的自定义金额");
+          return;
         }
       }
 
-      const selectedOption = this.selectedRechargeOption
+      const selectedOption = this.selectedRechargeOption;
 
       // 使用二次确认弹窗
-      this.$dialog.confirm({
-        title: '支付确认',
-        message: `
+      this.$dialog
+        .confirm({
+          title: "支付确认",
+          message: `
           <div class="confirm-dialog-content">
             <div class="confirm-tip">请核实并确认ID是否正确,请提防:</div>
             <div class="warning-list">
@@ -322,209 +401,230 @@ export default {
             </div>
           </div>
         `,
-        confirmButtonText: '确认支付',
-        cancelButtonText: '取消',
-        showCancelButton: true,
-        showConfirmButton: true,
-        allowHtml: true
-      }).then(() => {
-        // 调用支付接口
-        if (this.paymentType === 'wechat') {
-          this.requestWechatPay(selectedOption)
-        } else {
-          this.requestAliPay(selectedOption)
-        }
-      }).catch(() => {
-        // 取消支付
-      })
+          confirmButtonText: "确认支付",
+          cancelButtonText: "取消",
+          showCancelButton: true,
+          showConfirmButton: true,
+          allowHtml: true,
+        })
+        .then(() => {
+          // 调用支付接口
+          if (this.paymentType === "wechat") {
+            this.requestWechatPay(selectedOption);
+          } else {
+            this.requestAliPay(selectedOption);
+          }
+        })
+        .catch(() => {
+          // 取消支付
+        });
     },
 
     // 请求支付宝支付
     async requestAliPay(product) {
       // 显示加载提示
-      this.isLoading = true
+      this.isLoading = true;
       this.$toast.loading({
-        message: '正在发起支付...',
+        message: "正在发起支付...",
         forbidClick: true,
-        duration: 0
-      })
+        duration: 0,
+      });
 
       try {
         // 获取平台类型
-        const platform = getPlatformType()
+        const platform = getPlatformType();
 
         // 构建支付参数
         const payData = {
           userId: this.userInfo.id,
-          productId: product && product.isCustom ? 1018 : product.id
-        }
+          productId: product && product.isCustom ? 1018 : product.id,
+        };
 
         // 自定义金额时追加 amount
         if (product && product.isCustom) {
-          payData.amount = Number(this.customAmount)
+          payData.amount = Number(this.customAmount);
         }
 
         // 调用支付宝H5支付接口
-        const res = await aliPayH5(payData, platform)
-        this.$toast.clear()
-        this.isLoading = false
+        const res = await aliPayH5(payData, platform);
+        this.$toast.clear();
+        this.isLoading = false;
 
         // 优先尝试解析服务端 JSON 错误并提示
         try {
-          if (typeof res === 'string') {
-            const trimmed = res.trim()
-            if (trimmed.startsWith('{') || trimmed.startsWith('[')) {
-              const json = JSON.parse(trimmed)
-              if (json && typeof json === 'object' && json.code !== undefined && json.code !== 200) {
-                this.$toast.fail(json.message || '支付请求失败')
-                return
+          if (typeof res === "string") {
+            const trimmed = res.trim();
+            if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
+              const json = JSON.parse(trimmed);
+              if (
+                json &&
+                typeof json === "object" &&
+                json.code !== undefined &&
+                json.code !== 200
+              ) {
+                this.$toast.fail(json.message || "支付请求失败");
+                return;
               }
             }
-          } else if (res && typeof res === 'object' && res.code !== undefined && res.code !== 200) {
-            this.$toast.fail(res.message || '支付请求失败')
-            return
+          } else if (
+            res &&
+            typeof res === "object" &&
+            res.code !== undefined &&
+            res.code !== 200
+          ) {
+            this.$toast.fail(res.message || "支付请求失败");
+            return;
           }
         } catch (e) {
           // 忽略解析错误,继续后续流程
         }
 
         // 处理HTML表单响应
-        if (typeof res === 'string' && res.includes('<form')) {
+        if (typeof res === "string" && res.includes("<form")) {
           // 创建一个div来放置表单
-          const div = document.createElement('div')
-          div.innerHTML = res
-          document.body.appendChild(div)
+          const div = document.createElement("div");
+          div.innerHTML = res;
+          document.body.appendChild(div);
 
           // 自动提交表单
           setTimeout(() => {
-            const form = div.querySelector('form')
+            const form = div.querySelector("form");
             if (form) {
-              form.submit()
+              form.submit();
             } else {
-              this.$toast.fail('支付表单加载失败')
+              this.$toast.fail("支付表单加载失败");
             }
-          }, 100)
+          }, 100);
         } else {
-          this.$toast.fail('获取支付表单失败')
+          this.$toast.fail("获取支付表单失败");
         }
       } catch (error) {
-        this.$toast.clear()
-        this.isLoading = false
-        console.error('支付请求失败:', error)
-        this.$toast.fail('支付请求失败,请重试')
+        this.$toast.clear();
+        this.isLoading = false;
+        console.error("支付请求失败:", error);
+        this.$toast.fail("支付请求失败,请重试");
       }
     },
 
     // 请求微信支付
     async requestWechatPay(product) {
       // 显示加载提示
-      this.isLoading = true
+      this.isLoading = true;
       this.$toast.loading({
-        message: '正在发起支付...',
+        message: "正在发起支付...",
         forbidClick: true,
-        duration: 0
-      })
+        duration: 0,
+      });
 
       try {
         // 构建支付参数
-        const payWayId = getDevicePayWayId() // 获取设备对应的支付方式ID
+        const payWayId = getDevicePayWayId(); // 获取设备对应的支付方式ID
         const payData = {
-          "productName": "一号房间",
-          openId: localStorage.getItem('userOpenId'),
+          productName: "一号房间",
+          openId: localStorage.getItem("userOpenId"),
           userId: this.userInfo.id,
           productId: product.id,
           amount: product.price,
           orderNo: Date.now(),
-          payWayId: payWayId // 添加支付方式ID
-        }
+          payWayId: payWayId, // 添加支付方式ID
+        };
 
         // 调用后端支付接口
-        const res = await wxPay(payData)
-        console.log(res, 9999)
-        this.$toast.clear()
-        this.isLoading = false
+        const res = await wxPay(payData);
+        this.$toast.clear();
+        this.isLoading = false;
 
         // 处理支付结果
         if (res.status == 200) {
           try {
-            let signData = JSON.parse(res.data.outputJSON)
-            this.resultDataMess = signData
-            console.log(signData, 'signData')
-            let wxJsapiParam = signData.wxJsapiParam
-            if (signData.returnCode == '0000') {
+            let signData = JSON.parse(res.data.outputJSON);
+            this.resultDataMess = signData;
+            console.log(signData, "signData");
+            let wxJsapiParam = signData.wxJsapiParam;
+            if (signData.returnCode == "0000") {
               // 5. 调用 weixinJSBridge 支付
-              this.invokeWeixinBridgePayment(wxJsapiParam)
+              this.invokeWeixinBridgePayment(wxJsapiParam);
             } else {
-              this.$toast.fail(this.resultDataMess.returnMsg || '获取支付链接失败')
+              this.$toast.fail(
+                this.resultDataMess.returnMsg || "获取支付链接失败"
+              );
             }
           } catch {
-            this.$toast.fail(this.resultDataMess.returnMsg || '获取支付链接失败')
+            this.$toast.fail(
+              this.resultDataMess.returnMsg || "获取支付链接失败"
+            );
           }
         } else {
-          this.$toast.fail(this.resultDataMess.returnMsg || '获取支付链接失败')
+          this.$toast.fail(this.resultDataMess.returnMsg || "获取支付链接失败");
         }
       } catch (error) {
-        this.$toast.clear()
-        this.isLoading = false
-        console.error('支付请求失败:', error)
-        this.$toast.fail('支付请求失败,请重试')
+        this.$toast.clear();
+        this.isLoading = false;
+        console.error("支付请求失败:", error);
+        this.$toast.fail("支付请求失败,请重试");
       }
     },
     // 调用 weixinJSBridge 支付
     invokeWeixinBridgePayment(payParams) {
       window.WeixinJSBridge.invoke(
-        'getBrandWCPayRequest',
+        "getBrandWCPayRequest",
         payParams,
         this.handleWeixinPayResult
-      )
+      );
     },
     // 处理支付结果
     handleWeixinPayResult(res) {
       if (res.err_msg === "get_brand_wcpay_request:ok") {
         // 支付成功
-        this.handlePaymentSuccess(res)
+        this.handlePaymentSuccess(res);
       } else if (res.err_msg === "get_brand_wcpay_request:cancel") {
         // 支付取消
-        this.handlePaymentCancel()
+        this.handlePaymentCancel();
       } else {
         // 支付失败
-        this.handlePaymentFailure(res)
+        this.handlePaymentFailure(res);
       }
     },
 
     // 处理支付成功
     handlePaymentSuccess() {
-      console.log('支付成功')
-      this.$toast.success('支付成功')
-      window.location.href = 'https://gbyy91.com/pay'
+      console.log("支付成功");
+      this.$toast.success("支付成功");
+      window.location.href = "https://gbyy91.com/pay";
     },
 
     // 处理支付失败
     handlePaymentFailure(message) {
-      console.error('支付失败:', message)
-      this.$toast.fail(message || '支付失败,请重试')
+      console.error("支付失败:", message);
+      this.$toast.fail(message || "支付失败,请重试");
     },
 
     // 处理支付取消
     handlePaymentCancel() {
-      console.log('用户取消支付')
-      this.$toast('支付已取消')
+      console.log("用户取消支付");
+      this.$toast("支付已取消");
     },
 
     // 金币兑换
     goToCoinExchange() {
-      this.$router.push('/coin-exchange')
+      this.$router.push("/coin-exchange");
     },
 
     // 退出登录
     logout() {
       // 清除本地存储的用户信息
-      localStorage.removeItem('lastUserId')
+      // localStorage.removeItem("lastUserId");
+      localStorage.removeItem("userId");
+      localStorage.removeItem("userName");
+      localStorage.removeItem("avatar");
+      localStorage.removeItem("token");
+      localStorage.removeItem("integral");
+      localStorage.removeItem("canExchange");
       // 跳转到搜索页面
-      this.$router.push('/')
-    }
-  }
-}
+      this.$router.push("/");
+    },
+  },
+};
 </script>
 
 <style scoped>
@@ -532,7 +632,7 @@ export default {
   min-height: 100vh;
   display: flex;
   flex-direction: column;
-  background-color: #F5F7FA;
+  background-color: #f5f7fa;
   padding-bottom: 10px;
   position: relative;
   overflow: hidden;
@@ -616,7 +716,7 @@ export default {
   display: flex;
   align-items: center;
   justify-content: center;
-  border: 2px solid #F5EEFF;
+  border: 2px solid #f5eeff;
 }
 
 .user-details {
@@ -635,7 +735,7 @@ export default {
   color: #666;
   display: flex;
   align-items: center;
-  background-color: #F5F5F5;
+  background-color: #f5f5f5;
   padding: 2px 8px;
   border-radius: 12px;
   display: inline-flex;
@@ -648,7 +748,7 @@ export default {
 }
 
 .switch-account-btn {
-  background-color: #B66FFF;
+  background-color: #b66fff;
   color: white;
   padding: 6px 12px;
   border-radius: 16px;
@@ -687,7 +787,7 @@ export default {
 }
 
 .recharge-item {
-  background-color: #F0F0F0;
+  background-color: #f0f0f0;
   border-radius: 8px;
   padding: 8px 8px;
   display: flex;
@@ -695,14 +795,14 @@ export default {
   align-items: center;
   cursor: pointer;
   transition: all 0.2s ease;
-  border: 1px solid #DDDDDD;
+  border: 1px solid #dddddd;
   position: relative;
   overflow: hidden;
 }
 
 .recharge-item.active {
-  background-color: #F5EEFF;
-  border: 1px solid #B66FFF;
+  background-color: #f5eeff;
+  border: 1px solid #b66fff;
   transform: scale(1.02);
   box-shadow: 0 2px 8px rgba(182, 111, 255, 0.2);
 }
@@ -716,7 +816,7 @@ export default {
   height: 0;
   border-style: solid;
   border-width: 0 20px 20px 0;
-  border-color: transparent #B66FFF transparent transparent;
+  border-color: transparent #b66fff transparent transparent;
 }
 
 .recharge-item.active:after {
@@ -769,7 +869,7 @@ export default {
   display: flex;
   align-items: center;
   padding: 8px;
-  border-bottom: 1px solid #EAEAEA;
+  border-bottom: 1px solid #eaeaea;
 }
 
 .payment-icon {
@@ -852,8 +952,8 @@ export default {
 }
 
 .checkbox-wrapper.checked {
-  background-color: #B66FFF;
-  border-color: #B66FFF;
+  background-color: #b66fff;
+  border-color: #b66fff;
 }
 
 .agreement-text {
@@ -862,7 +962,7 @@ export default {
 }
 
 .agreement-link {
-  color: #B66FFF;
+  color: #b66fff;
   text-decoration: none;
 }
 
@@ -887,7 +987,7 @@ export default {
 }
 
 .pay-button .van-button {
-  background-color: #B66FFF;
+  background-color: #b66fff;
   border: none;
   height: 38px;
   font-size: 15px;
@@ -986,4 +1086,4 @@ export default {
   color: #f44336;
   font-weight: normal;
 }
-</style>
+</style>