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
<template>
    <div class="update-page">
        <x-header :left-options="{backText: ''}" class="gradient-color">修改密码</x-header>
        <group class="update-input" label-width="73px">
            <x-input title="原密码"
                     placeholder="请输入原密码"
                     :min="8"
                     :max="16"
                     :type="showPwd1"
                     :novalidate="true"
                     v-model="oldPassword">
                <i slot="right" @click="changePwd(1)" class="iconfont"
                   :class='{"icon-eye":showPwd1=="text","icon-hide":showPwd1=="password"}'></i>
            </x-input>
            <x-input title="新密码"
                     :type="showPwd2"
                     v-model="newPassword"
                     :min="8"
                     :max="16"
                     :novalidate="true"
                     placeholder="请输入密码"
                     class="password">
                <i slot="right" @click="changePwd(2)" class="iconfont"
                   :class='{"icon-eye":showPwd2=="text","icon-hide":showPwd2=="password"}'></i>
            </x-input>
            <x-input title="确认密码"
                     :type="showPwd3"
                     v-model="confirmPassword"
                     :novalidate="true"
                     :min="8"
                     :max="16"
                     placeholder="请再次确认密码"
                     class="password">
                <i slot="right" @click="changePwd(3)" class="iconfont"
                   :class='{"icon-eye":showPwd3=="text","icon-hide":showPwd3=="password"}'></i>
            </x-input>
        </group>
        <FButton :text="'确认修改'" @on-click-button="changeBut"></FButton>
    </div>
</template>
 
<script>
    import {XButton, XInput, Group, Flexbox, FlexboxItem, XHeader, md5} from 'vux';
    import FButton from'../../components/common/FButton';
    import validate from '../../tool/validator';
    import SysApi from '../../api/api';
    import statusCodeManage from '../../api/statusCodeManage';
    import initData from '../../tool/initData';
    /**
     * Created by z.x.q on 2018/3/22.
     * 我的--登录
     */
    export default {
        name: 'f-update-password',
        components: {
            XButton, XInput, Group, Flexbox, FlexboxItem, FButton, XHeader
        },
        data(){
            return {
                showPwd1: 'password',
                showPwd2: 'password',
                showPwd3: 'password',
                oldPassword: '',
                newPassword: '',
                confirmPassword: ''
            }
        },
        methods: {
            changePwd(which){
                if (this[`showPwd${which}`] === 'password') {
                    this[`showPwd${which}`] = 'text';
                } else {
                    this[`showPwd${which}`] = 'password';
                }
            },
            changeBut(){
                if (validate.checkValEmpty(this.oldPassword)) {
                    this.$vux.toast.text('请输入原密码', 'middle');
                    return;
                }
                if (validate.checkValEmpty(this.newPassword)) {
                    this.$vux.toast.text('请输入新密码', 'middle');
                    return;
                }
                if (validate.checkValEmpty(this.confirmPassword)) {
                    this.$vux.toast.text('请输入确认密码', 'middle');
                    return;
                }
                if (!validate.checkPassword(this.oldPassword)) {
                    this.$vux.toast.text('请输入正确的密码', 'middle');
                    return;
                }
                if (!validate.checkPassword(this.newPassword)) {
                    this.$vux.toast.text('请设置8-16位数字+字母组合密码', 'middle');
                    return;
                }
                if (!validate.checkPassword(this.confirmPassword)) {
                    this.$vux.toast.text('请输入正确的确认密码', 'middle');
                    return;
                }
                if (this.newPassword !== this.confirmPassword) {
                    this.$vux.toast.text('新密码与确认密码不同', 'middle');
                    return;
                }
                let mblNo = window.sessionStorage.getItem('newPhoneNum');
                let obj = {
                    mblNo: mblNo,
                    oldPassword: md5(mblNo + this.oldPassword),
                    newPassword: md5(mblNo + this.newPassword)
                };
                SysApi.editPwd(obj).then(
                    res => {
                        this.$vux.toast.show({
                            width: '80%',
                            type: 'text',
                            text: '修改成功',
                            time: 1500,
                            position: 'middle',
                            onHide: () => {
                                window.sessionStorage.removeItem('newSid')
                                window.sessionStorage.removeItem('newPhoneNum')
                                window.sessionStorage.removeItem('newClientState')
                                this.$router.push({name: 'f-login'});
 
                            }
                        })
                    },
                    err => {
                        statusCodeManage.showTipOfStatusCode(err, this);
                    }
                )
            }
        },
        activated () {
            this.$store.commit('UPDATE_DIRECTION', {direction: 'in'});
        },
        deactivated(){
            this.$store.commit('UPDATE_DIRECTION', {direction: 'none'});
            this.showPwd1 = this.showPwd2 = this.showPwd3 = 'password';
            initData(['oldPassword', 'newPassword', 'confirmPassword'], this);
        }
    }
</script>
 
<style lang="less" rel="stylesheet/less">
    @import "../../style/mixin.less";
 
    .update-page {
        background-color: @color-background-default;
        .vux-header {
            .color-linear-gradient(@color-primary-light, @color-primary, 90deg);
            .vux-header-title {
                font-size: 18px;
            }
            .vux-header-left {
                .left-arrow:before {
                    border: solid 1px @color-white;
                    border-width: 2px 0 0 2px;
                }
            }
            .vux-header-right {
                color: @color-white !important;
            }
        }
        .update-input {
            .weui-cells {
                margin-top: 0;
                background-color: @color-background-default;
                .weui-cell {
                    height: 23px;
                    background-color: @color-white;
                    border-bottom: 1px solid @color-disabled;
                    font-size: @font-size-base;
                    &:last-child {
                        border-bottom: transparent;
                    }
                    &:first-child {
                        margin-top: 10px;
                    }
                }
                .weui-cell:before {
                    display: none;
                }
            }
            .weui-cells:before {
                display: none;
            }
            .weui-cells:after {
                display: none;
            }
        }
        .input-other {
            font-size: @font-size-medium;
            .flexLayout(space-between, center, row);
            span {
                &:first-child {
                    color: @color-text-secondary;
                }
                &:nth-child(2) {
                    color: @color-primary;
                }
            }
        }
    }
 
</style>