ann0707
2018-08-16 c9bc8ec61cff4076132f6396d99d383a2cdf5a03
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
<template>
    <div class="loan-info-box">
        <x-header slot="header"
                  style="width:100%;height:46px;background-color: #ec6758; "
                  title="借款"
                  :left-options="{backText: ''}">
        </x-header>
        <div class="loan_jiekuan">
            <h4>按日计息,日利率{{loanInfo.dayRate}}%,单笔最低贷款1,000元</h4>
            <div>
                <img src="../../../assets/imgs/yinghangbiaozhi.jpg" alt="">
                <span>{{loanInfo.bankName}}</span><span>({{loanInfo.bankCardNo}})</span>
            </div>
        </div>
        <group class="personInfo" text-align="right">
            <div class="loanMoney_l">
                <p>贷款金额</p>
                <!--(可贷金额:<b style="color: #0092f1;">{{loanInfo.creditLimitAvailable|formatMoney}}</b>元)-->
                <div class="inputBox">
                    <x-input v-model.trim="loanAmt" type="tel" title="¥" placeholder="请输入贷款金额"
                             required @on-blur="trial" @input.native="inputChange"></x-input>
                    <span @click="loanAmt=loanInfo.creditLimitAvailable">全部借出</span>
                </div>
            </div>
            <selector title="还款期数" :options="loanTermList" placeholder="请选择"
                      v-model="loanTerm" @on-change="trial"></selector>
            <selector title="贷款用途" :options="loanUseList" placeholder="请选择"
                      v-model="loanUse" @on-change="trial"></selector>
            <cell title="还款方式">{{loanInfo.repayType}}</cell>
            <cell title="首次还款日">{{showFormDate(repayTrial.firstRepayDay)}}</cell>
            <cell title="固定还款日">暂定</cell>
            <cell title="每期还款金额">{{repayTrial.repayAmt|formatMoney}}</cell>
        </group>
        <div style="height: 40px"></div>
        <box gap="0 15px">
            <x-button v-if="canClick" type="primary" @click.native="goQoutaInfo">下一步</x-button>
            <x-button v-else type="" @click.native="clickTips">下一步</x-button>
        </box>
        <div class="nuber_l">客户热线:<span>{{loanInfo.customerHotline}}</span></div>
        <div style="height: 20px"></div>
    </div>
</template>
 
<script>
    import {
        XHeader,
        XInput,
        Group,
        Cell,
        Selector,
        XButton,
        Box
    } from 'vux';
    import SysApi from '../../../api/api';
    import validate from '../../../tool/validator';
    import fToast from '../../../tool/fToast';
    import statusCodeManage from '../../../api/statusCodeManage';
    import formDate from '../../../tool/date';
 
    export default {
        name: 'loanInfo',
        components: {
            XHeader,
            Group,
            XInput,
            Cell,
            Selector,
            XButton,
            Box
        },
        data() {
            return {
                //贷款信息数据
                loanInfo: {},
                //贷款用途列表
                loanUseList: [],
                //当前选择的贷款用途
                loanUse: null,
                //还款期数列表
                loanTermList: [],
                //当前选择的还款期数
                loanTerm: null,
                //当前输入的贷款金额
                loanAmt: null,
                //借款试算结果
                repayTrial: {}
            };
        },
        filters: {
            // 金额格式化
            formatMoney(val) {
                return validate.formatMoney(val) + '元'
            }
        },
        computed: {
            canClick() {
                return this.loanAmt && Number(this.loanAmt) % 100 === 0 && this.loanUse && this.loanTerm
            }
        },
        methods: {
            //格式化日期
            showFormDate(dateTime) {
                return formDate(dateTime, 'MM-DD') || '暂定';
            },
            //贷款金额输入框input事件,过滤非数字、不是整百
            inputChange() {
                setTimeout(() => {
                    if (this.loanAmt) {
                        if (this.loanAmt.length > 9) {
                            this.loanAmt = this.loanAmt.substring(0, 9);
                        } else {
                            this.loanAmt = this.loanAmt.replace(/[^\d]/g, '');
                            if (Number(this.loanAmt) > Number(this.loanInfo.creditLimitAvailable)) {
                                this.loanAmt = this.loanInfo.creditLimitAvailable
                            }
                        }
                    }
                }, 1);
            },
            //未填写数据时,文字提示
            clickTips() {
                if (validate.checkValEmpty(this.loanAmt)) {
                    fToast.toast('请输入贷款金额');
                    return;
                } else if (Number(this.loanAmt) % 100) {
                    fToast.toast('请输入整百贷款金额');
                    return;
                }
                if (validate.checkValEmpty(this.loanTerm)) {
                    fToast.toast('请选择还款期数');
                    return;
                }
                if (validate.checkValEmpty(this.loanUse)) {
                    fToast.toast('请选择贷款用途');
                }
            },
            //跳转到【贷款信息确认】页面
            goQoutaInfo() {
                sessionStorage.loanInfo = JSON.stringify(Object.assign({}, this.loanInfo, this.repayTrial, {
                    loanAmt: this.loanAmt,
                    loanTerm: this.loanTerm,
                    loanUse: this.loanUse,
                    repayType: '等额本息'
                }));
                this.$router.push({path: '/bnd/loan/quotaInfo'});
            },
            //借款试算接口
            trial() {
                if (Number(this.loanAmt) % 100) {
                    fToast.toast('请输入整百贷款金额');
                } else {
                    if (this.canClick) {
                        SysApi.trial({
                            prodId: sessionStorage.prodId,
                            loanAmt: this.loanAmt,
                            loanTerm: this.loanTerm
                        }).then(res => {
                            this.repayTrial = res.body
                        }, err => {
                            statusCodeManage.showTipOfStatusCode(err)
                        })
                    }
                }
            },
            // 得到选项列表统一的方法
            getOptionsList(optionList) {
                let tmpList = [];
                if (optionList instanceof Array) {
                    optionList.forEach(function (item) {
                        tmpList.push({
                            key: item.code,
                            value: item.name
                        });
                    });
                }
                return tmpList;
            },
            // 初始化我的贷款页面接口:获取【我的贷款】信息:如可用额度、总额度等等
            initMyLoan() {
                this.loanInfo = JSON.parse(sessionStorage.loanInfo);
                this.loanInfo.repayType = '等额本息';
                this.loanUseList = this.getOptionsList(this.loanInfo.loanUseList);
                this.loanTermList = this.getOptionsList(this.loanInfo.loanTermList);
            }
        },
        activated() {
            this.initMyLoan()
        }
    };
