Pārlūkot izejas kodu

feat: 充值查询处理中订单继续并提示,记录可跳转支付地址重新拉起支付

liangan 4 nedēļas atpakaļ
vecāks
revīzija
13672f3a6f
3 mainītis faili ar 97 papildinājumiem un 11 dzēšanām
  1. 16 0
      src/api/wallet.ts
  2. 56 2
      src/pages/wallet/myWallet.vue
  3. 25 9
      src/pages/wallet/rechargeRecord.vue

+ 16 - 0
src/api/wallet.ts

@@ -86,3 +86,19 @@ export function rechargeRecordList(data: any) {
 export function redEnvelopeTop(data: any) {
   return http.get<any>(`${pre}/api/red/envelope/top`, data)
 }
+
+/**
+ * 充值未完成订单查询
+ * @returns
+ */
+export function unpaidOrder() {
+  return http.get<any>(`${pre}/api/recharge/record/unpaidOrder`)
+}
+
+/**
+ * 充值订单二次三方支付
+ * @returns
+ */
+export function thirdPayAgree(recordId: any) {
+  return http.get<any>(`${pre}/api/recharge/record/thirdPayAgree/${recordId}`)
+}

+ 56 - 2
src/pages/wallet/myWallet.vue

@@ -13,8 +13,9 @@
 // eslint-disable-next-line unused-imports/no-unused-imports
 import { onPageScroll, onReachBottom } from '@dcloudio/uni-app' // 必须导入需要用到的页面生命周期(即使在当前页面上没有直接使用到)
 import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
-
-import { getWalletAccountInfo, walletFlowList } from '@/api/wallet'
+import { getWalletAccountInfo, unpaidOrder, walletFlowList } from '@/api/wallet'
+import DialogBox from '@/components/DialogBox/DialogBox.vue'
+import { DialogUtils } from '@/components/DialogBox/utils'
 import { formatNumber } from '@/utils'
 import { toPage } from '@/utils/page'
 // z-paging
@@ -22,6 +23,9 @@ const paging = ref(null)
 // 类似mixins,如果是页面滚动务必要写这一行,并传入当前ref绑定的paging,注意此处是paging,而非paging.value
 useZPaging(paging)
 
+// DialogBox 函数式调用配置
+const dialogConfig = ref<any>({})
+
 const dayType = ref(1)
 const walletInfo = ref<any>({})
 async function getWalletInfo() {
@@ -46,8 +50,52 @@ async function getWalletFlowList(pageNo: number, pageSize: number) {
     paging.value.complete(false)
   }
 }
+
+// 显示取消订单确认对话框
+function showUnpaidOrderDialog() {
+  Object.assign(dialogConfig.value, DialogUtils.info(
+    `You have unfinished recharge orders,\nDo you want to continue recharge?`,
+    {
+      showCancel: true,
+      confirmText: 'Continue Recharge',
+      cancelText: 'New Recharge',
+    },
+  ))
+}
+
+// 处理对话框关闭事件
+function handleDialogClose() {
+  dialogConfig.value.show = false
+}
+
+// 处理对话框确认事件
+function handleDialogConfirm() {
+  //  继续充值
+  handleDialogClose()
+  toPage('/pages/wallet/rechargeRecord')
+  // 关闭对话框
+}
+function handleDialogCancel() {
+  //  新充值
+  handleDialogClose()
+  toPage('/pages/wallet/recharge')
+}
+// 查询未完成的充值订单
+async function getUnpaidOrder() {
+  try {
+    const res = await unpaidOrder()
+    console.log(res)
+    if (res.code === '200' && res.data) {
+      showUnpaidOrderDialog()
+    }
+  }
+  catch (error) {
+    console.log(error)
+  }
+}
 onShow(() => {
   getWalletInfo()
+  getUnpaidOrder()
 })
 </script>
 
@@ -133,6 +181,12 @@ onShow(() => {
           </view>
         </view>
       </view>
+      <DialogBox
+        v-bind="dialogConfig"
+        @confirm="handleDialogConfirm"
+        @cancel="handleDialogCancel"
+        @close="handleDialogClose"
+      />
     </view>
   </z-paging>
 </template>

+ 25 - 9
src/pages/wallet/rechargeRecord.vue

@@ -14,8 +14,9 @@
 import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
 import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
 import { getEnum as _getEnum } from '@/api/common'
-import { rechargeRecordList } from '@/api/wallet'
+import { rechargeRecordList, thirdPayAgree } from '@/api/wallet'
 import { formatNumber } from '@/utils'
+import { toPage } from '@/utils/page'
 
 defineOptions({
   name: 'RechargeRecord', // 充值记录
@@ -45,6 +46,18 @@ async function queryList(pageNo: number, pageSize: number) {
     paging.value.complete(false)
   }
 }
+async function handleClick(data: any) {
+  if (data.status === 1) {
+    try {
+      const res = await thirdPayAgree(data.id)
+      console.log(res)
+      if (res.code === '200') {
+        toPage('/pages/webLink/webLink', { link: res.data, title: 'Recharge' })
+      }
+    }
+    catch {}
+  }
+}
 onLoad(() => {
   getEnum()
 })
@@ -53,15 +66,18 @@ onLoad(() => {
 <template>
   <z-paging ref="paging" v-model="dataList" use-page-scroll @query="queryList">
     <view class="py-20rpx">
-      <view v-for="item in dataList" :key="item.id" class="bg-white px-22rpx py-18rpx">
-        <view class="mb-8rpx flex items-center justify-between">
-          <view>ID:{{ item.orderNo }}</view>
-          <wd-text :type="item.status === 2 ? 'success' : 'primary'" bold :text="statusEnum.find(i => i.code === item.status)?.name" />
-        </view>
-        <view class="flex items-center justify-between text-22rpx text-#3A444C">
-          <view>Wallet Balance:+{{ formatNumber(item.amount) }}</view>
-          <view>{{ item.createTime }}</view>
+      <view v-for="item in dataList" :key="item.id" class="flex items-center justify-between bg-white px-22rpx py-18rpx" @click="handleClick(item)">
+        <view class="mr-16rpx flex-1">
+          <view class="mb-8rpx flex items-center justify-between">
+            <view>ID:{{ item.orderNo }}</view>
+            <wd-text :type="item.status === 2 ? 'success' : 'primary'" bold :text="statusEnum.find(i => i.code === item.status)?.name" />
+          </view>
+          <view class="flex items-center justify-between text-22rpx text-#3A444C">
+            <view>Wallet Balance:+{{ formatNumber(item.amount) }}</view>
+            <view>{{ item.createTime }}</view>
+          </view>
         </view>
+        <wd-icon v-if="item.status === 1" custom-class="flex-shrink-0" name="chevron-right" size="48rpx" />
       </view>
     </view>
   </z-paging>