Browse Source

Merge remote-tracking branch 'origin/gzb' into wzl

gzb
wangzhonglu 9 months ago
parent
commit
62f5e267ad
1 changed files with 195 additions and 48 deletions
  1. 195
    48
      src/views/layout.vue

+ 195
- 48
src/views/layout.vue View File

39
           <DropdownMenu slot="list">
39
           <DropdownMenu slot="list">
40
             <DropdownItem name="1">个人信息</DropdownItem>
40
             <DropdownItem name="1">个人信息</DropdownItem>
41
             <DropdownItem name="2">修改密码</DropdownItem>
41
             <DropdownItem name="2">修改密码</DropdownItem>
42
-            <DropdownItem name="5">更换手机号</DropdownItem>
42
+            <DropdownItem name="3">更换手机号</DropdownItem>
43
             <DropdownItem name="4">退出</DropdownItem>
43
             <DropdownItem name="4">退出</DropdownItem>
44
           </DropdownMenu>
44
           </DropdownMenu>
45
         </Dropdown>
45
         </Dropdown>
50
     </div>
50
     </div>
51
     <!-- 修改密码 -->
51
     <!-- 修改密码 -->
52
     <Modal
52
     <Modal
53
-        class="modal1"
54
-        :mask-closable="false"
55
-        v-model="pwInfo.show"
56
-        title="修改密码"
53
+      class="modal_view"
54
+      :mask-closable="false"
55
+      v-model="pwInfo.show"
56
+      title="修改密码"
57
     >
57
     >
58
       <Form
58
       <Form
59
-          v-if="pwInfo.show"
60
-          ref="pwInfo"
61
-          :model="pwInfo"
62
-          :rules="rules"
63
-          :label-width="110"
59
+        v-if="pwInfo.show"
60
+        ref="pwInfo"
61
+        :model="pwInfo"
62
+        :rules="rules"
63
+        :label-width="110"
64
       >
64
       >
65
         <FormItem label="原密码" prop="oldpwd">
65
         <FormItem label="原密码" prop="oldpwd">
66
-          <Input
67
-              v-model="pwInfo.oldpwd"
68
-              placeholder="请输入原密码"
69
-          ></Input>
66
+          <Input v-model="pwInfo.oldpwd" placeholder="请输入原密码"></Input>
70
         </FormItem>
67
         </FormItem>
71
-        <FormItem
72
-            label="新密码"
73
-            prop="loginpwd"
74
-        >
75
-          <Input
76
-              v-model="pwInfo.loginpwd"
77
-              placeholder="请输入新密码"
78
-          ></Input>
68
+        <FormItem label="新密码" prop="loginpwd">
69
+          <Input v-model="pwInfo.loginpwd" placeholder="请输入新密码"></Input>
79
         </FormItem>
70
         </FormItem>
80
-        <FormItem
81
-            label="确认密码"
82
-            prop="loginpwd1"
83
-        >
71
+        <FormItem label="确认密码" prop="loginpwd1">
84
           <Input
72
           <Input
85
-              v-model="pwInfo.loginpwd1"
86
-              placeholder="请输入确认密码"
73
+            v-model="pwInfo.loginpwd1"
74
+            placeholder="请输入确认密码"
87
           ></Input>
75
           ></Input>
88
         </FormItem>
76
         </FormItem>
89
       </Form>
77
       </Form>
90
       <div
78
       <div
91
-          slot="footer"
92
-          style="
79
+        slot="footer"
80
+        style="
93
           display: flex;
81
           display: flex;
94
           justify-content: space-between;
82
           justify-content: space-between;
95
           align-items: center;
83
           align-items: center;
100
         </div>
88
         </div>
101
         <div>
89
         <div>
102
           <Button @click="pwInfo.show = false">取消</Button>
90
           <Button @click="pwInfo.show = false">取消</Button>
