zhaoxiaoqiang
2021-05-18 d12b432f4a009d87a9946ae81bdea5c9895a2bfe
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
<!--
 * @Author: 小明丶
 * @Date: 2019-08-20 18:12:00
 * @LastEditors: 小明丶
 * @LastEditTime: 2020-11-19 16:41:42
 * @Description: 
 -->
<!--
    修改密码
-->
<template>
  <div class="reset-pwd h-100-g">
    <v-navbar title="修改密码" fixed></v-navbar>
 
 
    <div class="cell-group">
      <v-cell v-model="form.oldPwd" label='原密码' placeholder="请输入原密码"></v-cell>
      <v-cell v-model="form.newPwd" label='新密码' placeholder="请输入8-16位数字字母组合密码"></v-cell>
      <v-cell v-model="form.rePwd" label='确认新密码' placeholder="请再次输入新密码"></v-cell>
    </div>
 
 
    <footer class="flex-center-g footer">
      <van-button class="btn" :color="$store.state.backColor" @click="reSetPwd">确认修改</van-button>
    </footer>
  </div>
</template>
 
<script>
  import md5 from 'blueimp-md5';
   import {
    SET_SESSION_ID,
    SET_USER_INFO
  } from '@/store/mutations-types';
  import {
    mapState,
    mapMutations
  } from 'vuex';
  export default {
    name: "reset-pwd",
    data() {
      return {
        form: {
          oldPwd: '',
          newPwd: '',
          rePwd: ''
        },
 
        rule: [{
            key: "oldPwd",
            message: "请输入原密码",
            type: "isEmpty"
          },
          {
            key: "newPwd",
            message: "请输入新密码",
            type: "isEmpty"
          },
          {
            key: "newPwd",
            message: "请设置8-16位数字+字母组合密码",
            type: "isPassword"
          },
        ]
      }
    },
    computed: {
      ...mapState(['userinfo'])
    },
    methods: {
      ...mapMutations([SET_USER_INFO, SET_SESSION_ID]),
      // 验证form参数
      validatorForm() {
        return this.$validator(this.form, this.rule).check(item => {
          this.$notify(item.message)
        })
      },
 
      reSetPwd() {
        if (!this.validatorForm()) return
        if (this.form.newPwd === this.form.oldPwd) {
          this.$notify('新密码不能与旧密码相同');
          return;
        }
        if (this.form.newPwd !== this.form.rePwd) {
          this.$notify('两次输入新密码不一致');
          return;
        }
 
        let _mblNo = this.userinfo.mblNo;
        let obj = {
          newPwd: md5(_mblNo + this.form.newPwd),
          oldPwd: md5(_mblNo + this.form.oldPwd)
        };
        this.$api.userUpdatePwd(obj).then(res => {
          this.$notify('修改成功!')
          //删除信息 重新登录
          this.SET_USER_INFO({});
          this.SET_SESSION_ID('');
          localStorage.removeItem('user_account')
          localStorage.removeItem('user_pwd')
          if(sessionStorage.isddxt == 1){
            this.$router.push('/?platNo=ddxt')
          }else{
            this.$router.push('/')
          }
          
        })
      },
    }
  }
</script>
 
<style scoped lang="less">
  .reset-pwd {
    padding-top: 44px;
    background-color: @c-f5;
 
    .cell-group {
      margin: 10px auto 0 auto;
      width: 360px;
    }
 
 
    .btn {
      width: 340px;
      height: 44px;
      border: none;
      font-size: @font-16;
      border-radius: 22px;
      background-color: @c-bg-default;
      color: @c-text-fff;
 
    }
 
    .footer {
      margin-top: 25px;
      padding-bottom: 30px;
    }
 
  }
</style>