peng
3 天以前 2fd269af9df3653b058deee57bcd7a9f39ff28e7
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
<template>
  <div class="wrapper">
    <card _Title="资金管理"/>
 
    <div class="box">
      <div class="mb_20 account-price">
        <span class="subTips">账户余额:</span>
        <span class="global_color mr_10" style="font-size:26px">¥{{ memberDeposit | unitPrice }}</span>
        <span class="subTips">冻结金额:</span>
        <span class="">¥{{ frozenDeposit | unitPrice }}</span>
      </div>
      <div class="account-btns">
        <Button type="primary" @click="recharge">在线充值</Button>
        <Button @click="withdrawalApply">申请提现</Button>
      </div>
    </div>
    <Modal v-model="modal" width="530">
      <p slot="header">
        <Icon type="edit"></Icon>
        <span>充值金额</span>
      </p>
      <div>
        <Form
          ref="formData"
          :label-width="100"
          :model="formData"
          :rules="formValidate"
          label-position="left"
        >
          <FormItem label="充值金额" prop="price">
            <Input v-model="formData.price" maxlength="9" number size="large"
            ><span slot="append">元</span></Input>
          </FormItem>
        </Form>
      </div>
      <div slot="footer" style="text-align: center">
        <Button size="large" type="success" @click="rechargePrice">充值</Button>
      </div>
    </Modal>
    <!-- 提现申请 -->
    <Modal v-model="withdrawApplyModal" width="530">
      <p slot="header">
        <Icon type="edit"></Icon>
        <span>提现金额</span>
      </p>
      <div>
        <Form
          ref="withdrawApplyFormData"
          :label-width="120"
          :model="withdrawApplyFormData"
          :rules="withdrawApplyFormValidate"
        >
          <FormItem label="提现类型" prop="type">
            <Select v-model="withdrawApplyFormData.type" disabled>
              <Option value="ALI">支付宝</Option>
              <Option value="WECHAT">微信</Option>
            </Select>
          </FormItem>
          <FormItem label="提现金额" prop="price">
            <Input
              v-model="withdrawApplyFormData.price"
              maxlength="9"
              number
              size="large"
            ><span slot="append">元</span></Input>
            <span style="color: red">最低提现金额 {{ withdrawApplyFormData.minPrice }}元</span>
          </FormItem>
          <FormItem v-if="withdrawApplyFormData.type === 'ALI'" label="真实姓名" prop="realName">
            <Input
              v-model="withdrawApplyFormData.realName"
              maxlength="9"
              number
              size="large"
            ></Input>
          </FormItem>
          <FormItem v-if="withdrawApplyFormData.type === 'ALI'" label="第三方登录账号" prop="connectNumber">
            <Input
              v-model="withdrawApplyFormData.connectNumber"
              maxlength="9"
              number
              size="large"
            ></Input>
          </FormItem>
        </Form>
      </div>
      <div slot="footer" style="text-align: center">
        <Button size="large" type="success" @click="withdrawal">提现</Button>
      </div>
    </Modal>
    <!-- 余额日志 -->
    <Tabs value="log" @on-click="tabPaneChange">
      <TabPane label="余额日志" name="log">
        <Table :columns="logColumns" :data="logColumnsData.records"></Table>
        <!-- 分页 -->
        <div class="page-size">
          <Page
            :current="walletForm.pageNumber"
            :page-size="walletForm.pageSize"
            :page-size-opts="[10, 20, 50]"
            :total="logColumnsData.total"
            show-sizer
            show-total
            size="small"
            transfer
            @on-change="changePage"
            @on-page-size-change="changePageSize"
          ></Page>
        </div>
      </TabPane>
      <!-- 充值记录 -->
      <TabPane label="充值记录" name="recharge">
        <Table
          :columns="rechargeListColumns"
          :data="rechargeListData.records"
        ></Table>
        <!-- 分页 -->
        <div class="page-size">
          <Page
            :current="rechargeForm.pageNumber"
            :page-size="rechargeForm.pageSize"
            :page-size-opts="[10, 20, 50]"
            :total="rechargeListData.total"
            show-sizer
            show-total
            size="small"
            transfer
            @on-change="rechargeChangePage"
            @on-page-size-change="rechargeChangePageSize"
          ></Page>
        </div>
      </TabPane>
 
      <TabPane label="提现记录" name="withdrawApply">
        <Table
          :columns="withdrawApplyColumns"
          :data="withdrawApplyColumnsListData.records"
        ></Table>
        <!-- 分页 -->
        <div class="page-size">
          <Page
            :current="withdrawApplyForm.pageNumber"
            :page-size="withdrawApplyForm.pageSize"
            :page-size-opts="[10, 20, 50]"
            :total="withdrawApplyColumnsListData.total"
            show-sizer
            show-total
            size="small"
            transfer
            @on-change="withdrawChangePage"
            @on-page-size-change="withdrawChangePageSize"
          ></Page>
        </div>
      </TabPane>
    </Tabs>
  </div>
</template>
 
