myReflect.vue
3.7 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
<template>
<view class="money_edit">
<view class="banner">
<image class="bg-img" src="@/pages_my/static/logo_start.png" mode="widthFix"></image>
<view class="my_money">
<text>{{ type === '0' ? '可提现金额(元)' : '现有余额(元)' }}</text>
<text>¥<text class="number">{{ amount }}</text> </text>
</view>
</view>
<view class="edit_box">
<view class="edit_title px-30">{{ type === '0' ? '提现金额' : '充值金额' }}</view>
<view class="money_line px-30">
<text class="m-r-10">¥</text>
<input
:value="query.amount"
placeholder="请输入提现余额"
type="number"
@input="onInput"
/>
</view>
<view class="option">
<u-cell-group :border="false">
<u-cell :title="type === '0' ? '提现到' : '充值方式'" :border="false" :value="type === '0' ? formatBank : '微信支付'"></u-cell>
</u-cell-group>
</view>
<!-- 提交按钮 -->
<view class="footer">
<u-button :text="type === '0' ? '申请提现' : '确认充值'" color="#333333" shape="circle" @click="confirm"></u-button>
</view>
</view>
</view>
</template>
<script>
import { recharge, getAmount, cashAmout, getBank } from '@/api/user.js'
import { mapGetters } from 'vuex'
export default {
data() {
return {
query: {
amount: '1800', // 充值金额
type: 1 // 0 公众号, 1 小程序
},
bankInfo: {
accountBank: '储蓄卡',
account: '6228485028809226788'
},
amount: 0, // 用户可提余额
type: '0', // 0提现,1充值
}
},
async onLoad(option) {
// this.getBankInfo()
this.type = option.type
// 查询可提现余额
// this.amount = await getAmount()
},
computed: {
...mapGetters(['userInfo']),
formatBank() {
let bankName = this.bankInfo.accountBank === '' ? '' : this.bankInfo.accountBank.split(' ')[0]
let bankNum = this.bankInfo.account
if(bankName !== '' && bankNum !== ''){
return `${bankName} ${"*".repeat(bankNum.length - 14).replace(/(.{4})/g, `$1 `)}${bankNum.length % 4 ? " " : ""}${bankNum.slice(-5)}`
}
return bankName + bankNum
}
},
methods: {
// 赋值充值金额
onInput({detail}) {
this.query.amount = detail.value
},
// 获取商家提现账户信息
async getBankInfo() {
let businessId = this.userInfo.businessId
const res = await getBank(businessId)
this.bankInfo = res
},
// 提交申请
async confirm(){
// 判断用户是提现还是充值
if(this.type === '0') {
let cashoutAmount = this.query.amount
const res = await cashAmout({ cashoutAmount })
} else {
const res = await recharge(this.query)
}
}
}
}
</script>
<style lang="scss" scoped>
.money_edit{
min-height: 100vh;
background-color: #f6f6f6;
}
.banner{
position: relative;
height: 288rpx;
background-color: #333;
.bg-img{
position: absolute;
top: 0;
right: -10rpx;
width: 430rpx;
height: 286rpx;
}
.my_money{
position: absolute;
top: 38rpx;
left: 28rpx;
display: flex;
flex-direction: column;
gap: 8rpx;
font-size: 28rpx;
line-height: 40rpx;
color: #fff;
.number{
font-size: 52rpx;
font-weight: 700;
line-height: 64rpx;
margin-left: 4rpx;
}
}
}
.edit_box{
position: relative;
height: 496rpx;
margin: 0 30rpx;
margin-top: -86rpx;
background: #FFFFFF;
border-radius: 12rpx;
.edit_title{
height: 86rpx;
color: #333;
line-height: 86rpx;
font-size: 28rpx;
}
.money_line{
display: flex;
align-items: center;
font-size: 40rpx;
line-height: 52rpx;
color: #333;
padding-bottom: 6rpx;
border-bottom: 2rpx solid #D8D8D8;
}
.footer{
margin: 100rpx 72rpx 0;
}
.option{
margin-top: 30rpx;
}
.opton-item{
display: flex;
}
}
</style>