Jacob
1 天以前 433c5ab2fd2a6fd48fb931b5070b742503a99a6b
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
<template>
   <view>
       <view class="ChangePassword">
           <form @submit="editPwd" report-submit='true'>
               <view class="phone">当前手机号:{{phone}}</view>
               <view class="list">
                   <view class="item">
                       <input type='password' placeholder='以字母开头,长度在6~18之间,只能包含字符、数字和下划线' placeholder-class='placeholder' name="password" :value="password"></input>
                   </view>
                   <view class="item">
                       <input type='password' placeholder='确认新密码' placeholder-class='placeholder' name="qr_password" :value="qr_password"></input>
                   </view>
                   <view class="item acea-row row-between-wrapper">
                       <input type='number' placeholder='填写验证码' placeholder-class='placeholder' class="codeIput" name="captcha" :value="captcha"></input>
                       <button class="code font-color" :class="disabled === true ? 'on' : ''" :disabled='disabled' @click="code">
                           {{ text }}
                       </button>
                   </view>
               </view>
               <button form-type="submit" class="confirmBnt bg-color">确认修改</button>
           </form>
       </view>
       <!-- #ifdef MP -->
       <!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
       <!-- #endif -->
   </view>
</template>
 
<script>
   import sendVerifyCode from "@/mixins/SendVerifyCode";
   import {
       phoneRegisterReset,
       registerVerify
   } from '@/api/api.js';
   import {
       getUserInfo
   } from '@/api/user.js';
   import {
       toLogin
   } from '@/libs/login.js';
   import {
       mapGetters
   } from "vuex";
   export default {
       mixins: [sendVerifyCode],
       components: {
       },
       data() {
           return {
               userInfo: {},
               phone: '',
               password: '',
               captcha: '',
               qr_password: '',
               isAuto: false, //没有授权的不会自动授权
               isShowAuth: false //是否隐藏授权
           };
       },
       computed: mapGetters(['isLogin']),
       watch:{
           isLogin:{
               handler:function(newV,oldV){
                   if(newV){
                       this.getUserInfo();
                   }
               },
               deep:true
           }
       },
       onLoad() {
           if (this.isLogin) {
               this.getUserInfo();
           } else {
               toLogin(this);
           }
       },
       methods: {
           /**
            * 授权回调
            */
           onLoadFun: function(e) {
               this.getUserInfo();
           },
           // 授权关闭
           authColse: function(e) {
               this.isShowAuth = e
           },
           /**
            * 获取个人用户信息
            */
           getUserInfo: function() {
               let that = this;
               getUserInfo().then(res => {
                   let tel = res.data.phone;
                   let phone = tel.substr(0, 3) + "****" + tel.substr(7);
                   that.$set(that, 'userInfo', res.data);
                   that.phone = phone;
               });
           },
           /**
            * 发送验证码
            * 
            */
           async code() {
               let that = this;
               if (!that.userInfo.phone) return that.$util.Tips({
                   title: '手机号码不存在,无法发送验证码!'
               });
               await registerVerify(that.userInfo.phone).then(res => {
                   that.$util.Tips({
                       title: res.message
                   });
                   that.sendCode();
               }).catch(err => {
                   return that.$util.Tips({
                       title: (err&&err.message)?err.message:err
                   });
               });
           },
 
           /**
            * H5登录 修改密码
            * 
            */
           editPwd: function(e) {
               let that = this,
                   password = e.detail.value.password,
                   qr_password = e.detail.value.qr_password,
                   captcha = e.detail.value.captcha;
               if (!password) return that.$util.Tips({
                   title: '请输入新密码'
               });
               if (!/^[a-zA-Z]\w{5,17}$/i.test(password)) return that.$util.Tips({
                   title: '以字母开头,长度在6~18之间,只能包含字符、数字和下划线'
               });
               if (qr_password != password) return that.$util.Tips({
                   title: '两次输入的密码不一致!'
               });
               if (!captcha) return that.$util.Tips({
                   title: '请输入验证码'
               });
               phoneRegisterReset({
                   account: that.userInfo.phone,
                   captcha: captcha,
                   password: password
               }).then(res => {
                   return that.$util.Tips({
                       title: res.message
                   }, {
                       tab: 3,
                       url: 1
                   });
               }).catch(err => {
                   return that.$util.Tips({
                       title: (err&&err.message)?err.message:err
                   });
               });
           }
       }
   }
</script>
 
<style lang="scss">
   page {
       background-color: #fff !important;
   }
 
   .ChangePassword .phone {
       font-size: 32rpx;
       font-weight: bold;
       text-align: center;
       margin-top: 55rpx;
   }
 
   .ChangePassword .list {
       width: 580rpx;
       margin: 53rpx auto 0 auto;
   }
 
   .ChangePassword .list .item {
       width: 100%;
       height: 110rpx;
       border-bottom: 2rpx solid #f0f0f0;
   }
 
   .ChangePassword .list .item input {
       width: 100%;
       height: 100%;
       font-size: 32rpx;
   }
 
   .ChangePassword .list .item .placeholder {
       color: #b9b9bc;
   }
 
   .ChangePassword .list .item input.codeIput {
       width: 340rpx;
   }
 
   .ChangePassword .list .item .code {
       font-size: 32rpx;
       background-color: #fff;
   }
 
   .ChangePassword .list .item .code.on {
       color: #b9b9bc !important;
   }
 
   .ChangePassword .confirmBnt {
       font-size: 32rpx;
       width: 580rpx;
       height: 90rpx;
       border-radius: 45rpx;
       color: #fff;
       margin: 92rpx auto 0 auto;
       text-align: center;
       line-height: 90rpx;
   }
</style>