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
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
<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 v-if="step===1">
            <div class="Code_ls">
                <h4>为了您的账户安全,需要进行短信验证</h4>
                <span>手机号码</span><span>{{userPhone}}</span>
            </div>
            <div id="code" class="code_input">
                <x-input placeholder="请输入短信验证码"
                         :max="6"
                         :min="6"
                         type="tel"
                         v-model.trim="code"
                         @input.native="inputChange"
                >
                </x-input>
                <span v-if="codeSecond===-1" @click="getCode">获取验证码</span>
                <span v-else class="count">{{codeSecond}}秒后重发</span>
            </div>
        </div>
        <div v-else>
            <group class="personInfo xInput">
                <x-input text-align="right" v-model.trim="newPwd" type="password" title="交易密码" :min="6" :max="6"
                         placeholder="请输入6位数字"
                         required @on-blur="checkNewPwd"></x-input>
                <x-input text-align="right" v-model.trim="confirmPwd" type="password" title="确认交易密码" :min="6" :max="6"
                         placeholder="请再次输入密码"
                         required @on-blur="checkConfirmPwd"></x-input>
            </group>
        </div>
        <div style="height: 20px"></div>
        <box gap="0 15px">
            <x-button type="primary" @click.native="handleUpStep">返回</x-button>
            <x-button v-if="step===1" type="primary" @click.native="loanCheckCode">下一步</x-button>
            <x-button v-else type="primary" @click.native="resetPwd">重置密码</x-button>
        </box>
        <div style="height: 20px"></div>
    </div>
</template>
 
<script>
    import {XHeader, Group, XInput, XButton, Box, md5} from 'vux';
    import validate from '../../../tool/validator';
    import fToast from '../../../tool/fToast';
    import SysApi from '../../../api/api'
    import statusCodeManage from '../../../api/statusCodeManage';
 
    export default {
        name: 'loanMessage',
        components: {XHeader, Group, XInput, XButton, Box},
        data() {
            return {
                code: '',//输入的验证码
                codeSecond: -1,//验证码倒计时
                step: 1,//当前步骤
                newPwd: '',//新交易密码
                confirmPwd: '',//确认交易密码
                token: ''//验证码校验成功返回token
            };
        },
        computed: {
            userPhone() {
                return validate.formatPhone(sessionStorage.newPhoneNum)
            },
            canClick() {
                return this.newPwd.length === 6 && this.confirmPwd.length === 6
            }
        },
        methods: {
            //返回跳转
            handleUpStep() {
                this.codeSecond = -1;
                this.$router.back()
            },
            //验证码输入框input事件
            inputChange() {
                setTimeout(() => {
                    if (this.code) {
                        this.code = this.code.replace(/[^\d]/g, '');
                    }
                }, 1);
            },
            //发送验证码,验证码倒计时
            getCode() {
                this.codeSecond = 60;
                let timer = setInterval(() => this.codeSecond === -1 ? clearInterval(timer) : this.codeSecond--, 1000);
                //调用发送验证码接口
                SysApi.loanSendCode({prodId: sessionStorage.prodId}).then(res => {
                }, err => {
                    statusCodeManage.showTipOfStatusCode(err);
                    this.codeSecond = -1
                })
            },
            //下一步按钮事件
            loanCheckCode() {
                if (validate.checkValEmpty(this.code)) {
                    fToast.toast('请输入验证码');
                    return false;
                }
                //调用发送验证码接口
                SysApi.loanCheckCode({
                    prodId: sessionStorage.prodId,
                    code: this.code,
                }).then(res => {
                    this.token = res.body.token;
                    this.step = 2;
                }, err => {
                    statusCodeManage.showTipOfStatusCode(err)
                })
            },
            //验证密码是否为纯6位数字
            checkPwd(pwd = this.oldPwd) {
                if (validate.checkValEmpty(pwd)) {
                    fToast.toast('请输入密码');
                    return false;
                } else {
                    let res = validate.checkVerifyCode(pwd);
                    if (!res) fToast.toast('请输入6位数字');
                    return res
                }
            },
            //检查新密码是否与确认密码相等
            checkConfirmPwd() {
                if (this.checkPwd(this.confirmPwd)) {
                    if (this.confirmPwd.length === 6 && this.newPwd !== this.confirmPwd) {
                        fToast.toast('确认密码不一致');
                        return true;
                    } else return false
                } else return true
            },
            // 确认修改按钮
            resetPwd() {
                if (this.checkConfirmPwd()) return;
                SysApi.resetPwd({
                    prodId: sessionStorage.prodId,
                    token: this.token,
                    newPwd: md5(sessionStorage.newPhoneNum + this.newPwd),
                    confirmPwd: md5(sessionStorage.newPhoneNum + this.confirmPwd),
                }).then(res => {
                    this.$router.push({path: '/bnd/loan/resetSuccess'});
                }, err => {
                    statusCodeManage.showTipOfStatusCode(err)
                })
            }
        },
        activated() {
            this.step = 1;
            this.code = '';
            this.newPwd = '';
            this.confirmPwd = '';
            this.getCode();
        }
    };
