|
@@ -15,8 +15,9 @@
|
|
|
@input="amount = amount.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1').replace(/^0\d*/, '0').replace(/^\./, '0.')">
|
|
|
</van-field>
|
|
|
<p class="help">
|
|
|
- <span>可提现金额 736.28元</span>
|
|
|
- <a href="javascript:;">全部提现></a>
|
|
|
+ <span>可提现金额 ¥{{ userinfo.user_balance | fen2Yuan }}元</span>
|
|
|
+ <a href="javascript:;"
|
|
|
+ @click="allWithdrawCash">全部提现></a>
|
|
|
</p>
|
|
|
<van-button
|
|
|
class="btn-withdraw-cash"
|
|
@@ -31,8 +32,8 @@
|
|
|
<script>
|
|
|
import { Field, Button, Toast } from 'vant'
|
|
|
import { apiUserCash } from './api/api'
|
|
|
-import { yuan2Fen } from '@/utils'
|
|
|
-// todo 点击全部提现把钱包余额的值传过来,提现接口调用成功,刷新用户信息接口
|
|
|
+import { fen2Yuan, yuan2Fen } from '@/utils'
|
|
|
+
|
|
|
export default {
|
|
|
name: 'index',
|
|
|
components: {
|
|
@@ -45,7 +46,20 @@ export default {
|
|
|
booLock: false
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ userinfo () {
|
|
|
+ return this.$store.state.common.userinfo
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
+ // 全部提现
|
|
|
+ allWithdrawCash () {
|
|
|
+ const amount = this.userinfo.user_balance
|
|
|
+ if (amount <= 0) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.amount = fen2Yuan(amount)
|
|
|
+ },
|
|
|
async withdrawCash () {
|
|
|
const amount = yuan2Fen(this.amount)
|
|
|
if (amount <= 0) {
|
|
@@ -56,7 +70,8 @@ export default {
|
|
|
const { status, msg } = await apiUserCash(amount)
|
|
|
this.booLock = false
|
|
|
if (status) {
|
|
|
-
|
|
|
+ // 更新用户信息
|
|
|
+ this.$store.dispatch('common/getUserInfo')
|
|
|
} else {
|
|
|
Toast(msg)
|
|
|
}
|