Authored by jiran.zhao

申请提现

@@ -3,11 +3,27 @@ export default function() { @@ -3,11 +3,27 @@ export default function() {
3 form: '', 3 form: '',
4 showLoading: true, 4 showLoading: true,
5 data: { 5 data: {
6 - seasons: '',  
7 - productIntro: '', 6 + applyType: 0,
8 }, 7 },
  8 + beginStr: '',
  9 + endStr: '',
  10 + beginTimeStr: '',
  11 + endTimeStr: '',
9 ruleValidate: { 12 ruleValidate: {
10 productName: [{ required: true, message: '商品名不能为空', trigger: 'blur' }], 13 productName: [{ required: true, message: '商品名不能为空', trigger: 'blur' }],
11 }, 14 },
  15 + apply: {
  16 + shopId: '',
  17 + applyPid: '',
  18 + applyAmount: '',
  19 + applyType: 0,
  20 + beginTime: '',
  21 + endTime: '',
  22 + applyPhone: '',
  23 + targetAccount: '',
  24 + token: '',
  25 + timestamp: '',
  26 + salt: 'fd4ad5fcsa0de589af23234ks1923ks',
  27 + },
12 }; 28 };
13 } 29 }
@@ -10,21 +10,28 @@ @@ -10,21 +10,28 @@
10 <span class="red">*支付宝每日转账最高限额10万元人民币,单日超过10万人民币限额的,请联系平台客服</span> 10 <span class="red">*支付宝每日转账最高限额10万元人民币,单日超过10万人民币限额的,请联系平台客服</span>
11 </Form-item> 11 </Form-item>
12 <Form-item label="提现方式"> 12 <Form-item label="提现方式">
13 - <span>最大可提现</span><span>{{ formatDate(data.billBeginTime) }}</span> 13 + <span>最大可提现</span><span>{{ beginTimeStr }}</span>
14 ~ 14 ~
15 - <span>{{ formatDate(data.billEndTime) }}</span> 15 + <span>{{ endTimeStr }}</span>
16 <br /> 16 <br />
17 <span>请选择账单日期</span> 17 <span>请选择账单日期</span>
18 <Date-picker 18 <Date-picker
19 - :value="data.range"  
20 - type="datetimerange" 19 + v-model="beginStr"
  20 + type="date"
21 format="yyyy-MM-dd" 21 format="yyyy-MM-dd"
22 placeholder="选择日期时间" 22 placeholder="选择日期时间"
23 - @on-change="clickAvailableDate" 23 + @on-change="changeTimeStr"
  24 + />
  25 + <Date-picker
  26 + v-model="endStr"
  27 + type="date"
  28 + format="yyyy-MM-dd"
  29 + placeholder="选择日期时间"
  30 + @on-change="changeTimeStr"
24 /> 31 />
25 </Form-item> 32 </Form-item>
26 <Form-item label="提现金额"> 33 <Form-item label="提现金额">
27 - <input :value="data.availableAmount" placeholder="请输入..." /> 34 + <input :value="data.withdrawAmount" placeholder="请输入..." />
28 </Form-item> 35 </Form-item>
29 <Form-item label="提现到帐号"> 36 <Form-item label="提现到帐号">
30 <span>{{ data.withdrawAccount }}</span> 37 <span>{{ data.withdrawAccount }}</span>
@@ -37,16 +44,15 @@ @@ -37,16 +44,15 @@
37 </Form-item> 44 </Form-item>
38 <Form-item> 45 <Form-item>
39 <Button id="btnSubmit" type="primary" size="large" @click="save">确认提现</Button> 46 <Button id="btnSubmit" type="primary" size="large" @click="save">确认提现</Button>
40 - <Button type="primary" size="large">联系客服</Button>  
41 - <Button id="cancel" type="primary" size="large">联系客服</Button> 47 + <Button id="cancel" type="primary" size="large" @click="backList">取消</Button>
42 </Form-item> 48 </Form-item>
43 </Form> 49 </Form>
44 </layout-body> 50 </layout-body>
45 </template> 51 </template>
46 52
47 <script> 53 <script>
48 -import _ from 'lodash';  
49 import moment from 'moment'; 54 import moment from 'moment';
  55 +import crypto from 'util/crypto';
