对接提现接口
This commit is contained in:
@ -21,14 +21,14 @@
|
|||||||
<view>
|
<view>
|
||||||
<scroll-view class="h-500rpx" scroll-y :show-scrollbar="false">
|
<scroll-view class="h-500rpx" scroll-y :show-scrollbar="false">
|
||||||
<wd-radio-group v-model="selectedBankCardIndex">
|
<wd-radio-group v-model="selectedBankCardIndex">
|
||||||
<view v-for="(item, index) in bankList" :key="index">
|
<view v-for="(item, index) in bankList" :key="item.id">
|
||||||
<wd-radio :value="item.id" checked-color="#4C9F44" size='large' shape="dot" custom-class="!mr-60rpx">
|
<wd-radio :value="index" checked-color="#4C9F44" size='large' shape="dot" custom-class="!mr-60rpx">
|
||||||
<view class="flex items-center mx-60rpx ">
|
<view class="flex items-center mx-60rpx ">
|
||||||
<view class="flex">
|
<view class="flex">
|
||||||
<view class="mr-40rpx">
|
<view class="mr-40rpx">
|
||||||
<wd-img width="44rpx" height="44rpx" mode="aspectFill" :src="`${OSS}icon/icon_bank_card2.png`"></wd-img>
|
<wd-img width="44rpx" height="44rpx" mode="aspectFill" :src="`${OSS}icon/icon_bank_card2.png`"></wd-img>
|
||||||
</view>
|
</view>
|
||||||
<view class="font-400 text-30rpx leading-42rpx text-#303133">{{ item.bankName }} 储蓄卡(3265)</view>
|
<view class="font-400 text-30rpx leading-42rpx text-#303133">{{ item.bank_name }}({{ Withdraw.handleFormatBankCardNumber(item.bank_card) }})</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-radio>
|
</wd-radio>
|
||||||
@ -50,7 +50,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mx-auto mt-30rpx" @click="Withdraw.handleSelectReason">确定</view>
|
<view class="w-630rpx h-90rpx leading-90rpx text-center bg-[#4C9F44] rounded-8rpx text-[#fff] mx-auto mt-30rpx" @click="Withdraw.handleSelectBankCard">确定</view>
|
||||||
</view>
|
</view>
|
||||||
</wd-popup>
|
</wd-popup>
|
||||||
|
|
||||||
@ -59,10 +59,17 @@
|
|||||||
<view class="flex justify-between items-center pl-60rpx pr-28rpx pt-64rpx pb-64rpx">
|
<view class="flex justify-between items-center pl-60rpx pr-28rpx pt-64rpx pb-64rpx">
|
||||||
<view class="text-#303133 text-28rpx leading-40rpx">到账银行卡</view>
|
<view class="text-#303133 text-28rpx leading-40rpx">到账银行卡</view>
|
||||||
<view class="flex items-center" @click="showBankCardPopup = true">
|
<view class="flex items-center" @click="showBankCardPopup = true">
|
||||||
<view class="flex items-center mr-16rpx">
|
<template v-if="selectBank.id">
|
||||||
<wd-img width="44rpx" height="44rpx" mode="aspectFill" :src="`${OSS}icon/icon_bank_card2.png`"></wd-img>
|
<view class="flex items-center mr-16rpx">
|
||||||
</view>
|
<wd-img width="44rpx" height="44rpx" mode="aspectFill" :src="`${OSS}icon/icon_bank_card2.png`"></wd-img>
|
||||||
<view class="font-bold text-28rpx leading-40rpx text-#303133">招商银行(3265)</view>
|
</view>
|
||||||
|
<view class="font-bold text-28rpx leading-40rpx text-#303133">{{ selectBank.bank_name }} ({{ Withdraw.handleFormatBankCardNumber(selectBank.bank_card) }})</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template v-else>
|
||||||
|
<view class="font-bold text-28rpx leading-40rpx text-#303133">请选择</view>
|
||||||
|
</template>
|
||||||
|
|
||||||
<view class="flex items-center">
|
<view class="flex items-center">
|
||||||
<wd-icon name="arrow-right" size="22rpx"></wd-icon>
|
<wd-icon name="arrow-right" size="22rpx"></wd-icon>
|
||||||
</view>
|
</view>
|
||||||
@ -76,13 +83,13 @@
|
|||||||
<view class="bg-white rounded-16rpx px-38rpx mx-32rpx border-b border-b-solid border-b-#F6F7F9 pb-30rpx">
|
<view class="bg-white rounded-16rpx px-38rpx mx-32rpx border-b border-b-solid border-b-#F6F7F9 pb-30rpx">
|
||||||
<view class="mt-44rpx flex items-center">
|
<view class="mt-44rpx flex items-center">
|
||||||
<view class="text-[#303133] text-36rpx font-400 leading-50rpx">¥</view>
|
<view class="text-[#303133] text-36rpx font-400 leading-50rpx">¥</view>
|
||||||
<wd-input inputmode="decimal" size="large" placeholder="请输入金额" required no-border placeholderStyle="font-size: 48rpx; color: #c9c9c9;"></wd-input>
|
<wd-input v-model="withdrawMoney" size="large" placeholder="请输入金额" required no-border placeholderStyle="font-size: 48rpx; color: #c9c9c9;"></wd-input>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="mt-26rpx text-26rpx leading-36rpx mx-70rpx">
|
<view class="mt-26rpx text-26rpx leading-36rpx mx-70rpx">
|
||||||
<text class="text-#606266 mr-20rpx">可提现36542.3元</text>
|
<text class="text-#606266 mr-20rpx">可提现{{ useStore.userMoney }}元</text>
|
||||||
<text class="text-#4C9F44">全部提现</text>
|
<text class="text-#4C9F44" @click="Withdraw.handleWithdrawAll">全部提现</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="mx-48rpx h-90rpx leading-90rpx rounded-8rpx text-center mt-112rpx text-[#fff]" :class="withdrawMoney > 0 ? 'bg-[#4C9F44]' : 'bg-[#A5CFA1]'" @click="Withdraw.handleConfirmwithdrawMoney">确定</view>
|
<view class="mx-48rpx h-90rpx leading-90rpx rounded-8rpx text-center mt-112rpx text-[#fff]" :class="withdrawMoney > 0 ? 'bg-[#4C9F44]' : 'bg-[#A5CFA1]'" @click="Withdraw.handleConfirmwithdrawMoney">确定</view>
|
||||||
@ -91,19 +98,29 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { getBankCardList, withdrawApply } from '@/api/bank'
|
||||||
|
import { useUserStore } from '@/store'
|
||||||
|
import { toast } from '@/utils/toast'
|
||||||
|
import { amount } from '@/utils/test'
|
||||||
|
import { router } from '@/utils/tools'
|
||||||
|
import { getUserInfo } from '@/api/user'
|
||||||
|
|
||||||
const OSS = inject('OSS')
|
const OSS = inject('OSS')
|
||||||
|
const useStore = useUserStore()
|
||||||
|
|
||||||
// 选择银行卡
|
// 选择银行卡
|
||||||
const showBankCardPopup = ref<boolean>(false)
|
const showBankCardPopup = ref<boolean>(false)
|
||||||
const selectedBankCardIndex = ref<number>(0)
|
const selectedBankCardIndex = ref<number>(0)
|
||||||
const bankList = ref<Array<{ id: number, bankName: string, bankCard: string }>>([
|
const bankList = ref<Array<{ id: number, bank_name: string, bank_card: string }>>([])
|
||||||
{ id: 1, bankName: '招商银行', bankCard: '3265' },
|
const selectBank = ref<{ id: number, bank_name: string, bank_card: string }>({
|
||||||
{ id: 2, bankName: '建设银行', bankCard: '1234' },
|
id: 0,
|
||||||
{ id: 3, bankName: '农业银行', bankCard: '5678' },
|
bank_name: '',
|
||||||
])
|
bank_card: ''
|
||||||
|
})
|
||||||
|
console.log("🚀 ~ selectBank:", selectBank.value.id)
|
||||||
|
|
||||||
// 提现金额
|
// 提现金额
|
||||||
const withdrawMoney = ref<number>(0)
|
const withdrawMoney = ref<string>('')
|
||||||
|
|
||||||
|
|
||||||
// 扣除原生导航栏/底部(tabbar、安全区)高度,避免 100vh 溢出产生滚动条
|
// 扣除原生导航栏/底部(tabbar、安全区)高度,避免 100vh 溢出产生滚动条
|
||||||
@ -111,10 +128,94 @@
|
|||||||
height: 'calc(100vh - var(--window-top) - var(--window-bottom))'
|
height: 'calc(100vh - var(--window-top) - var(--window-bottom))'
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const Withdraw = {
|
onLoad(() => {
|
||||||
// 确定提现
|
Withdraw.getBankCardList()
|
||||||
handleConfirmwithdrawMoney: () => {
|
})
|
||||||
|
|
||||||
|
const Withdraw = {
|
||||||
|
/**
|
||||||
|
* 获取银行卡列表
|
||||||
|
*/
|
||||||
|
getBankCardList: async () => {
|
||||||
|
const res = await getBankCardList()
|
||||||
|
bankList.value = res.list
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 格式化银行卡号
|
||||||
|
* @ param bankCardNumber 银行卡号
|
||||||
|
*/
|
||||||
|
handleFormatBankCardNumber: (bankCardNumber: string) => {
|
||||||
|
if (!bankCardNumber) return ''
|
||||||
|
const noSpace = bankCardNumber.replace(/\s/g, '')
|
||||||
|
if (noSpace.length <= 4) return noSpace
|
||||||
|
return noSpace.slice(-4)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择银行卡
|
||||||
|
* @param item 银行卡
|
||||||
|
*/
|
||||||
|
handleSelectBankCard: () => {
|
||||||
|
const item = bankList.value[selectedBankCardIndex.value]
|
||||||
|
selectBank.value = item
|
||||||
|
showBankCardPopup.value = false
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 全部提现
|
||||||
|
*/
|
||||||
|
handleWithdrawAll: async () => {
|
||||||
|
if (useStore.userMoney <= 0) {
|
||||||
|
toast.info('暂无可提现金额')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
withdrawMoney.value = String(useStore.userMoney)
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确定提现
|
||||||
|
*/
|
||||||
|
handleConfirmwithdrawMoney: async () => {
|
||||||
|
const money = Number(withdrawMoney.value)
|
||||||
|
if (money <= 0) {
|
||||||
|
toast.info('请输入提现金额')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!amount(money)) {
|
||||||
|
toast.info('金额格式错误')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!selectBank.value.id) {
|
||||||
|
toast.info('请选择提现银行卡')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (money > useStore.userMoney) {
|
||||||
|
toast.info('提现金额不能大于可提现金额')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
uni.showLoading({
|
||||||
|
title: '提交中...'
|
||||||
|
})
|
||||||
|
try {
|
||||||
|
await withdrawApply(money, selectBank.value.id)
|
||||||
|
// 重新获取用户余额
|
||||||
|
const balance = await getUserInfo()
|
||||||
|
useStore.setUserMoney(Number(balance.user_money))
|
||||||
|
|
||||||
|
uni.hideLoading
|
||||||
|
toast.success('提现申请提交成功')
|
||||||
|
router.redirectTo('/bundle/wallet/wallet', 500)
|
||||||
|
} catch (error) {
|
||||||
|
uni.hideLoading
|
||||||
|
toast.info('获取可提现金额失败,请稍后重试')
|
||||||
|
return
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// 添加银行卡
|
// 添加银行卡
|
||||||
|
|||||||
Reference in New Issue
Block a user