杨磊
4 天以前 ef37c59e055a990ce247b265b27d3fcef430a243
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
<template>
  <div class="loginPage">
    <div class="loginContent">
      <div class="loginFormBox">
        <div class="title">
          <span class="active">找回密码</span>
        </div>
        <!-- 用户名密码登录 -->
        <div>
          <div class="loginContentBox">
            <div class="errorTips" v-if="errorTipsTxt">
              {{ errorTipsTxt }}
              <span
                v-if="loginFormType == 'password'"
                class="findPassword"
                @click="toFindPassword()"
                >找回密码</span
              >
            </div>
            <div class="codeLoginItemBox flex">
              <el-select
                style="width: 100px"
                class="mr10"
                placeholder="请选择"
                v-model="loginForm.region"
              >
                <el-option
                  v-for="item in options"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
                ></el-option>
              </el-select>
              <el-input
                class="flex1"
                placeholder="请输入手机号"
                v-model="loginForm.mobilePhone"
                @keyup.enter.native="loginFun"
              ></el-input>
            </div>
            <div class="codeLoginItemBox flex">
              <el-input
                placeholder="请输入图形验证码"
                class="flex1 mr10"
                v-model="loginForm.imgCode"
              ></el-input>
              <div class="imgCode">
                <img :src="imgCode" alt="" @click="getImgCapcha" />
              </div>
            </div>
            <div class="codeLoginItemBox flex">
              <el-input
                placeholder="请输入验证码"
                class="flex1 mr10"
                v-model="loginForm.verificationCode"
                @keyup.enter.native="loginFun"
              ></el-input>
              <el-button
                style="width: 140px"
                @click="getVerifyCode"
                :disabled="countDown != 0"
                >{{
                  countDown == 0
                    ? "获取短信验证码"
                    : "验证码(" + countDown + "s)"
                }}</el-button
              >
            </div>
            <!-- <div class="loginItemBox" v-if="loginFormType == 'password'">
              <span>手机号</span>
              <el-input
                class="loginItemIpt"
                v-model="loginForm.mobilePhone"
                placeholder="请输入手机号"
                clearable
                @keyup.enter.native="loginFun"
              ></el-input>
            </div> -->
            <div class="loginItemBox">
              <span>新密码</span>
              <el-input
                class="loginItemIpt"
                v-model="loginForm.password"
                type="password"
                show-password
                placeholder="请输入密码"
                @keyup.enter.native="loginFun"
              ></el-input>
            </div>
            <div class="loginItemBox">
              <span>确认密码</span>
              <el-input
                class="loginItemIpt"
                v-model="loginForm.repetitionPassword"
                type="password"
                show-password
                placeholder="请输入确认密码"
                @keyup.enter.native="loginFun"
              ></el-input>
            </div>
            <div class="loginBtnBox">
              <el-button
                type="primary"
                class="loginBtn"
                @click="loginFun"
                :loading="loading"
                >重置密码</el-button
              >
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "login",
  data() {
    return {
      redirectPath: "",
      loading: false,
      errorTipsTxt: "",
      loginFormType: "code",
      imgCode: "",
      loginForm: {
        region: "中国+86",
        mobilePhone: "",
        password: "",
        imgCode: "",
        verificationCode: "",
        repetitionPassword: "",
      },
      countDown: 0,
      options: [
        {
          value: "中国+86",
          label: "中国+86",
        },
      ],
    };
  },
  created() {
    this.redirectPath = this.$route.query.redirectPath;
    this.getImgCapcha();
  },
  methods: {
    getImgCapcha() {
      this.MG.identity.getImgCode().then((res) => {
        this.imgCode = "data:image/png;base64," + res;
      });
    },
    // 获取验证码
    getVerifyCode() {
      if (!this.config.reg_tel.test(this.loginForm.mobilePhone)) {
        this.$message({
          message: "请输入正确格式的手机号!",
          type: "error",
        });
        return false;
      } else if (
        this.loginForm.imgCode == "" ||
        this.loginForm.imgCode.length != 4
      ) {
        this.$message({
          message: "请输入正确格式的图形验证码",
          type: "error",
        });
        return false;
      } else {
        this.MG.identity
          .getPhoneCode({
            phoneNumber: this.loginForm.mobilePhone,
            imageCaptcha: this.loginForm.imgCode,
            appRefCode: this.config.appRefCode,
          })
          .then((res) => {
            if (res == "验证码发送成功") {
              this.getSecond(60);
              this.$message({
                message: res,
                type: "success",
              });
            } else {
              this.$message({
                message: res,
                type: "error",
              });
              this.getImgCapcha();
            }
          });
      }
    },
    //验证码倒计时
    getSecond(time) {
      if (!this.timer) {
        this.countDown = time;
        this.timer = setInterval(() => {
          this.countDown--;
          if (this.countDown == 0) {
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000);
      }
    },
    loginFun() {
      if (!this.loginForm.mobilePhone) {
        this.$message({
          message: "请输入手机号!",
          type: "error",
        });
        return false;
      }
      if (!this.loginForm.verificationCode) {
        this.$message({
          message: "请输入短信验证码!",
          type: "error",
        });
        return false;
      }
      if (!this.loginForm.password) {
        this.$message({
          message: "请输入密码!",
          type: "error",
        });
        return false;
      }
      if (this.loginForm.password != this.loginForm.repetitionPassword) {
        this.$message({
          message: "两次输入密码不一致!",
          type: "error",
        });
        return false;
      }
 
      this.loading = true;
 
      this.MG.identity
        .changePasswordByMobilePhone({
          phoneNumber: this.loginForm.mobilePhone,
          phoneCaptcha: this.loginForm.verificationCode,
          password: this.loginForm.password,
        })
        .then((res) => {
          this.loading = false;
          this.$message({
            message: "密码重置成功!",
            type: "success",
          });
          this.$router.push({
            path: "/login",
          });
        });
    },
  },
};
</script>
<style lang="less" scoped>
@import "@/assets/css/theme.less";
.loginPage {
  width: 100%;
  height: 100%;
  background-image: url("@/assets/images/login/pageBg.png");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  position: relative;
  .loginContent {
    width: 1200px;
    height: 570px;
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -285px;
    margin-left: -600px;
    padding: 36px 0;
    box-shadow: 0px 0px 66px 0px rgb(170 170 170 / 35%);
    background-image: url("@/assets/images/login/boxBg.png");
    background-repeat: no-repeat;
    background-size: 100% 100%;
    box-sizing: border-box;
    text-align: right;
    .loginFormBox {
      display: inline-block;
      width: 420px;
      height: 496px;
      padding: 30px 40px;
      margin-right: 60px;
      background: #fff;
      box-sizing: border-box;
      box-shadow: 0 0 5px 0 hsl(0deg 0% 67% / 35%);
      .title {
        font-size: 16px;
        text-align: center;
        color: #333333;
        span {
          display: inline-block;
          width: 80px;
          cursor: pointer;
          &.active {
            font-weight: bold;
            color: @color;
          }
        }
        .division {
          width: 5px;
          margin: 0 50px;
          cursor: initial;
          color: #d0d0d0;
        }
      }
      .loginContentBox {
        padding-top: 30px;
        margin-top: 20px;
        margin-bottom: 15px;
        position: relative;
        .errorTips {
          position: absolute;
          top: 8px;
          left: 10px;
          font-size: 12px;
          color: #e50021;
          .findPassword {
            cursor: pointer;
            color: #2b68cd;
            font-size: 12px;
          }
        }
        .codeLoginItemBox {
          margin-bottom: 15px;
          .imgCode {
            width: 140px;
            height: 40px;
            img {
              width: 100%;
              height: 100%;
              background: #efefef;
            }
          }
        }
        .loginItemBox {
          display: flex;
          justify-content: space-between;
          align-items: center;
          border-radius: 4px;
          margin-bottom: 15px;
          box-sizing: border-box;
          border: 1px solid #dcdfe6;
          span {
            display: inline-block;
            width: 100px;
            text-align: center;
          }
        }
        .changFormBtn {
          margin-bottom: 15px;
          overflow: hidden;
          span {
            cursor: pointer;
          }
        }
        .loginBtnBox {
          margin-bottom: 15px;
          .loginBtn {
            width: 100%;
          }
        }
        .registerBox {
          margin-top: 20px;
          font-size: 14px;
          text-align: center;
          color: #666666;
          span {
            cursor: pointer;
          }
          .division {
            margin: 0 20px;
            cursor: initial;
            color: #d0d0d0;
          }
        }
      }
      .wechatBox {
        .wxCodeBox {
          margin-top: 10px;
          height: 300px;
        }
      }
    }
  }
}
.mr10 {
  margin-right: 10px;
}
</style>
<style>
.loginItemIpt .el-input__inner {
  height: 38px;
  line-height: 38px;
  border: 0;
}
</style>