</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-wepay-flow {
        background-color: @color-white;
    }
 
    .left-arrow:before {
        border-color: @color-white;
    }
 
    .weui-cells__title {
        margin: 0 !important;
        font-size: 16PX !important;
    }
 
    .weui-input, .weui-cell__bd {
        font-size: @font-size-base;
    }
 
    .weui-label {
        font-size: @font-size-base;
    }
 
    .personInfo ::-webkit-input-placeholder { /* WebKit browsers */
        color: #bfbfbf;
    }
 
    .personInfo :-moz-placeholder { /* Mozilla Firefox 4 to 18 */
        color: #bfbfbf;
    }
 
    .personInfo ::-moz-placeholder { /* Mozilla Firefox 19+ */
        color: #bfbfbf;
    }
 
    .personInfo :-ms-input-placeholder { /* Internet Explorer 10+ */
        color: #bfbfbf;
    }
 
    .xInput {
        .weui-cell {
            height: 24px;
            .weui-cell__ft {
                font-size: 10px;
            }
        }
    }
 
    .header-space {
        height: 46px;
    }
 
    .loan-info-box .weui-cell_select .weui-select {
        padding-right: 2.5rem;
        direction: rtl;
    }
 
    .loan-info-box .weui-input {
        text-align: right;
    }
 
    .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);;
    }
 
    /*------------------------------*/
    .Code_ls {
        padding: 0.25rem 1.25rem;
        h4 {
            padding-bottom: 1.2rem;
            padding-top: 1rem;
            font-size: @font-size-medium;
            font-weight: normal;
            color: @color-text-primary;
        }
        span {
            color: @color-text-third;
            display: inline-block;
        }
        span:last-child {
            margin-left: 0.5rem;
        }
    }
 
    .vux-no-group-title {
        margin-top: 0.77rem !important;
    }
 
    .loan-info-box .currentStep .weui-wepay-flow__state {
        background-color: @color-primary;
        color: @color-white !important;
        line-height: 1rem;
    }
 
    .weui-wepay-flow__li.weui-wepay-flow__li .weui-wepay-flow__state {
        width: 1.33333rem;
        height: 1.33333rem;
        border-radius: 1.58333rem;
        color: @color-text-third;
        line-height: 1.33333rem;
    }
 
    .loan-info-box .weui-input {
        text-align: left;
    }
 
    .porcolor p {
        color: @color-primary;
    }
 
    #code.code_input {
        padding: 1rem 1.25rem;
        background-color: @color-white !important;
        font-size: @font-size-medium;
        overflow: hidden;
        .weui-cell {
            margin: 0px;
            padding: 0px;
            width: 69%;
            height: 24px;
            float: left;
            .weui-cell__bd {
                width: 70%;
                display: inline-block;
            }
            .weui-cell__ft {
                display: inline-block;
            }
        }
        input {
            border: none;
            width: 100%;
            text-align: left !important;
            outline: none;
            font-size: @font-size-medium;
        }
        span {
            display: inline-block;
            font-size: @font-size-medium;
            color: @color-text-third;
            padding: 0.25rem 0;
            border-left: 1px solid @color-text-third;
            text-align: center;
            width: 30%;
            float: left;
        }
 
    }
 
    .weui-cell__ft button {
        background-color: @color-white !important;
    }
 
    .weui-btn:after {
        border: none !important;
    }
 
    .weui-btn {
        font-size: @font-size-primary !important;
    }
</style>