103
-          <Button @click="savepwInfo()" type="primary">保存</Button>
91
+          <Button @click="savepwInfo()" class="primary_btn" type="primary"
92
+            >保存</Button
93
+          >
94
+        </div>
95
+      </div>
96
+    </Modal>
97
+    <!-- 修改手机号 -->
98
+    <Modal
99
+      class="modal_view"
100
+      :mask-closable="false"
101
+      v-model="phoneInfo.show"
102
+      title="修改手机号"
103
+    >
104
+      <Form
105
+        v-if="phoneInfo.show"
106
+        ref="phoneInfo"
107
+        :model="phoneInfo"
108
+        :rules="rules"
109
+        :label-width="110"
110
+      >
111
+        <FormItem label="原手机号">
112
+          <div style="line-height: 36px">{{ phoneInfo.oldphone }}</div>
113
+        </FormItem>
114
+        <FormItem label="新手机号" prop="phone">
115
+          <Input v-model="phoneInfo.phone" placeholder="请输入新手机号"></Input>
116
+        </FormItem>
117
+        <FormItem label="短信验证码" prop="msgcode">
118
+          <Input
119
+            style="width: calc(100% - 102px)"
120
+            v-model="phoneInfo.msgcode"
121
+            placeholder="请输入短信验证码"
122
+          ></Input>
123
+          <div
124
+            :class="['code_btn', phoneInfo.second === 60 ? '' : 'disabled']"
125
+            @click="getMsgCode()"
126
+          >
127
+            {{
128
+              phoneInfo.second === 60 ? "获取验证码" : `${phoneInfo.second}s`
129
+            }}
130
+          </div>
131
+        </FormItem>
132
+      </Form>
133
+      <div
134
+        slot="footer"
135
+        style="
136
+          display: flex;
137
+          justify-content: space-between;
138
+          align-items: center;
139
+        "
140
+      >
141
+        <div style="color: #b50000">
142
+          注:更换手机号码之后,原来的手机号码将无法使用。
143
+        </div>
144
+        <div>
145
+          <Button @click="phoneInfo.show = false">取消</Button>
146
+          <Button @click="savephoneInfo()" class="primary_btn" type="primary"
147
+            >保存</Button
148
+          >
104
         </div>
149
         </div>
105
       </div>
150
       </div>
106
     </Modal>
151
     </Modal>
112
 </template>
157
 </template>
113
 
158
 
114
 <script>
159
 <script>
115
-import {region_add} from "@/api/region";
116
-import {admin_detail, admin_edit_pwd} from "@/api/admin";
160
+import { admin_detail, admin_edit_phone, admin_edit_pwd } from "@/api/admin";
161
+import { login_msg_code } from "@/api/login";
117
 
162
 
