withdrawDeposit.vue
5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<template>
<u-navbar title="提现" :autoBack="true" bgColor="#ffffff" placeholder safeAreaInsetTop :titleStyle="{ color: '#000' }">
<template #right>
<view class="navleft" @click="proxy.$h.jumpUrl(`/pages2/money/income?flag=withdraw`)">提现记录</view>
</template>
</u-navbar>
<view class="money">
<!-- <view class="money-title">提现到</view>
<view class="flexJ" @click="proxy.$h.jumpUrl(`/pages2/money/bankCard?type=select`)">
<template v-if="!SelectBankCardData?.id">
<view class="sel">请选择银行卡</view>
</template>
<template v-if="SelectBankCardData?.id">
<view class="flexA">
<image :src="proxy.$h.downFile(SelectBankCardData?.icon) || '/static/images/auditerror.png'" mode="aspectFill" class="money-icon" />
<view class="bankCard">{{ SelectBankCardData?.bank }}</view>
</view>
</template>
<u-icon name="arrow-right" color="#666666" size="18"></u-icon>
</view>
<u-line margin="32rpx 0 56rpx 0"></u-line> -->
<view class="money-title">提现金额</view>
<view class="flexA">
<view class="f">¥</view>
<up-input placeholder="" border="none" v-model="params.amount" @change="e => limitDecimal(e)"></up-input>
</view>
<u-line margin="36rpx 0"></u-line>
<view style="margin-bottom: 114rpx">
<text class="redtext">可提现¥{{ parseFloat(amount).toFixed(2) || '0.00' }}</text>
<text class="bluetext" @click="params.amount = amount">全部提现</text>
</view>
<view class="money-title">提现到</view>
<u-radio-group iconPlacement="right" v-model="params.type">
<template v-for="_ in withdrawList">
<view style="width: 100%; margin-bottom: 32rpx">
<view class="flexA">
<image class="icon" :src="_.icon" mode="scaleToFill" />
<view style="width: 100%">
<u-radio activeColor="#05B8D2" :label="_.name" :name="_.type"></u-radio>
</view>
</view>
</view>
</template>
</u-radio-group>
<!-- 有银行卡信息的时候显示 #05B8D2 没有的时候显示 #DADADA -->
<up-button :color="'#05B8D2'" shape="circle" text="确认提现" throttleTime="1500" :customStyle="{ height: '94rpx', fontSize: '32rpx', marginTop: '42rpx' }" @click="confirmWithdrawDepositHandler"></up-button>
</view>
</template>
<script setup lang="ts">
import { ref, getCurrentInstance, ComponentPublicInstance } from 'vue'
import { storeToRefs } from 'pinia'
import { onShow } from '@dcloudio/uni-app'
import { useSelectDataStore } from '../../store/selectData'
import { updateAdd_withdraw, getMy, getUserCard } from '../../api'
import { BankCardItemType, UserInfoType, GetUserCardType } from '../../types'
const { proxy } = getCurrentInstance() as { proxy: ComponentPublicInstance }
const { SelectBankCardData } = storeToRefs(useSelectDataStore())
const amount = ref(0)
const params = ref({ amount: 0, type: 1 })
const userCard = ref<GetUserCardType>()
const withdrawList = ref([
{ type: 1, icon: '/static/images/wechatpay.png', name: '微信' },
{ type: 2, icon: '/static/images/alipay.png', name: '支付宝' }
])
onShow(async () => {
const { result }: { result: UserInfoType } = await getMy()
amount.value = result.amount
getUserCardHandler()
})
const getUserCardHandler = async () => (userCard.value = (await getUserCard()).result as GetUserCardType)
const confirmWithdrawDepositHandler = async () => {
if (([null, undefined, ''].includes(userCard.value?.aliUserName) && params.value.type === 2) || ([null, undefined, ''].includes(userCard.value?.wxUserName) && params.value.type === 1))
return uni.showModal({
title: '提示',
content: `您还没有${proxy.$h.optObjectValue('account', params.value.type)}提现账户,是否去绑定`,
showCancel: true,
success: ({ confirm }) => {
if (confirm) {
proxy.$h.jumpUrl(`/pages2/money/account`)
}
}
})
if (params.value.amount === 0) return uni.$u.toast('请输入提现金额')
try {
await updateAdd_withdraw({ ...params.value })
uni.showModal({
title: '提示',
content: '提现成功,请等候后台审核',
showCancel: false,
success: () => {
proxy.$h.backUrl(1)
}
})
} catch (error) {
uni.$u.toast(error)
}
}
const regex = /^\d+(\.\d{0,2})?$/
const limitDecimal = (value: number) => {
// if (!regex.test(value + '')) {
// params.value.amount = Math.floor(value * 100) / 100
// }
}
</script>
<style lang="scss" scoped>
.navleft {
color: #26292c;
font-size: 28rpx;
}
.money {
box-sizing: border-box;
padding: 72rpx 32rpx 0;
&-icon {
width: 64rpx;
height: 64rpx;
border-radius: 50%;
margin-right: 22rpx;
}
.bankCard {
color: #323233;
font-size: 34rpx;
font-weight: 700;
}
.sel {
color: #666666;
font-size: 34rpx;
font-weight: 700;
}
.f {
color: #323233;
font-size: 52rpx;
}
&-title {
color: #323233;
font-size: 36rpx;
font-weight: 700;
margin-bottom: 62rpx;
}
.bluetext {
color: #05b8d2;
font-size: 26rpx;
font-weight: 700;
}
.redtext {
color: #f33f2e;
font-size: 26rpx;
font-weight: 700;
margin-right: 24rpx;
}
}
:deep(.u-input__content__field-wrapper__field) {
color: #323233;
font-size: 50rpx !important;
font-weight: 700;
}
.icon {
width: 52rpx;
height: 52rpx;
margin-right: 16rpx;
border-radius: 12rpx;
}
</style>