|
@@ -20,17 +20,39 @@
|
|
|
</route>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
+import { rechargeAdd, rechargeCallback, rechargeGoodsList } from '@/api/wallet'
|
|
|
+import { formatNumber } from '@/utils'
|
|
|
+import { toPage } from '@/utils/page'
|
|
|
+
|
|
|
defineOptions({
|
|
|
name: 'Recharge', // 充值
|
|
|
})
|
|
|
-const selectId = ref(1)
|
|
|
+const selectData = ref<any>({
|
|
|
+ id: '',
|
|
|
+})
|
|
|
// 触发确定按钮
|
|
|
onNavigationBarButtonTap((event: any) => {
|
|
|
if (event.text === 'Record') {
|
|
|
- uni.navigateTo({
|
|
|
- url: '/pages/wallet/rechargeRecord',
|
|
|
- })
|
|
|
+ toPage('/pages/wallet/rechargeRecord')
|
|
|
+ }
|
|
|
+})
|
|
|
+const dataList = ref<any[]>([])
|
|
|
+async function getRechargeGoodsList() {
|
|
|
+ const res = await rechargeGoodsList()
|
|
|
+ dataList.value = res.data
|
|
|
+}
|
|
|
+
|
|
|
+async function submit() {
|
|
|
+ const addRes = await rechargeAdd({ goodsId: selectData.value.id })
|
|
|
+ console.log(addRes)
|
|
|
+ if (addRes.code === '200') {
|
|
|
+ const callbackRes = await rechargeCallback({ data: JSON.stringify({ orderNo: addRes.data.orderNo, status: addRes.data.status }) })
|
|
|
+ console.log(callbackRes)
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+onShow(() => {
|
|
|
+ getRechargeGoodsList()
|
|
|
})
|
|
|
</script>
|
|
|
|
|
@@ -39,25 +61,26 @@ onNavigationBarButtonTap((event: any) => {
|
|
|
<view class="px-24rpx">
|
|
|
<view class="py-30rpx text-center text-28rpx text-#595959">
|
|
|
Recharge Highest Discount <text class="text-[var(--wot-color-theme)]">
|
|
|
- 5%
|
|
|
+ {{ Math.max(...(dataList.map(i => i.discountRate))) }}%
|
|
|
</text>
|
|
|
</view>
|
|
|
<view class="grid grid-cols-2 gap-20rpx">
|
|
|
<view
|
|
|
- v-for="i in 6"
|
|
|
- :key="i"
|
|
|
+ v-for="i in dataList"
|
|
|
+ :key="i.id"
|
|
|
class="border-1 border-transparent rounded-12rpx border-dashed bg-[rgba(var(--wot-color-theme-rgb),0.1)] py-24rpx text-center"
|
|
|
:style="{
|
|
|
- borderColor: i === selectId ? 'var(--wot-color-theme)' : '',
|
|
|
- backgroundColor: i === selectId ? 'rgba(var(--wot-color-theme-rgb),0.25)' : '',
|
|
|
+ borderColor: i.id === selectData.id ? 'var(--wot-color-theme)' : '',
|
|
|
+ backgroundColor: i.id === selectData.id ? 'rgba(var(--wot-color-theme-rgb),0.25)' : '',
|
|
|
}"
|
|
|
+ @click="selectData = i"
|
|
|
>
|
|
|
<view class="mb-8rpx text-40rpx text-[var(--wot-color-theme)] font-bold">
|
|
|
- 5,000
|
|
|
+ {{ formatNumber(i.amount) }}
|
|
|
</view>
|
|
|
<view class="text-20rpx">
|
|
|
Get <text class="text-[var(--wot-color-theme)]">
|
|
|
- ৳5,250, 5%
|
|
|
+ ৳{{ formatNumber(i.amount + i.discount) }}, {{ i.discountRate }}%
|
|
|
</text> Discount
|
|
|
</view>
|
|
|
</view>
|
|
@@ -65,7 +88,7 @@ onNavigationBarButtonTap((event: any) => {
|
|
|
</view>
|
|
|
<template #bottom>
|
|
|
<view class="bg-white/60 px-28rpx py-30rpx backdrop-blur-20">
|
|
|
- <wd-button block>
|
|
|
+ <wd-button block :disabled="!selectData.id" @click="submit">
|
|
|
Submit
|
|
|
</wd-button>
|
|
|
</view>
|