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
<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="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 style="height: 20px"></div>
        <box class="btn" gap="0 15px">
            <x-button type="primary" link="BACK">上一步</x-button>
            <x-button :type="code.length===6?'primary':''" :disabled="code.length!==6" @click.native="checkCode">确认贷款
            </x-button>
        </box>
        <div style="height: 20px"></div>
    </div>
</template>
 
<script>
    import {XHeader, XInput, XButton, Box} 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, XInput, XButton, Box},
        data() {
            return {
                code: '',//输入的验证码
                codeSecond: -1,//验证码倒计时秒数
            };
        },
        computed: {
            userPhone() {
                return validate.formatPhone(sessionStorage.newPhoneNum)
            }
        },
        methods: {
            //验证码输入框input事件,过滤非数字
            inputChange() {
                setTimeout(() => {
                    if (this.code) this.code = this.code.replace(/[^\d]/g, '');
                }, 1);
            },
            //确认贷款按钮事件
            checkCode() {
                if (validate.checkValEmpty(this.code)) {
                    fToast.toast('请输入验证码');
                    return;
                }
                //调用校验验证码接口
                SysApi.checkCode({
                    prodId: sessionStorage.prodId,
                    code: this.code,
                    codeType: 3
                }).then(res => {
                    this.$router.push({path: '/bnd/loan/subSuccess'});
                }, err => {
                    statusCodeManage.showTipOfStatusCode(err)
                })
            },
            //发送验证码、验证码倒计时
            getCode() {
                this.codeSecond = 60;
                let timer = setInterval(() => this.codeSecond === -1 ? clearInterval(timer) : this.codeSecond--, 1000);
                //调用发送验证码接口
                SysApi.resendCode({
                    prodId: sessionStorage.prodId,
                    codeType: 3
                }).then(res => {
                }, err => {
                    statusCodeManage.showTipOfStatusCode(err);
                    this.codeSecond = -1
                })
            },
        },
        activated() {
            this.codeSecond = 60;
            let timer = setInterval(() => this.codeSecond === -1 ? clearInterval(timer) : this.codeSecond--, 1000);
        }
    };
</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;
                }
            }
        }
    }
 
    .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;
        }
    }
 
    #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%;
            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>