<script>
import {getDepositLog, getMembersWallet, getRecharge, getWithdrawApply, recharge, withdrawalApply} from '@/api/member';
import {withdrawalSettingVO} from "@/api/pay";
 
export default {
  name: 'MoneyManagement',
  data() {
    return {
      frozenDeposit: 0, // 冻结余额
      memberDeposit: 0, // 余额
 
      modal: false, // 余额充值
      withdrawApplyModal: false, // 提现申请
      formData: {
        // 充值金额
        price: 1
      },
      // 提现金额
      withdrawApplyFormData: {
        price: 1,
        minPrice: 1,
        type: '',
        realName: '',
        connectNumber: '',
      },
      // 余额日志
      walletForm: {
        // 搜索框初始化对象
        pageNumber: 1,
        pageSize: 10
      },
      // 充值记录
      rechargeForm: {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10 // 页面大小
      },
      // 提现记录
      withdrawApplyForm: {
        // 搜索框初始化对象
        pageNumber: 1, // 当前页数
        pageSize: 10 // 页面大小
      },
      // 提现申请校验
      withdrawApplyFormValidate: {
        price: [
          {required: true, message: '请输入大于0小于9999的合法提现金额'},
          {
            pattern: /^[1-9]\d{0,3}(\.\d{1,2})?$/,
            message: '请输入大于0小于9999的合法提现金额',
            trigger: 'change'
          }
        ],
        realName: [
          {required: true, message: '请输入真实姓名'},
        ],
        connectNumber: [
          {required: true, message: '请输入第三方登录账号'},
        ],
      },
      formValidate: {
        price: [
          {required: true, message: '请输入大于等于1小于9999的合法充值金额'},
          {
            pattern: /^[1-9]\d{0,3}(\.\d{1,2})?$/,
            message: '请输入大于等于1小于9999的合法充值金额',
            trigger: 'change'
          }
        ]
      },
      // 余额日志
      logColumns: [
        {
          title: '时间',
          width: 190,
          key: 'createTime'
        },
        {
          title: '金额',
          key: 'money',
          width: 180,
          render: (h, params) => {
            if (params.row.money > 0) {
              return h('div', [
                h(
                  'span',
                  {
                    style: {
                      color: 'green'
                    }
                  },
                  this.$options.filters.unitPrice(params.row.money, '+ ¥')
                )
              ]);
            } else if (params.row.money < 0) {
              return h('div', [
                h(
                  'span',
                  {
                    style: {
                      color: 'red'
                    }
                  },
                  this.$options.filters.unitPrice(0 - params.row.money, '- ¥')
                )
              ]);
            }
          }
        },
        {
          title: '变动日志',
          key: 'detail'
        }
      ],
      logColumnsData: {}, // 余额日志
      // 充值记录
      rechargeListColumns: [
        {
          title: '充值时间',
          key: 'createTime',
          width: 168
        },
        {
          title: '支付单号',
          key: 'rechargeSn',
          width: 200
        },
        {
          title: '充值金额',
          key: 'rechargeMoney',
          render: (h, params) => {
            if (params.row.payStatus === 'PAID') {
              return h('div', [h('span', {
                style: {
                  color: 'green'
                }
              }, this.$options.filters.unitPrice(params.row.rechargeMoney, '+ ¥'))]);
            } else {
              return h('div', [h('span', this.$options.filters.unitPrice(params.row.rechargeMoney, '¥'))]);
            }
          }
        },
        {
          title: '支付状态',
          key: 'payStatus',
          render: (h, params) => {
            if (params.row.payStatus === 'PAID') {
              return h('div', [h('span', {}, '已付款')]);
            } else if (params.row.payStatus === 'UNPAID') {
              return h('div', [h('span', {}, '未付款')]);
            } else if (params.row.payStatus === 'CANCEL') {
              return h('div', [h('span', {}, '已取消')]);
            }
          }
        },
        {
          title: '支付方式',
          key: 'rechargeWay',
          render: (h, params) => {
            if (params.row.rechargeWay === 'ALIPAY') {
              return h('div', [h('span', {}, '支付宝')]);
            } else if (params.row.rechargeWay === 'WECHAT') {
              return h('div', [h('span', {}, '微信')]);
            } else if (params.row.rechargeWay === 'BANK_TRANSFER') {
              return h('div', [h('span', {}, '线下转账')]);
            } else {
              return h('div', [h('span', {}, '')]);
            }
          }
        },
        {
          title: '支付时间',
          key: 'payTime',
          width: 180
        }
      ],
      rechargeListData: {}, // 充值记录数据
      // 提现记录
      withdrawApplyColumns: [
        {
          title: '申请时间',
          key: 'createTime',
          width: 168
        },
        {
          title: '提现单号',
          key: 'sn',
          width: 200
        },
        {
          title: '提现金额',
          key: 'applyMoney',
          width: 110,
          render: (h, params) => {
            if (params.row.applyStatus === 'VIA_AUDITING') {
              return h('div', [h('span', {
                style: {
                  color: 'green'
                }
              }, this.$options.filters.unitPrice(params.row.applyMoney, '+ ¥'))]);
            } else {
              return h('div', [h('span', this.$options.filters.unitPrice(params.row.applyMoney, '¥'))]);
            }
          }
        },
        {
          title: '提现状态',
          key: 'applyStatus',
          width: 95,
          render: (h, params) => {
            if (params.row.applyStatus === 'APPLY') {
              return h('div', [h('span', {}, '申请中')]);
            } else if (params.row.applyStatus === 'VIA_AUDITING') {
              return h('div', [h('span', {}, '审核通过')]);
            } else if (params.row.applyStatus === 'SUCCESS') {
              return h('div', [h('span', {}, '提现成功')]);
            } else if (params.row.applyStatus === 'ERROR') {
              return h('div', [h('span', {}, '提现失败')]);
            } else {
              return h('div', [h('span', {}, '审核拒绝')]);
            }
          }
        },
        {
          title: '审核时间',
          key: 'inspectTime',
          width: 168
        },
        {
          title: '审核备注',
          key: 'inspectRemark',
          tooltip: true
 
        }
      ],
      withdrawApplyColumnsListData: {} // 提现记录
    };
  },
  mounted() {
    this.init();
  },
  methods: {
    // 初始化数据
    init() {
      getMembersWallet().then((res) => {
        this.frozenDeposit = res.result.memberFrozenWallet;
        this.memberDeposit = res.result.memberWallet;
      });
      getDepositLog(this.walletForm).then((res) => {
        if (res.message === 'success') {
          this.logColumnsData = res.result;
        }
      });
    },
    tabPaneChange(v) {
      // 如果查询充值记录
      if (v === 'recharge') {
        this.getRechargeData();
      }
      // 如果是余额日志
      if (v === 'log') {
        this.init();
      }
      // 如果是提现记录
      if (v === 'withdrawApply') {
        this.getWithdrawApplyData();
      }
    },
    // 充值记录
    getRechargeData() {
      getRecharge(this.rechargeForm).then((res) => {
        if (res.message === 'success') {
          this.rechargeListData = res.result;
        }
      });
    },
    // 提现记录
    getWithdrawApplyData() {
      getWithdrawApply(this.withdrawApplyForm).then((res) => {
        if (res.message === 'success') {
          this.withdrawApplyColumnsListData = res.result;
        }
      });
    },
    // 余额日志
    changePage(v) {
      this.walletForm.pageNumber = v;
      this.init();
    },
    changePageSize(v) {
      this.walletForm.pageNumber = 1;
      this.walletForm.pageSize = v;
      this.init();
    },
    // 充值记录
    rechargeChangePage(v) {
      this.rechargeForm.pageNumber = v;
      this.getRechargeData();
    },
    rechargeChangePageSize(v) {
      this.rechargeForm.pageNumber = 1;
      this.rechargeForm.pageSize = v;
      this.getRechargeData();
    },
    // 提现记录
    withdrawChangePage(v) {
      this.withdrawApplyForm.pageNumber = v;
      this.getWithdrawApplyData();
    },
    withdrawChangePageSize(v) {
      this.withdrawApplyForm.pageNumber = 1;
      this.withdrawApplyForm.pageSize = v;
      this.getWithdrawApplyData();
    },
    // 弹出在线充值框
    recharge() {
      this.formData.price = 1;
      this.modal = true;
    },
    // 在线充值
    rechargePrice() {
      this.$refs['formData'].validate((valid) => {
        if (valid) {
          recharge(this.formData).then((res) => {
            if (res.message === 'success') {
              this.$router.push({
                path: '/payment',
                query: {orderType: 'RECHARGE', sn: res.result.rechargeSn}
              });
            }
          });
        }
      });
    },
    // 申请提现弹出框
    withdrawalApply() {
      this.withdrawApplyModal = true;
      this.withdrawApplyFormData.minPrice = 1;
      this.withdrawApplyFormData.price = 1;
      this.withdrawApplyFormData.type = '';
      this.withdrawApplyFormData.realName = '';
      this.withdrawApplyFormData.connectNumber = '';
      withdrawalSettingVO().then((res) => {
        if (res.code === 200) {
          this.withdrawApplyFormData.minPrice = res.result.minPrice;
          this.withdrawApplyFormData.type = res.result.type;
          this.withdrawApplyFormData.price = 1;
        }
      });
    },
    // 提现
    withdrawal() {
      this.$refs['withdrawApplyFormData'].validate((valid) => {
        if (valid) {
          withdrawalApply(this.withdrawApplyFormData).then((res) => {
            if (res && res.success) {
              this.$Message.success('提现申请成功,关注提现状态');
              this.withdrawApplyModal = false;
              this.init(); // 余额查询
              this.getWithdrawApplyData(); // 提现记录
            }
          });
        }
      });
    }
  }
};
</script>
 
<style lang="scss" scoped>
.box {
  margin: 20px 0;
}
 
.page-size {
  margin: 15px 0px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
 
.account-price {
  font-weight: bold;
}
 
.subTips {
  margin-left: 10px;
}
 
.account-btns {
  margin: 10px 0;
}
 
.ivu-btn {
  margin: 0 4px;
}
 
</style>