</script>
 
<style lang="less">
    @import "../../../style/mixin.less";
 
    .loan-info-box {
        background-color: @color-background-default;
        .vux-header {
            .color-linear-gradient(@color-primary-light, @color-primary, 90deg);
            .vux-header-left {
                .left-arrow:before {
                    border: solid 1px @color-white;
                    border-width: 2px 0 0 2px;
                }
            }
        }
        .weui-cells {
            margin-top: 0;
        }
    }
 
    .weui-input, .weui-cell__bd {
        font-size: @font-size-base;
    }
 
    .weui-label {
        font-size: @font-size-base;
    }
 
    .loan-info-box .weui-cell_select .weui-select {
        padding-right: 2.5rem;
        direction: rtl;
        font-size: @font-size-medium;
    }
 
    .loan-info-box .weui-btn_primary {
        .color-linear-gradient(@color-primary-light, @color-primary, 90deg);
    }
 
    .loan-info-box .weui-btn_primary:not(.weui-btn_disabled):active {
        color: rgba(255, 255, 255, 0.6);
        background-color: rgb(241, 95, 79);;
    }
 
    /*------------------------------*/
 
    .nuber_l {
        text-align: center;
        font-size: @font-size-medium;
        width: 100%;
        height: 2.5rem;
        padding-top: 3rem;
        span {
            display: inline-block;
            color: @color-primary;
            text-decoration: underline;
        }
    }
 
    .loan_jiekuan {
        h4 {
            color: @color-text-third;
            font-size: @font-size-small;
            font-weight: normal;
            padding: 0.5rem 1rem;
        }
        div {
            padding: 1rem;
            background: @color-white;
        }
        div > img {
            width: 1.25rem;
            height: 1.25rem;
            vertical-align: middle;
            padding-right: 0.5rem;
        }
        div > span {
            font-size: @font-size-base;
            vertical-align: middle;
        }
    }
 
    .vux-label {
        font-size: @font-size-base !important;
    }
 
    .weui-cell__ft {
        font-size: @font-size-medium !important;
        color: @color-black !important;
    }
 
    .loanMoney_l {
        padding: 1rem 1.25rem;
        padding-bottom: 0;
        position: relative;
        p {
            font-size: @font-size-base;
            padding-bottom: 0.5rem;
        }
        .inputBox {
            display: flex;
            align-items: center;
            justify-content: space-between;
            .weui-cell {
                padding: 0.83333rem 0;
            }
            span {
                width: 80px;
                text-align: right;
                font-size: @font-size-medium;
                color: @color-primary;
            }
        }
 
    }
 
    .weui-btn:after {
        border: none !important;
    }
 
    .weui-btn {
        font-size: @font-size-primary !important;
    }
 
</style>