2 次代码提交 39568938fc ... c94491dfc4

作者 SHA1 备注 提交日期
  mht c94491dfc4 自定义金额默认关闭 1 周之前
  mht a228005e4c Revert "兑换remove 自定义金额" 1 周之前
共有 3 个文件被更改,包括 30 次插入41 次删除
  1. 1 1
      src/utils/config.js
  2. 15 21
      src/views/Recharge.vue
  3. 14 19
      src/views/Search.vue

+ 1 - 1
src/utils/config.js

@@ -10,7 +10,7 @@ export const API_BASE_URL = isDev
 export const PAYMENT_TYPE = "alipay";
 
 // 支付宝支付自定义金额模块开关
-export const ALI_CUSTOM = true;
+export const ALI_CUSTOM = false;
 
 // 支付方式ID
 export const PAY_WAY_ID = {

+ 15 - 21
src/views/Recharge.vue

@@ -51,23 +51,20 @@
           <div class="diamond-icon">
             <img src="@/assets/images/recharge_zuanshi.png" alt="钻石" class="diamond-img" />
           </div>
-          <!-- 注释掉自定义金额相关显示 -->
-          <!-- <template v-if="!item.isCustom"> -->
+          <template v-if="!item.isCustom">
             <div class="recharge-amount">{{ item.amount }}</div>
             <div class="recharge-price">¥{{ item.price }}</div>
-          <!-- </template>
+          </template>
           <template v-else>
             <div class="recharge-amount">自定义金额</div>
             <div class="recharge-price">点击输入</div>
-          </template> -->
+          </template>
         </div>
       </div>
 
-      <!-- 注释掉自定义金额输入框
       <div v-if="isCustomSelected" class="custom-input">
         <van-field v-model="customAmount" type="number" input-align="center" placeholder="请输入自定义金额(元)" clearable />
       </div>
-      -->
     </div>
 
     <!-- 支付方式 -->
@@ -155,8 +152,8 @@ export default {
       isLoading: false,
       agreementChecked: false,
       agreementVisible: false,
-      // 自定义金额 - 已注释功能
-      // customAmount: '',
+      // 自定义金额
+      customAmount: '',
       // 支付方式类型
       paymentType: PAYMENT_TYPE,
       // 金币兑换权限
@@ -169,18 +166,15 @@ export default {
     },
     // 显示列表 = 产品列表 + 自定义
     rechargeOptionsWithCustom() {
-      // 注释掉自定义金额功能
-      /* if (ALI_CUSTOM && this.paymentType === 'alipay') {
+      if (ALI_CUSTOM && this.paymentType === 'alipay') {
         return [...(this.rechargeOptions || []), { isCustom: true }]
-      } else { */
+      } else {
         return [...(this.rechargeOptions || [])]
-      // }
+      }
     },
     // 是否选择了自定义
     isCustomSelected() {
-      // 注释掉自定义金额功能
-      // return this.selectedRecharge === this.rechargeOptionsWithCustom.length - 1
-      return false
+      return this.selectedRecharge === this.rechargeOptionsWithCustom.length - 1
     }
   },
   created() {
@@ -303,13 +297,13 @@ export default {
       }
 
       // 自定义金额校验
-      /* if (this.isCustomSelected) {
+      if (this.isCustomSelected) {
         const amountNumber = Number(this.customAmount)
         if (!this.customAmount || Number.isNaN(amountNumber) || amountNumber <= 0) {
           this.$toast('请输入有效的自定义金额')
           return
         }
-      } */
+      }
 
       const selectedOption = this.selectedRechargeOption
 
@@ -362,13 +356,13 @@ export default {
         // 构建支付参数
         const payData = {
           userId: this.userInfo.id,
-          productId: product ? product.id : null
+          productId: product && product.isCustom ? 1018 : product.id
         }
 
-        // 自定义金额时追加 amount - 注释掉自定义金额功能
-        /* if (product && product.isCustom) {
+        // 自定义金额时追加 amount
+        if (product && product.isCustom) {
           payData.amount = Number(this.customAmount)
-        } */
+        }
 
         // 调用支付宝H5支付接口
         const res = await aliPayH5(payData, platform)

+ 14 - 19
src/views/Search.vue

@@ -40,24 +40,21 @@
           <div class="diamond-icon">
             <img src="@/assets/images/recharge_zuanshi.png" alt="钻石" class="diamond-img" />
           </div>
-          <!-- 注释掉自定义金额相关显示 -->
-          <!-- <template v-if="!item.isCustom"> -->
+          <template v-if="!item.isCustom">
             <div class="recharge-amount">{{ item.amount }}</div>
             <div class="recharge-price">¥{{ item.price }}</div>
-          <!-- </template>
+          </template>
           <template v-else>
             <div class="recharge-amount">自定义金额</div>
             <div class="recharge-price">点击输入</div>
-          </template> -->
+          </template>
         </div>
       </div>
 
-      <!-- 注释掉自定义金额输入框
       <div v-if="isCustomSelected" class="custom-input">
         <van-field v-model="customAmount" type="number" input-align="center" placeholder="请输入自定义金额(元)" clearable
           :disabled="!isLoggedIn" />
       </div>
-      -->
     </div>
 
     <!-- 支付方式 -->
@@ -135,8 +132,8 @@ export default {
       paymentMethod: 'alipay',
       agreementChecked: false,
       agreementVisible: false,
-      // 自定义金额 - 已注释功能
-      // customAmount: '',
+      // 自定义金额
+      customAmount: '',
       // 支付方式类型
       paymentType: PAYMENT_TYPE,
       // 登录状态
@@ -156,18 +153,15 @@ export default {
     },
     // 显示列表 = 产品列表 + 自定义
     coinOptionsWithCustom() {
-      // 注释掉自定义金额功能
-      /* if (ALI_CUSTOM) {
+      if (ALI_CUSTOM) {
         return [...(this.coinOptions || []), { isCustom: true }]
-      } else { */
+      } else {
         return [...(this.coinOptions || [])]
-      // }
+      }
     },
     // 是否选择了自定义
     isCustomSelected() {
-      // 注释掉自定义金额功能
-      // return this.selectedRecharge === this.coinOptionsWithCustom.length - 1
-      return false
+      return this.selectedRecharge === this.coinOptionsWithCustom.length - 1
     }
   },
   methods: {
@@ -297,17 +291,18 @@ export default {
       }
 
       // 自定义金额校验
-      /* if (this.isCustomSelected) {
+      if (this.isCustomSelected) {
         const amountNumber = Number(this.customAmount)
         if (!this.customAmount || Number.isNaN(amountNumber) || amountNumber <= 0) {
           this.$toast('请输入有效的自定义金额')
           return
         }
-      } */
+      }
 
       const selectedOption = this.selectedRechargeOption
-      // 自定义金额已注释,直接显示产品价格
-      const priceToShow = selectedOption?.price || 0
+      const priceToShow = selectedOption && selectedOption.isCustom
+        ? (Number(this.customAmount) || 0)
+        : (selectedOption?.price || 0)
 
       // 使用二次确认弹窗
       this.$dialog.confirm({