<template>
|
|
<view class="u-page">
|
|
<view class="u-demo-block-2" >
|
<view class="margin-10"><span>提现金额</span></view>
|
<view class="margin-10">
|
<u--form
|
labelPosition="left"
|
:model="walletInfo"
|
:rules="rules"
|
ref="uForm"
|
>
|
<u-form-item
|
label="¥"
|
prop="amount"
|
borderBottom
|
ref="item1"
|
>
|
<u--input
|
v-model="walletInfo.amount"
|
border="none"
|
placeholder="请输入提现金额"
|
></u--input>
|
</u-form-item>
|
</u--form>
|
</view>
|
<view class="margin-10">
|
可提现余额<span class="t-red" style="margin-left:10rpx;margin-right:10rpx;">{{wallet.withdrawableAmount || '0' }}</span>元
|
</view>
|
|
|
<!-- #ifdef PUB_SUPPLIER -->
|
|
<view class="topic-gray flex " style="">
|
<view :style="{'margin-top': '24rpx','margin-right': '12rpx','font-size':'24rpx'}"
|
@click="protocal=!protocal" class="component-radio" :class="[protocal?'cur':'']" >
|
</view>
|
<view :style="{'margin-top': '24rpx','margin-right': '12rpx','font-size':'24rpx'}">我已阅读并同意<span class="t-red" @click="goto('/pages/help/content?id=提现协议',false)">《提现协议》</span></view>
|
</view>
|
|
<!-- #endif -->
|
|
<view class="margin-30">
|
<u-button type="primary" text="立即提现" size="normal" :disabled="!protocal" @click="submitWithdraw"></u-button>
|
</view>
|
</view>
|
|
</view>
|
</template>
|
|
<script>
|
export default {
|
data() {
|
return {
|
protocal:0,
|
wallet:{},
|
walletInfo: {
|
"amount":0,
|
},
|
rules:{
|
'amount':[
|
{ required: true, message: '请输入提现金额', trigger: ['blur', 'change'] },
|
{ validator: this.validateDecimal, trigger: ['blur', 'change'] }
|
]
|
}
|
};
|
},
|
|
onLoad(options) {
|
|
|
},
|
onShow() {
|
this.getMyWallet(true)
|
|
},
|
async onPullDownRefresh() {
|
|
},
|
methods: {
|
submitWithdraw(){
|
this.$message.showLoading()
|
// 防止多次重复点击
|
this.protocal=false
|
// 判断输入的金额是否是数字,需要真正则表达式,两位小数点
|
this.$refs.uForm.validate().then(async res => {
|
const resp = await this.$http.request('post', '/v2/withdraw-record', {
|
data: this.walletInfo
|
});
|
if (resp.code === 0) {
|
this.$message.showToast('提现操作成功,等待审核!')
|
// this.getMyWallet(true)
|
setTimeout(() => {
|
uni.navigateBack()
|
}, 1000)
|
}else{
|
// if(resp&&resp.data&&resp.data[0]){
|
// this.$message.showToast(resp.data[0].msg)
|
// }
|
this.$message.showToast("提现失败")
|
}
|
}).catch(err => {
|
|
console.log(err)
|
|
}).finally(() => {
|
this.$message.hideLoading() // 关闭加载提示
|
})
|
|
},
|
|
validateDecimal(rule, value, callback) {
|
|
const decimalRegex = /^\d+(\.\d{1,2})?$/; // 正则表达式,支持最多两位小数
|
if (!value) {
|
return callback(new Error('请输入提现金额'));
|
}
|
|
|
if (!decimalRegex.test(value)) {
|
return callback(new Error('提现金额必须是有效的数字(最多两位小数)'));
|
}
|
// 提现金额要大于0
|
if (value < 0.1) {
|
return callback(new Error('提现金额必须大于0.1'));
|
}
|
if (value > this.wallet.withdrawableAmount) {
|
return callback(new Error('提现金额不能大于可提现金额'));
|
}
|
// 提现金额不能大于500
|
if (value > 500) {
|
return callback(new Error('提现金额不能大于500'));
|
}
|
|
callback();
|
},
|
|
click(name) {
|
|
},
|
|
getMyWallet(refresh=false) {
|
// /api/supplier/delivery
|
|
if (this.currentInfo.id && (this.currentInfo.id !== this.cacheUserId || refresh)) {
|
this.cacheUserId = this.currentInfo.id
|
let that = this
|
setTimeout(() => {
|
//其他统计
|
// #ifdef PUB_SUPPLIER
|
this.$http.request('get', '/v2/wallet/supplier', {}).then(res => {
|
if (res.code === 0) {
|
that.wallet = res.data || {}
|
}
|
})
|
// #endif
|
// // #ifdef PUB_PARTNER
|
// this.$http.request('get', '/api/partner/order/statistics', {}).then(res => {
|
// if (res.code === 0) {
|
// that.tj = res.data || {}
|
// }
|
// })
|
// // #endif
|
|
}, 200)
|
}
|
|
},
|
|
},
|
onReady() {
|
//如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
|
this.$refs.uForm.setRules(this.rules)
|
},
|
}
|
</script>
|
|
<style lang="scss">
|
.u-page{
|
.image-icon{
|
width:30rpx;
|
height: 30rpx;
|
}
|
// .u-button--plain.data-v-3bf2dba7 {
|
// background-color: #00BCD4;
|
// }
|
// .u-button--plain.u-button--primary.data-v-3bf2dba7 {
|
// color: #FFFFFF;
|
// }
|
// .u-button--primary.data-v-3bf2dba7 {
|
// color: #fff;
|
// border-color: #00BCD4;
|
// border-width: 1px;
|
// border-style: solid;
|
// border-radius: 10rpx;
|
// width:200rpx;
|
// }
|
.u-demo-block{
|
padding: 10rpx;
|
background-color: #FFFFFF;
|
border-radius: 50rpx;
|
background-color: #00AF68;
|
margin: 20rpx;
|
.tixian{
|
margin-top: 30rpx;
|
margin-bottom: 30rpx;
|
}
|
}
|
.u-demo-block-2{
|
margin: 30rpx;
|
padding: 30rpx;
|
// padding-top: 20rpx;
|
background-color: #FFFFFF;
|
border-radius: 10rpx;
|
}
|
.title{
|
text-align: center;
|
font-size: 30rpx;
|
color: #909399;
|
margin: 10rpx;
|
}
|
.grid-text-white{
|
color: white;
|
}
|
.grid-text {
|
font-size: 14px;
|
color: #909399;
|
padding: 10rpx 0 20rpx 0rpx;
|
/* #ifndef APP-PLUS */
|
box-sizing: border-box;
|
/* #endif */
|
}
|
.statis_val{
|
font-size: 16px;
|
color: black;
|
// font-weight: bold;
|
}
|
|
.margin-10{
|
margin:10rpx;
|
}
|
|
.margin-30{
|
margin-top:30rpx;
|
}
|
}
|
</style>
|