|
@@ -11,12 +11,13 @@
|
|
|
<script lang="ts" setup>
|
|
|
import { getConfigByCode } from '@/api/common'
|
|
|
import { orderCancel, orderDetail, orderPink, orderStatusEnum, payOrder } from '@/api/order'
|
|
|
+import { getWalletAccountInfo } from '@/api/wallet'
|
|
|
import DialogBox from '@/components/DialogBox/DialogBox.vue'
|
|
|
import { DialogUtils } from '@/components/DialogBox/utils'
|
|
|
import { t } from '@/locale'
|
|
|
import { formatNumber } from '@/utils'
|
|
|
import { getPageParams, toPage } from '@/utils/page'
|
|
|
-import { showToast, toast } from '@/utils/toast'
|
|
|
+import { toast } from '@/utils/toast'
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'OrderDetail', // 订单详情
|
|
@@ -26,6 +27,7 @@ defineOptions({
|
|
|
const paging = ref(null)
|
|
|
|
|
|
const id = ref<any>()
|
|
|
+const isPayOrder = ref<boolean>(false)
|
|
|
const detail = ref<any>({})
|
|
|
const orderStatusEnumData = ref<any>([])
|
|
|
const openRedEnvelopeRate = ref<any>()
|
|
@@ -35,6 +37,7 @@ const timer = ref()
|
|
|
|
|
|
// DialogBox 函数式调用配置
|
|
|
const dialogConfig = ref<any>({})
|
|
|
+const dialogType = ref<'cancel' | 'pay' | 'recharge' | ''>('')
|
|
|
|
|
|
async function getConfig(code: string) {
|
|
|
try {
|
|
@@ -107,7 +110,13 @@ async function getDetail() {
|
|
|
const res = await orderDetail({ id: id.value })
|
|
|
if (res.code === '200') {
|
|
|
detail.value = res.data
|
|
|
- startCountdown() // 开始倒计时
|
|
|
+ if (detail.value?.status === 1) {
|
|
|
+ startCountdown() // 开始倒计时
|
|
|
+ // if (isPayOrder.value) {
|
|
|
+ // // 自动调用支付接口
|
|
|
+ // await goPay()
|
|
|
+ // }
|
|
|
+ }
|
|
|
await getPink()
|
|
|
paging.value.complete()
|
|
|
}
|
|
@@ -139,12 +148,14 @@ function selectAddress() {
|
|
|
|
|
|
// 显示取消订单确认对话框
|
|
|
function showCancelOrderDialog() {
|
|
|
+ dialogType.value = 'cancel'
|
|
|
Object.assign(dialogConfig.value, DialogUtils.info(
|
|
|
t('orderDetail.dialog.cancel.title'),
|
|
|
{
|
|
|
showCancel: true,
|
|
|
confirmText: t('orderDetail.dialog.cancel.confirm'),
|
|
|
cancelText: t('orderDetail.dialog.cancel.keep'),
|
|
|
+ confirmPlain: true,
|
|
|
},
|
|
|
))
|
|
|
}
|
|
@@ -183,14 +194,15 @@ async function cancelOrder() {
|
|
|
|
|
|
// 处理对话框确认事件
|
|
|
function handleDialogConfirm() {
|
|
|
- const config = dialogConfig.value as any
|
|
|
- const { confirmText } = config
|
|
|
-
|
|
|
- if (confirmText === 'Yes, Cancel') {
|
|
|
- // 确认取消订单
|
|
|
+ if (dialogType.value === 'cancel') {
|
|
|
cancelOrder()
|
|
|
}
|
|
|
-
|
|
|
+ else if (dialogType.value === 'pay') {
|
|
|
+ goPay()
|
|
|
+ }
|
|
|
+ else if (dialogType.value === 'recharge') {
|
|
|
+ toPage('/pages/wallet/recharge', { price: detail.value?.payPrice }, true)
|
|
|
+ }
|
|
|
// 关闭对话框
|
|
|
handleDialogClose()
|
|
|
}
|
|
@@ -199,22 +211,49 @@ function handleDialogConfirm() {
|
|
|
function handleDialogClose() {
|
|
|
dialogConfig.value.show = false
|
|
|
}
|
|
|
+// 支付
|
|
|
+// 显示支付余额去充值提示
|
|
|
+function showRechargeDialog() {
|
|
|
+ dialogType.value = 'recharge'
|
|
|
+ Object.assign(dialogConfig.value, DialogUtils.info(
|
|
|
+ `Your wallet balance is insufficient. \n Please Recharge!`,
|
|
|
+ {
|
|
|
+ showCancel: false,
|
|
|
+ confirmText: 'Recharge Now',
|
|
|
+ cancelText: '',
|
|
|
+ confirmPlain: true,
|
|
|
+ },
|
|
|
+ ))
|
|
|
+}
|
|
|
+// 显示支付确认对话框
|
|
|
+function showPayOrderDialog() {
|
|
|
+ dialogType.value = 'pay'
|
|
|
+ Object.assign(dialogConfig.value, DialogUtils.info(
|
|
|
+ 'BandhuBuy Wallet Pay',
|
|
|
+ {
|
|
|
+ showCancel: false,
|
|
|
+ cancelText: '',
|
|
|
+ confirmText: 'DONE',
|
|
|
+ confirmPlain: false,
|
|
|
+ },
|
|
|
+ ))
|
|
|
+}
|
|
|
+async function goPay() {
|
|
|
+ const payRes = await payOrder({
|
|
|
+ orderId: detail.value?.orderId,
|
|
|
+ type: detail.value?.storePink?.kId ? 'open' : 'join',
|
|
|
+ })
|
|
|
+ console.log(payRes)
|
|
|
+ if (payRes.code === '200') {
|
|
|
+ toast.success(t('orderDetail.payment.success'))
|
|
|
+ getDetail()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
-async function handleClick() {
|
|
|
+function handleClick() {
|
|
|
if (detail.value?.status === 1) {
|
|
|
// 去支付
|
|
|
- const payRes = await payOrder({
|
|
|
- orderId: detail.value?.orderId,
|
|
|
- type: detail.value?.storePink?.kId ? 'open' : 'join',
|
|
|
- })
|
|
|
- console.log(payRes)
|
|
|
- if (payRes.code === '200') {
|
|
|
- showToast({
|
|
|
- message: t('orderDetail.payment.success'),
|
|
|
- icon: 'success',
|
|
|
- })
|
|
|
- getDetail()
|
|
|
- }
|
|
|
+ showPayOrderDialog()
|
|
|
}
|
|
|
else {
|
|
|
// 去分享
|
|
@@ -231,10 +270,25 @@ onLoad(async (options) => {
|
|
|
getConfig('join_red_envelope_rate')
|
|
|
const params = getPageParams(options)
|
|
|
id.value = params.id
|
|
|
+ isPayOrder.value = params.isPayOrder
|
|
|
await getOrderStatus()
|
|
|
})
|
|
|
-onShow(() => {
|
|
|
- getDetail()
|
|
|
+const balance = ref<number>(0)
|
|
|
+onShow(async () => {
|
|
|
+ await getDetail()
|
|
|
+ if (isPayOrder.value && detail.value?.status === 1) {
|
|
|
+ const res = await getWalletAccountInfo()
|
|
|
+ console.log(res)
|
|
|
+ balance.value = res?.data?.balance
|
|
|
+ if (balance.value < detail.value?.payPrice) {
|
|
|
+ // 余额不足,提示去充值
|
|
|
+ showRechargeDialog()
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ // 余额充足,显示支付对话框
|
|
|
+ showPayOrderDialog()
|
|
|
+ }
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
onUnmounted(() => {
|
|
@@ -382,7 +436,7 @@ onUnmounted(() => {
|
|
|
</view>
|
|
|
</view>
|
|
|
<template #bottom>
|
|
|
- <view class="flex items-center justify-end bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
|
|
|
+ <view v-if="detail?.status === 1" class="flex items-center justify-end bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
|
|
|
<!-- 取消订单按钮 -->
|
|
|
<wd-button
|
|
|
v-if="detail?.status === 1"
|
|
@@ -393,18 +447,55 @@ onUnmounted(() => {
|
|
|
{{ t('orderDetail.button.cancel') }}
|
|
|
</wd-button>
|
|
|
<wd-button @click="handleClick">
|
|
|
- {{ detail?.status !== 1 ? t('orderDetail.button.share') : t('orderDetail.button.pay') }}
|
|
|
+ {{ t('orderDetail.button.pay') }}
|
|
|
</wd-button>
|
|
|
</view>
|
|
|
</template>
|
|
|
-
|
|
|
<!-- DialogBox 函数式调用 -->
|
|
|
<DialogBox
|
|
|
v-bind="dialogConfig"
|
|
|
@confirm="handleDialogConfirm"
|
|
|
@cancel="handleDialogClose"
|
|
|
@close="handleDialogClose"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <view v-if="dialogType === 'pay'">
|
|
|
+ <view class="font-blod relative text-32rpx">
|
|
|
+ <text>BandhuBuy Wallet Pay</text>
|
|
|
+ <wd-icon name="close-normal" custom-class="absolute right-0 top-1/2 -translate-y-1/2" size="40rpx" @click="handleDialogClose" />
|
|
|
+ </view>
|
|
|
+ <view class="py-60rpx">
|
|
|
+ <text class="text-40rpx">
|
|
|
+ ৳
|
|
|
+ </text>
|
|
|
+ <text class="text-60rpx">
|
|
|
+ {{ formatNumber(detail.payPrice) }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ <view class="pb-28rpx text-left">
|
|
|
+ <view class="text-24rpx font-bold">
|
|
|
+ Payment Method
|
|
|
+ </view>
|
|
|
+ <view class="my-14rpx border-b-1px border-b-#EBEBEB border-b-solid" />
|
|
|
+ <view class="flex items-center justify-between text-24rpx">
|
|
|
+ <view class="flex items-center">
|
|
|
+ <view class="text-24rpx">
|
|
|
+ <text>BandhuBuy Wallet (</text>
|
|
|
+ <text class="text-[var(--wot-color-theme)]">
|
|
|
+ Balance: ৳{{ formatNumber(balance) }}
|
|
|
+ </text>
|
|
|
+ <text>)</text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ <view>
|
|
|
+ <image
|
|
|
+ src="/static/icons/circle-check.png"
|
|
|
+ class="h-36rpx w-36rpx"
|
|
|
+ />
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+ </DialogBox>
|
|
|
</z-paging>
|
|
|
</template>
|
|
|
|