118
 export default {
163
 export default {
119
   data() {
164
   data() {
140
       userDropdown: false,
185
       userDropdown: false,
141
       pwInfo: {
186
       pwInfo: {
142
         show: false,
187
         show: false,
188
+        adminid: "",
189
+        loginpwd: "",
190
+        oldpwd: "",
191
+        rversion: ""
143
       },
192
       },
144
       phoneInfo: {
193
       phoneInfo: {
145
-        show: false
194
+        show: false,
195
+        timer: null,
196
+        second: 60,
197
+        rversion: "",
198
+        adminid: "",
199
+        oldphone: "",
200
+        phone: "",
201
+        msgcode: ""
146
       },
202
       },
147
       rules: {
203
       rules: {
148
         oldpwd: [
204
         oldpwd: [
186
     }
242
     }
187
   },
243
   },
188
   methods: {
244
   methods: {
189
-    savepwInfo(){
190
-
245
+    // 获取短信验证码
246
+    getMsgCode() {
247
+      if (this.phoneInfo.second < 60) {
248
+        return;
249
+      }
250
+      // 手机号验证
251
+      if (!this.phoneInfo.phone) {
252
+        this.$Message.error("手机号码不能为空");
253
+        return;
254
+      }
255
+      let filter = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
256
+      if (!filter.test(this.phoneInfo.phone)) {
257
+        this.$Message.error("手机号码格式不正确");
258
+        return;
259
+      }
260
+      this.setRegionSecond();
261
+      login_msg_code({
262
+        phone: this.phoneInfo.phone
263
+      }).then((data) => {
264
+        if (data.code === 0) {
265
+          this.$Message.success(data.msg);
266
+        } else {
267
+          this.$Message.error(data.msg);
268
+        }
269
+      });
270
+    },
271
+    setRegionSecond() {
272
+      this.phoneInfo.second = 59;
273
+      this.phoneInfo.timer = setInterval(() => {
274
+        this.phoneInfo.second--;
275
+        if (this.phoneInfo.second <= 0) {
276
+          clearInterval(this.phoneInfo.timer);
277
+          this.phoneInfo.timer = null;
278
+          this.phoneInfo.second = 60;
279
+        }
280
+      }, 1000);
281
+    },
282
+    savephoneInfo() {
283
+      this.$refs.phoneInfo.validate((valid) => {
284
+        if (valid) {
285
+          this.showLoading = true;
286
+          admin_edit_phone({
287
+            adminid: this.userInfo.adminid,
288
+            phone: this.phoneInfo.phone,
289
+            msgcode: this.phoneInfo.msgcode,
290
+            rversion: this.phoneInfo.rversion
291
+          }).then((data) => {
292
+            this.showLoading = false;
293
+            if (data.code === 0) {
294
+              this.phoneInfo.show = false;
295
+              this.$Message.success(data.msg);
296
+            } else {
297
+              this.$Message.error(data.msg);
298
+            }
299
+          });
300
+        }
301
+      });
302
+    },
303
+    savepwInfo() {
191
       this.$refs.pwInfo.validate((valid) => {
304
       this.$refs.pwInfo.validate((valid) => {
192
         if (valid) {
305
         if (valid) {
193
-          console.log(this.pwInfo)
194
-          return
195
           this.showLoading = true;
306
           this.showLoading = true;
196
           admin_edit_pwd({
307
           admin_edit_pwd({
197
-            adminid: this.pwInfo.adminid,
308
+            adminid: this.userInfo.adminid,
198
             loginpwd: this.pwInfo.loginpwd,
309
             loginpwd: this.pwInfo.loginpwd,
199
             oldpwd: this.pwInfo.oldpwd,
310
             oldpwd: this.pwInfo.oldpwd,
200
             rversion: this.pwInfo.rversion
311
             rversion: this.pwInfo.rversion
201
-            }).then((data) => {
312
+          }).then((data) => {
202
             this.showLoading = false;
313
             this.showLoading = false;
203
             if (data.code === 0) {
314
             if (data.code === 0) {
204
-              this.regionInfo.show = false;
315
+              this.pwInfo.show = false;
205
               this.$Message.success(data.msg);
316
               this.$Message.success(data.msg);
206
             } else {
317
             } else {
207
               this.$Message.error(data.msg);
318
               this.$Message.error(data.msg);
223
         // 2修改密码 3更换手机号
334
         // 2修改密码 3更换手机号
224
         admin_detail({ adminid: this.userInfo.adminid }).then((res) => {
335
         admin_detail({ adminid: this.userInfo.adminid }).then((res) => {
225
           if (res.code === 0) {
336
           if (res.code === 0) {
226
-            console.log(res.obj);
227
-            if(name === "2"){
228
-              this.pwInfo.show = true;
229
-              this.pwInfo.rversion = res.obj.rversion;
230
-            }else {
231
-              this.phoneInfo.show = true;
232
-              this.phoneInfo.rversion = res.obj.rversion;
337
+            if (name === "2") {
338
+              this.pwInfo = {
339
+                show: true,
340
+                rversion: res.obj.rversion,
341
+                adminid: "",
342
+                loginpwd: "",
343
+                oldpwd: ""
344
+              };
345
+            } else {
346
+              this.phoneInfo = {
347
+                show: true,
348
+                timer: null,
349
+                second: 60,
350
+                rversion: res.obj.rversion,
351
+                adminid: "",
352
+                oldphone: res.obj.phone,
353
+                phone: "",
354
+                msgcode: ""
355
+              };
233
             }
356
             }
234
           } else {
357
           } else {
235
             this.$Message.error(res.msg);
358
             this.$Message.error(res.msg);
339
     overflow: auto;
462
     overflow: auto;
340
   }
463
   }
341
 }
464
 }
465
+.code_btn {
466
+  display: inline-block;
467
+  margin-left: 10px;
468
+  width: 92px;
469
+  font-size: 14px;
470
+  text-align: center;
471
+  color: #339dff;
472
+  line-height: 30px;
473
+  border: 1px solid #339dff;
474
+  border-radius: 6px;
475
+  background-color: #fff;
476
+  cursor: pointer;
477
+  &.disabled {
478
+    color: #c5c8ce;
479
+    background-color: #f7f7f7;
480
+    border-color: #dcdee2;
481
+    cursor: not-allowed;
482
+  }
483
+}
484
+.modal_view {
485
+  .ivu-modal {
486
+    width: 520px;
487
+  }
488
+}
342
 </style>
489
 </style>

Loading…
Cancel
Save