Skip to content

Commit 06b137d

Browse files
author
myxingke
committed
支付充值
1 parent 41f8681 commit 06b137d

File tree

2 files changed

+72
-65
lines changed

2 files changed

+72
-65
lines changed

src/libs/http.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ Http.install = function (Vue) {
5353
* @param data 请求数据
5454
* @returns {Promise}
5555
*/
56-
Vue.prototype.apiPost = function(url, data) {
56+
Vue.prototype.apiPost = function(url, data, toast = false) {
57+
if(toast && typeof (toast) == 'boolean') {
58+
Vue.prototype.$loading("加载中...")
59+
} else if(toast && typeof (toast) == 'string') {
60+
Vue.prototype.$loading(toast)
61+
}
5762
return new Promise((resolve, reject) => {
5863
AxiosInst.post(url, data).then((response) => {
5964
Vue.prototype.response(response.data)
@@ -73,7 +78,12 @@ Http.install = function (Vue) {
7378
* @param data 请求数据
7479
* @returns {Promise}
7580
*/
76-
Vue.prototype.apiGet = function(url, data) {
81+
Vue.prototype.apiGet = function(url, data, toast = false) {
82+
if(toast && typeof (toast) == 'boolean') {
83+
Vue.prototype.$loading("加载中...")
84+
} else if(toast && typeof (toast) == 'string') {
85+
Vue.prototype.$loading(toast)
86+
}
7787
return new Promise((resolve, reject) => {
7888
AxiosInst.get(url, {
7989
params: data

src/module/manage/pages/system/bank_account.vue

Lines changed: 60 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,44 @@
1212
</Checkbox-group>
1313
</Form-item>
1414
<Row>
15-
<Col span="7">
16-
<Form-item
17-
v-for="(item, index) in formDynamic.bank"
18-
:key="item"
19-
:label="'开户行' + (index + 1)"
20-
:prop="'bank.' + index + '.value'"
21-
:rules="{required: true, message: '开户行' + (index + 1) +'不能为空', trigger: 'blur'}">
22-
<Input type="text" v-model="item.value" placeholder="请输入..."></Input>
23-
</Form-item>
24-
</Col>
25-
<Col span="7">
26-
<Form-item
27-
v-for="(item, index) in formDynamic.payee"
28-
:key="item"
29-
:label="'开户名' + (index + 1)"
30-
:prop="'payee.' + index + '.value'"
31-
:rules="{required: true, message: '开户名' + (index + 1) +'不能为空', trigger: 'blur'}">
32-
<Input type="text" v-model="item.value" placeholder="请输入..."></Input>
33-
</Form-item>
34-
</Col>
35-
<Col span="10">
36-
<Form-item
37-
v-for="(item, index) in formDynamic.account"
38-
:key="item"
39-
:label="'收款帐号' + (index + 1)"
40-
:prop="'account.' + index + '.value'"
41-
:rules="{required: true, message: '收款帐号' + (index + 1) +'不能为空', trigger: 'blur'}">
42-
<Row>
43-
<Col span="19">
15+
<Col span="7" v-show="formDynamic.account.length > 0">
16+
<Form-item
17+
v-for="(item, index) in formDynamic.bank"
18+
:key="item"
19+
:label="'开户行' + (index + 1)"
20+
:prop="'bank.' + index + '.value'"
21+
:rules="{required: true, message: '开户行' + (index + 1) +'不能为空', trigger: 'blur'}">
22+
<Input type="text" v-model="item.value" placeholder="请输入..."></Input>
23+
</Form-item>
24+
</Col>
25+
<Col span="7">
26+
<Form-item
27+
v-for="(item, index) in formDynamic.payee"
28+
:key="item"
29+
:label="'开户名' + (index + 1)"
30+
:prop="'payee.' + index + '.value'"
31+
:rules="{required: true, message: '开户名' + (index + 1) +'不能为空', trigger: 'blur'}">
4432
<Input type="text" v-model="item.value" placeholder="请输入..."></Input>
45-
</Col>
46-
<Col span="4" offset="1">
47-
<Button type="ghost" @click="handleRemove(index)">删除</Button>
48-
</Col>
49-
</Row>
50-
</Form-item>
33+
</Form-item>
34+
</Col>
35+
<Col span="10">
36+
<Form-item
37+
v-for="(item, index) in formDynamic.account"
38+
:key="item"
39+
:label="'收款帐号' + (index + 1)"
40+
:prop="'account.' + index + '.value'"
41+
:rules="{required: true, message: '收款帐号' + (index + 1) +'不能为空', trigger: 'blur'}">
42+
<Row>
43+
<Col span="19">
44+
<Input type="text" v-model="item.value" placeholder="请输入..."></Input>
45+
</Col>
46+
<Col span="4" offset="1">
47+
<Button type="ghost" @click="handleRemove(index)">删除</Button>
48+
</Col>
49+
</Row>
50+
</Form-item>
5151
</Col>
52+
<Col span="24" v-show="formDynamic.account.length == 0" style="text-align: center; font-size: 20px; color: #00a0e9">至少选择一个银行帐户信息</Col>
5253
</Row>
5354
<br>
5455
<Form-item>
@@ -73,11 +74,12 @@
7374

7475
</template>
7576
<script>
77+
7678
export default {
7779
data () {
7880
const validateAmounts = (rule, value, callback) => {
7981
if (value) {
80-
let reg = /^((\d+)(?!,\2(,|$)))(,(\d+)(?!,\5(,|$)))*$/ ;
82+
let reg = /^((\d+)(?!,\2(,|$)))(,(\d+)(?!,\5(,|$)))*$/;
8183
if (!reg.test(value)) {
8284
callback(new Error('充值金额规则不正确'))
8385
}
@@ -86,25 +88,12 @@
8688
}
8789
return {
8890
formDynamic: {
89-
account: [
90-
{
91-
value: ''
92-
}
93-
],
94-
bank: [
95-
{
96-
value: ''
97-
}
98-
],
99-
payee: [
100-
{
101-
value: ''
102-
}
103-
],
91+
account: [],
92+
bank: [],
93+
payee: [],
10494
amounts: '',
10595
pay_type: [],
10696
desc: ''
107-
10897
},
10998
//验证规则
11099
ruleValidate: {
@@ -113,8 +102,8 @@
113102
{validator: validateAmounts, trigger: 'blur'}
114103
],
115104
pay_type: [
116-
{ required: true, type: 'array', min: 1, message: '至少选择一种充值方式', trigger: 'change' },
117-
{ type: 'array', max: 2, message: '最多选择两个充值方式', trigger: 'change' }
105+
{required: true, type: 'array', min: 1, message: '至少选择一种充值方式', trigger: 'change'},
106+
{type: 'array', max: 2, message: '最多选择两个充值方式', trigger: 'change'}
118107
],
119108
}
120109
}
@@ -124,7 +113,7 @@
124113
this.$refs[name].validate((valid) => {
125114
if (valid) {
126115
this.request("AdminSystemBank", this.formDynamic, '保存中...').then((res) => {
127-
if(res.status) {
116+
if (res.status) {
128117
this.$Message.success(res.msg)
129118
} else {
130119
this.$Message.error(res.msg)
@@ -152,17 +141,25 @@
152141
},
153142
//拉取数据
154143
getData () {
155-
this.request("AdminSystemBank", {id: this.$store.state.Merchant.merchant.id}, true).then((res) => {
156-
if (res.status) {
157-
res.data
144+
this.apiGet('/admin/system/bank_account', {}, '获取中...').then((res) => {
145+
//.length > 0
146+
if (res.status && res.data) {
147+
this.formDynamic.amounts = res.data.amounts;
148+
this.formDynamic.desc = res.data.desc;
149+
this.formDynamic.pay_type = res.data.pay_type;
150+
for (let item of res.data.banks) {
151+
this.formDynamic.account.push({'value': item.account});
152+
this.formDynamic.bank.push({'value': item.bank});
153+
this.formDynamic.payee.push({'value': item.payee});
154+
}
158155
} else {
159-
this.$Message.error('商户信息获取失败!');
160-
this.$router.go(-1)
156+
this.$Message.success(res.msg);
161157
}
162-
}).catch((err) => {
163-
this.$Message.error(err);
164-
})
158+
});
165159
},
160+
},
161+
mounted() {
162+
this.getData();
166163
}
167164
}
168165
</script>

0 commit comments

Comments
 (0)