391 行
8.7 KiB
Vue
391 行
8.7 KiB
Vue
<!-- 绑定提现账户 -->
|
|
<template>
|
|
<view class="bank-bind-page brand-page">
|
|
<view class="page-wrap">
|
|
<shopro-navbar variant="gradient" :backText="pageTitle"></shopro-navbar>
|
|
<view class="page-content">
|
|
<view class="type-banner brand-card u-flex u-col-center">
|
|
<image class="type-icon" :src="typeIcon" mode="aspectFit"></image>
|
|
<view class="type-info">
|
|
<view class="type-title">{{ typeTitle }}</view>
|
|
<view class="type-desc">{{ typeDesc }}</view>
|
|
</view>
|
|
</view>
|
|
|
|
<!-- 微信授权 -->
|
|
<view class="wechat-box brand-card" v-if="bindType === 'wechat'">
|
|
<view class="wechat-status" v-if="withdrawInfo">
|
|
<view class="status-label">已绑定账户</view>
|
|
<view class="status-value">{{ withdrawInfo.real_name || '' }} {{ withdrawInfo.card_no || '' }}</view>
|
|
</view>
|
|
<view class="wechat-empty" v-else>
|
|
<view class="empty-title">尚未绑定微信</view>
|
|
<view class="empty-desc">授权后将提现至您的微信零钱账户</view>
|
|
</view>
|
|
<button class="u-reset-button bind-wechat-btn" @tap="bindWechat">
|
|
{{ withdrawInfo ? '重新授权' : '微信授权绑定' }}
|
|
</button>
|
|
</view>
|
|
|
|
<!-- 银行卡 / 支付宝表单 -->
|
|
<view class="form-card brand-card" v-else>
|
|
<u-form :model="form.data" :rules="formRules" ref="bindForm" :errorType="errorType">
|
|
<u-form-item
|
|
v-if="bindType === 'bank'"
|
|
:labelStyle="labelStyle"
|
|
label-width="150"
|
|
label-position="left"
|
|
label="持卡人"
|
|
prop="real_name"
|
|
>
|
|
<u-input
|
|
placeholder="请输入持卡人姓名"
|
|
:placeholderStyle="placeholderStyle"
|
|
v-model="form.data.real_name"
|
|
type="text"
|
|
></u-input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
v-if="bindType === 'bank'"
|
|
:labelStyle="labelStyle"
|
|
label-width="150"
|
|
label-position="left"
|
|
label="开户行"
|
|
prop="bank_name"
|
|
>
|
|
<u-input
|
|
placeholder="请输入开户银行名称"
|
|
:placeholderStyle="placeholderStyle"
|
|
v-model="form.data.bank_name"
|
|
type="text"
|
|
></u-input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
v-if="bindType === 'bank'"
|
|
:labelStyle="labelStyle"
|
|
label-width="150"
|
|
label-position="left"
|
|
label="银行卡号"
|
|
prop="card_no"
|
|
>
|
|
<u-input
|
|
placeholder="请输入银行卡号"
|
|
:placeholderStyle="placeholderStyle"
|
|
v-model="form.data.card_no"
|
|
type="number"
|
|
></u-input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
v-if="bindType === 'alipay'"
|
|
:labelStyle="labelStyle"
|
|
label-width="150"
|
|
label-position="left"
|
|
label="真实姓名"
|
|
prop="real_name"
|
|
>
|
|
<u-input
|
|
placeholder="请输入真实姓名"
|
|
:placeholderStyle="placeholderStyle"
|
|
v-model="form.data.real_name"
|
|
type="text"
|
|
></u-input>
|
|
</u-form-item>
|
|
<u-form-item
|
|
v-if="bindType === 'alipay'"
|
|
:labelStyle="labelStyle"
|
|
label-width="170"
|
|
label-position="left"
|
|
label="支付宝账号"
|
|
prop="card_no"
|
|
>
|
|
<u-input
|
|
placeholder="请输入支付宝账号"
|
|
:placeholderStyle="placeholderStyle"
|
|
v-model="form.data.card_no"
|
|
type="text"
|
|
></u-input>
|
|
</u-form-item>
|
|
</u-form>
|
|
</view>
|
|
|
|
<view class="notice-card brand-card" v-if="bindType !== 'wechat'">
|
|
<view class="notice-title">安全提示</view>
|
|
<view class="notice-item">请确保账户信息与本人实名信息一致</view>
|
|
<view class="notice-item">请仔细核对账号,避免提现失败</view>
|
|
</view>
|
|
|
|
<view class="foot-box safe-area-inset-bottom" v-if="bindType !== 'wechat'">
|
|
<button class="u-reset-button save-btn" @tap="saveForm">保存</button>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import FormValidate from '@/shopro/validate/form';
|
|
import wechat from '@/shopro/wechat/wechat';
|
|
|
|
const TYPE_META = {
|
|
bank: {
|
|
title: '绑定银行卡',
|
|
typeTitle: '银行卡转账',
|
|
desc: '请填写本人实名银行卡信息',
|
|
icon: 'bank_type.png'
|
|
},
|
|
alipay: {
|
|
title: '绑定支付宝',
|
|
typeTitle: '支付宝账户',
|
|
desc: '请填写本人实名支付宝账号',
|
|
icon: 'ali_type.png'
|
|
},
|
|
wechat: {
|
|
title: '绑定微信',
|
|
typeTitle: '微信零钱',
|
|
desc: '授权后提现至微信零钱',
|
|
icon: 'wx_type.png'
|
|
}
|
|
};
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
bindType: 'bank',
|
|
withdrawInfo: null,
|
|
errorType: ['message'],
|
|
labelStyle: {
|
|
'font-size': '30rpx',
|
|
'font-weight': '500',
|
|
color: '#333'
|
|
},
|
|
placeholderStyle: 'font-size: 30rpx; font-weight: 400; color: #C2C7CF;',
|
|
form: {
|
|
data: {
|
|
real_name: '',
|
|
bank_name: '',
|
|
card_no: ''
|
|
},
|
|
bankRules: {
|
|
real_name: FormValidate.realName,
|
|
bank_name: FormValidate.bankName,
|
|
card_no: FormValidate.bankCode
|
|
},
|
|
alipayRules: {
|
|
real_name: FormValidate.realName,
|
|
card_no: FormValidate.alipayAccount
|
|
}
|
|
}
|
|
};
|
|
},
|
|
computed: {
|
|
meta() {
|
|
return TYPE_META[this.bindType] || TYPE_META.bank;
|
|
},
|
|
pageTitle() {
|
|
return this.withdrawInfo ? '修改提现账户' : this.meta.title;
|
|
},
|
|
typeTitle() {
|
|
return this.meta.typeTitle;
|
|
},
|
|
typeDesc() {
|
|
return this.meta.desc;
|
|
},
|
|
typeIcon() {
|
|
return this.$IMG_URL + '/imgs/wallet/' + this.meta.icon;
|
|
},
|
|
formRules() {
|
|
return this.bindType === 'bank' ? this.form.bankRules : this.form.alipayRules;
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
this.bindType = options.type || 'bank';
|
|
if (!TYPE_META[this.bindType]) {
|
|
this.bindType = 'bank';
|
|
}
|
|
this.loadInfo();
|
|
},
|
|
onReady() {
|
|
if (this.bindType !== 'wechat') {
|
|
this.$nextTick(() => {
|
|
this.$refs.bindForm && this.$refs.bindForm.setRules(this.formRules);
|
|
});
|
|
}
|
|
},
|
|
methods: {
|
|
loadInfo() {
|
|
this.$http('money.bankInfo', { type: this.bindType }, '', false).then(res => {
|
|
if (res.code === 1 && res.data) {
|
|
this.withdrawInfo = res.data;
|
|
this.form.data = {
|
|
real_name: res.data.real_name || '',
|
|
bank_name: res.data.bank_name || '',
|
|
card_no: res.data.card_no || ''
|
|
};
|
|
}
|
|
});
|
|
},
|
|
bindWechat() {
|
|
wechat.bind();
|
|
setTimeout(() => {
|
|
this.loadInfo();
|
|
uni.$emit('WITHDRAW_BIND_SUCCESS', { type: 'wechat' });
|
|
}, 1500);
|
|
},
|
|
saveForm() {
|
|
this.$refs.bindForm.validate().then(valid => {
|
|
if (!valid) return;
|
|
this.$http(
|
|
'money.bankEdit',
|
|
{ type: this.bindType, ...this.form.data },
|
|
'提交中...'
|
|
).then(res => {
|
|
if (res.code === 1) {
|
|
this.$u.toast(res.msg || '保存成功');
|
|
uni.$emit('WITHDRAW_BIND_SUCCESS', { type: this.bindType });
|
|
setTimeout(() => uni.navigateBack(), 500);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.bank-bind-page {
|
|
height: 100vh;
|
|
}
|
|
|
|
.page-wrap {
|
|
background: $brand-header-gradient;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.page-content {
|
|
flex: 1;
|
|
padding: 0 $brand-page-gutter 160rpx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.type-banner {
|
|
padding: 32rpx 28rpx;
|
|
margin-bottom: 24rpx;
|
|
|
|
.type-icon {
|
|
width: 80rpx;
|
|
height: 80rpx;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.type-info {
|
|
margin-left: 24rpx;
|
|
|
|
.type-title {
|
|
font-size: 32rpx;
|
|
font-weight: 600;
|
|
color: $brand-text;
|
|
}
|
|
|
|
.type-desc {
|
|
font-size: 24rpx;
|
|
color: $brand-text-muted;
|
|
margin-top: 8rpx;
|
|
}
|
|
}
|
|
}
|
|
|
|
.form-card {
|
|
padding: 10rpx 28rpx 20rpx;
|
|
margin-bottom: 24rpx;
|
|
}
|
|
|
|
.wechat-box {
|
|
padding: 40rpx 28rpx;
|
|
margin-bottom: 24rpx;
|
|
text-align: center;
|
|
|
|
.wechat-status,
|
|
.wechat-empty {
|
|
margin-bottom: 40rpx;
|
|
}
|
|
|
|
.status-label,
|
|
.empty-title {
|
|
font-size: 28rpx;
|
|
color: $brand-text-muted;
|
|
margin-bottom: 12rpx;
|
|
}
|
|
|
|
.status-value,
|
|
.empty-desc {
|
|
font-size: 30rpx;
|
|
color: $brand-text;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.bind-wechat-btn {
|
|
width: 100%;
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
background: #07C160;
|
|
border-radius: 44rpx;
|
|
font-size: 30rpx;
|
|
font-weight: 500;
|
|
color: #fff;
|
|
}
|
|
}
|
|
|
|
.notice-card {
|
|
padding: 28rpx;
|
|
|
|
.notice-title {
|
|
font-size: 28rpx;
|
|
font-weight: 600;
|
|
color: $brand-text;
|
|
margin-bottom: 16rpx;
|
|
}
|
|
|
|
.notice-item {
|
|
font-size: 24rpx;
|
|
color: $brand-text-muted;
|
|
line-height: 40rpx;
|
|
padding-left: 20rpx;
|
|
position: relative;
|
|
|
|
&::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 18rpx;
|
|
width: 8rpx;
|
|
height: 8rpx;
|
|
border-radius: 50%;
|
|
background: $brand-primary;
|
|
}
|
|
}
|
|
}
|
|
|
|
.foot-box {
|
|
position: fixed;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
padding: 20rpx $brand-page-gutter;
|
|
background: rgba(255, 255, 255, 0.96);
|
|
box-shadow: 0 -4rpx 20rpx rgba(0, 0, 0, 0.06);
|
|
}
|
|
|
|
.save-btn {
|
|
width: 100%;
|
|
height: 88rpx;
|
|
line-height: 88rpx;
|
|
background: $brand-primary-gradient;
|
|
border-radius: 44rpx;
|
|
font-size: 30rpx;
|
|
font-weight: 500;
|
|
color: #fff;
|
|
}
|
|
</style>
|