Explorar o código

优化提现流程

lishanshan hai 3 meses
pai
achega
124a1f5aab

+ 9 - 0
src/api/pay.ts

@@ -89,4 +89,13 @@ export function getWithdrawDetail(data: { id: string }) {
       returnResponse: true
     }
   })
+}
+
+// 银行卡认证接口
+export function bankCardAuth(data: { clientApp: string }) {
+  return http.Post('/payment/channelAccounts/withdraw/prepare/coupon', data, {
+    meta: {
+      returnResponse: true
+    }
+  })
 }

+ 3 - 3
src/components/couponList.vue

@@ -186,8 +186,8 @@ onShow(async () => {
         searchValue.value = ''
         await sendCategoryList()
     }
-    // 重新获取优惠券数据
-    await send()
+    // 重新获取优惠券数据(使用 reload 重置分页状态,避免重复数据)
+    await reload()
 })
 
 onUnload(() => {
@@ -642,4 +642,4 @@ async function couponTypeChange(type) {
         padding-top: 150rpx;
     }
 }
-</style>
+</style>

+ 35 - 5
src/pages-B/payment/bankCard-list.vue

@@ -1,6 +1,6 @@
 <script setup lang="ts">
 import { ref, computed } from 'vue'
-import { getBankcardList } from '@/api/pay'
+import { getBankcardList, bankCardAuth } from '@/api/pay'
 import { getImageUrl } from '@/utils/imageUtil'
 
 // 响应式状态
@@ -52,12 +52,42 @@ function addBankCard() {
 			})
 		}
 	} else {
-		uni.navigateTo({
-			url: '/pages-B/payment/bankCard-edit'
-		})
+		// uni.navigateTo({
+		// 	url: '/pages-B/payment/bankCard-edit'
+        // })
+        bankCardAuth({ clientApp: "COUPON_CENTER_WECHAT_MINIAPP" }).then((res: any) => {
+          if (res.data.code === 200) {
+            const { status, certificationUrl } = res.data.result;
+            switch (status) {
+              case 'NEED_CERTIFICATION':
+                // 会员注册确认
+                confirmRegister(certificationUrl);
+                break;
+              case 'FAILED':
+                uni.$u.toast('会员认证失败');
+                break;
+              case 'READY':
+                break;
+            }
+          } else {
+            uni.$u.toast(res.message);
+          }
+        });
 	}
 }
 
+// 会员注册确认-跳转三方链接
+function confirmRegister(url: string) {
+  // #ifdef H5
+  window.location.href = url;
+  // #endif
+  // #ifndef H5
+  uni.navigateTo({
+    url: `/pages-B/payment/web-view?webUrl=${encodeURIComponent(url)}`,
+  });
+  // #endif
+}
+
 // 显示操作菜单
 function showCardActions(card: any) {
 	selectedCard.value = card
@@ -132,7 +162,7 @@ function onActionSelect(action: { name: string }) {
             </view>
 		</view>
 
-		<view v-if="cardList && cardList.length > 0" class="footer-bar" >
+		<view v-if="btnText !== '更换' && cardList && cardList.length > 0" class="footer-bar" >
 			<u-button               
                 :customStyle="{
                     color: '#fff',

+ 36 - 4
src/pages/income/income.vue

@@ -5,7 +5,7 @@ import { storeToRefs } from 'pinia'
 import { computed, ref, watch } from 'vue'
 import dayjs from 'dayjs'
 import { getAccountCount } from '@/api/home'
-import { getBankSignRecord } from '@/api/pay'
+import { getBankSignRecord, bankCardAuth } from '@/api/pay'
 import { getCouponIssuerAccountByPageMap } from '@/api/income'
 import IncomeItem from '@/components/IncomeItem.vue'
 import MescrollBody from '@/custom-components/custom-mescroll/mescroll-body.vue'
@@ -318,9 +318,41 @@ function goToWithdrawal() {
     // 获取可提现余额
     const money = accountCountData.value?.withdrawableAmount || 0
     const bankNumber = accountCountData.value?.bankNumber || 0
-    uni.navigateTo({
-        url: `/pages-B/payment/withdrawal?m=${money}&bankNumber=${bankNumber}`,
-    })
+    // uni.navigateTo({
+    //     url: `/pages-B/payment/withdrawal?m=${money}&bankNumber=${bankNumber}`,
+    // })
+    bankCardAuth({ clientApp: "COUPON_CENTER_WECHAT_MINIAPP" }).then((res: any) => {
+      if (res.data.code === 200) {
+        const { status, certificationUrl } = res.data.result;
+        switch (status) {
+          case 'NEED_CERTIFICATION':
+            // 会员注册确认
+            confirmRegister(certificationUrl);
+            break;
+          case 'FAILED':
+            uni.$u.toast('会员认证失败');
+            break;
+          case 'READY':
+            // 跳转提现页面
+            uni.navigateTo({ url: `/pages-B/payment/withdrawal?m=${money}&bankNumber=${bankNumber}` });
+            break;
+        }
+      } else {
+        uni.$u.toast(res.message);
+      }
+    });
+}
+
+// 会员注册确认-跳转三方链接
+function confirmRegister(url: string) {
+  // #ifdef H5
+  window.location.href = url;
+  // #endif
+  // #ifndef H5
+  uni.navigateTo({
+    url: `/pages-B/payment/web-view?webUrl=${encodeURIComponent(url)}`,
+  });
+  // #endif
 }
 
 function handleItemClick(item: any) {