50 import FinanceService from 'services/finance/finance-service'; 56 import FinanceService from 'services/finance/finance-service';
51 import { WithdrawApply } from './store'; 57 import { WithdrawApply } from './store';
52 58
@@ -54,21 +60,36 @@ export default { @@ -54,21 +60,36 @@ export default {
54 data() { 60 data() {
55 return WithdrawApply.call(this); 61 return WithdrawApply.call(this);
56 }, 62 },
  63 + // watch: {
  64 + // beginTimeStr() {
  65 + // this.getAvailableAmount();
  66 + // },
  67 + // },
57 created() { 68 created() {
58 const params = { 69 const params = {
59 token: this.$user.token, 70 token: this.$user.token,
60 timestamps: Math.round(new Date().getTime() / 1000), 71 timestamps: Math.round(new Date().getTime() / 1000),
61 }; 72 };
62 this.financeService = new FinanceService(); 73 this.financeService = new FinanceService();
63 - this.financeService.shopWithdrawApplyInit(params).then(result => {  
64 - if (result.code === 200) {  
65 - Object.assign(this.data, result.data);  
66 - }  
67 - });  
68 - },  
69 - mounted() {  
70 - this.getInfo(); 74 + this.financeService
  75 + .shopWithdrawApplyInit(params)
  76 + .then(result => {
  77 + if (result.code === 200) {
  78 + this.data = result.data;
  79 + this.beginStr = this.formatDate(result.data.billBeginTime);
  80 + this.endStr = this.formatDate(result.data.billEndTime);
  81 + this.beginTimeStr = this.formatDate(result.data.billBeginTime);
  82 + this.endTimeStr = this.formatDate(result.data.billEndTime);
  83 + this.data.beginTime = result.data.billBeginTime;
  84 + this.data.endTime = result.data.billEndTime;
  85 + }
  86 + })
  87 + .catch(() => {
  88 + this.$Message.error('请求出错');
  89 + this.showLoading = false;
  90 + });
71 }, 91 },
  92 + mounted() {},
72 methods: { 93 methods: {
73 backList() { 94 backList() {
74 this.$router.push({ name: 'finance.withdraw.withdrawlist' }); 95 this.$router.push({ name: 'finance.withdraw.withdrawlist' });
@@ -93,23 +114,27 @@ export default { @@ -93,23 +114,27 @@ export default {
93 }); 114 });
94 }, 115 },
95 beforeSave() { 116 beforeSave() {
96 - const newApply = {};  
97 - newApply.availableAmount = this.data.availableAmount;  
98 - newApply.applyType = this.data.applyType;  
99 - newApply.beginTime = this.data.beginTime;  
100 - newApply.endTime = this.data.endTime;  
101 - newApply.applyAmount = this.data.applyAmount;  
102 - newApply.targetAccount = this.data.targetAccount;  
103 - newApply.remarks = this.data.remarks;  
104 - newApply.timestamp = this.data.timestamp;  
105 - newApply.token = this.data.token;  
106 - newApply.sign = this.data.sign;  
107 - return newApply; 117 + this.apply.shopId = this.$user.currentShop.shopsId;
  118 + this.apply.applyPid = this.$user.pid;
  119 + this.apply.applyAmount = this.data.withdrawAmount;
  120 + this.apply.applyType = this.data.applyType;
  121 + this.apply.beginTime = this.data.beginTime;
  122 + this.apply.endTime = this.data.endTime;
  123 + this.apply.applyPhone = this.data.accountPhone;
  124 + this.apply.targetAccount = this.data.withdrawAccount;
  125 + this.apply.token = this.$user.token;
  126 + this.apply.timestamp = Math.round(new Date().getTime() / 1000);
  127 + const params = this.apply;
  128 + const arrParams = Object.keys(params).map(key => {
  129 + return this.apply[key];
  130 + });
  131 + this.apply.sign = crypto.md5(arrParams.join('|'));
  132 + this.apply.account = this.$user.name;
108 }, 133 },
109 save() { 134 save() {
110 - const newApply = this.beforeSave(); 135 + this.beforeSave();
111 this.$Loading.start(); 136 this.$Loading.start();
112 - return this.financeService.shopWithdrawApply(newApply).then(result => { 137 + return this.financeService.shopWithdrawApply(this.apply).then(result => {
113 if (result.code === 200) { 138 if (result.code === 200) {
114 this.$Loading.finish(); 139 this.$Loading.finish();
115 this.$Notice.success({ 140 this.$Notice.success({
@@ -147,38 +172,14 @@ export default { @@ -147,38 +172,14 @@ export default {
147 return moment.unix(date).format('YYYY-MM-DD'); 172 return moment.unix(date).format('YYYY-MM-DD');
148 } 173 }
149 }, 174 },
150 - clickAvailableDate(time) {  
151 - if (!_.isArray(time)) {  
152 - time = time.split(' - ');  
153 - }  
154 - if ((time[0] + '').length) {  
155 - const billBeginStr = moment.unix(this.data.billBeginTime).format('YYYY-MM-DD');  
156 - const billEndStr = moment.unix(this.data.billEndTime).format('YYYY-MM-DD');  
157 - if (time[0] < billBeginStr || time[1] > billEndStr) {  
158 - this.data.beginTime = '';  
159 - this.data.endTime = '';  
160 - this.$Notice.error({  
161 - title: '时间选择错误',  
162 - desc: '请选择范围内时间',  
163 - });  
164 - }  
165 - this.data.beginTime = time[0];  
166 - this.data.endTime = time[1];  
167 - this.getAvailableAmount();  
168 - } else {  
169 - this.data.beginTime = '';  
170 - this.data.endTime = '';  
171 - }  
172 - },  
173 getAvailableAmount() { 175 getAvailableAmount() {
174 const params = {}; 176 const params = {};
175 - params.beginTime = this.data.beginTime;  
176 - params.endTime = this.data.endTime; 177 + params.beginTime = this.beginStr;
  178 + params.endTime = this.endStr;
177 this.financeService.shopGetAvailableAmount(params).then(result => { 179 this.financeService.shopGetAvailableAmount(params).then(result => {
178 if (result.code === 200) { 180 if (result.code === 200) {
179 - this.data.availableAmount = result.availableAmount; 181 + this.data.withdrawAmount = result.data.availableAmount;
180 } else { 182 } else {
181 - this.$Loading.error();  
182 this.$Notice.error({ 183 this.$Notice.error({
183 title: '查询错误', 184 title: '查询错误',
184 desc: result.message, 185 desc: result.message,
@@ -186,6 +187,7 @@ export default { @@ -186,6 +187,7 @@ export default {
186 } 187 }
187 }); 188 });
188 }, 189 },
  190 + changeTimeStr() {},
189 }, 191 },
190 }; 192 };
191 </script> 193 </script>
@@ -134,7 +134,7 @@ class FinanceService extends Service { @@ -134,7 +134,7 @@ class FinanceService extends Service {
134 * @returns {Promise<unknown>} 134 * @returns {Promise<unknown>}
135 */ 135 */
136 shopGetAvailableAmount(params) { 136 shopGetAvailableAmount(params) {
137 - return this.post(apiUrl.shopWithdrawApply, params); 137 + return this.post(apiUrl.shopGetAvailableAmount, params);
138 } 138 }
139 139
140 /** 140 /**
@@ -65,6 +65,7 @@ class UserController extends Context { @@ -65,6 +65,7 @@ class UserController extends Context {
65 pwdComplexRateDesc: user.pwdComplexRateDesc, 65 pwdComplexRateDesc: user.pwdComplexRateDesc,
66 needUpdate, 66 needUpdate,
67 token: user.token, 67 token: user.token,
  68 + pid: user.pid,
68 }, 69 },
69 }); 70 });
70 }); 71 });