DESKTOP-CVS3R96\我恁爹
2022-11-14 f8b256ef152e54c19adb85856f62432d59c16b6e
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
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
<template>
  <div class="login_page">
    <headers :mess="loginWay" />
    <!-- <div class="img_mess">
      <div class="logo_content animated fadeInRight">
        <img :src="Logo" alt />
      </div>
    </div> -->
    <div class="logins_content">
      <div class="login_title animated slideInDown">
        <span>{{ '手机注册' }}</span>
      </div>
      <div class="login_forms">
        <div class="top_forms">
          <!-- <div class="user_name">
            <input type="text" :placeholder="placeholder" v-model="phone" />
          </div>
          <div class="captcha">
            <input type="text" :placeholder="verification" v-model="code" />
            <div v-if="codeshow" @click="checkCodeBox">获取验证码</div>
            <div v-if="!codeshow" class="getcode">{{count}}s</div>
          </div>
          <div class="password">
            <input type="password"  placeholder="密码为6~12位数字、字母或符号" v-model="userPassword"  />
            @input="handleInput()" 
          </div>
          <div class="password">
            <input type="password"  placeholder="请再次确认密码" v-model="rePassword"  />
          </div>
          <div class="user_name">
            <input type="text" placeholder="机构代码" v-model="userName" />
          </div> -->
          <el-input :placeholder="placeholder" size="medium" v-model="phone" clearable @input="handleInput()" maxlength="11">
          </el-input>
          <!-- <el-input style="margin-top: 0.46rem;" :placeholder="verification" :size="medium" v-model="code" clearable>
          </el-input> -->
          <el-input style="margin-top: 0.46rem;" show-password placeholder="密码为6~12位数字、字母或符号" size="medium"
            v-model="userPassword" @input="handleInput()">
          </el-input>
          <el-input style="margin-top: 0.46rem;" show-password placeholder="请再次确认密码" size="medium" v-model="rePassword"
            @input="handleInput()">
          </el-input>
          <el-input style="margin-top: 0.46rem;" placeholder="邀请码" size="medium" v-model="userName" clearable
            @input="handleInput()">
          </el-input>
        </div>
        <div class="bottom_btns" :class="btnClass ? 'on' : 'off'">
          <div class="top_btn " @click="gook" :class="dengl ? 'animated pulse' : ''">
            <span>{{ '安全注册' }}</span>
          </div>
          <!-- <div
           class="register-form-item agree-model"
          >
            <i @click="isAgree"
             :class="agree?'glyphicon glyphicon glyphicon-ok-sign blue':'glyphicon glyphicon-ok-circle'"></i>
          我已阅读并同意
          <a  style="color:#fff">《注册协议》</a>
          </div> -->
          <div class="mes">
            <span>{{ '已有账户?' }}</span>
            <span @click="$router.push('/login')" style="color: rgb(54,124,248);">{{ '登录>' }}</span>
          </div>
        </div>
      </div>
    </div>
    <el-alert v-show="alertShow" :closable="closable" :title="texts" :type="elType" center></el-alert>
  </div>
</template>
 
<script>
import headers from "./components/header.vue";
import Logo from "@/assets/img/LOGO2.png";
import { isNull, isPhone, pwdReg } from '@/utils/utils'
import { Toast } from 'mint-ui'
import * as api from '@/axios/api'
export default {
  components: {
    headers
  },
  name: "newRegister",
  data() {
    return {
      verification: "验证码",
      loginWay: "手机号注册",
      loginWay: "手机号注册",
      placeholder: "手机号",
      Logo,
      phone: "",
      userName: "",
      code: "",
      userPassword: "",
      btnClass: false,
      codeshow: true,
      count: '', // 倒计时
      clickFalg: 0, //  点击次数
      rePassword: "",
      agree: false,
      dengl: false,
      alertShow: false,
      closable: false,
      texts: "",
      elType: "warning",
    }
  },
  mounted() {
 
  },
  methods: {
    handleInput() {
 
      if (this.userPassword !== "" && this.phone !== '' && this.userPassword == this.rePassword && this.userName != "") {
        this.btnClass = true;
      } else {
        this.btnClass = false;
      }
    },
    checkCodeBox() {
      if (isNull(this.phone) || !isPhone(this.phone)) {
        // Toast('请输入正确的手机号')
        this.texts = "请输入正确的手机号"
        this.alertShow = true
        setTimeout(() => {
          this.alertShow = false
        }, 2000)
      } else {
        this.checkPhone()
      }
    },
    async is_login(){
      //获取localStorage中的token
      let token = localStorage.getItem('USERTOEKN')
      if(token){
        this.$router.push('/home')
      }
    },
   
    async getcode() {
      // if(!this.checkCode()){
      //     // 验证图形码是否正确
      //     Toast('请输入正确图形验证码')
      //     return
      // }
      // 获取验证码
      if (this.clickFalg !== 0) {
        this.clickFalg = 0
        return
      }
      this.clickFalg++
      //   var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/
      let reg = /^[0-9]{11}$/ // 手机号码验证
      if (isNull(this.phone)) {
        this.texts = "手机号不能为空"
        this.alertShow = true
        setTimeout(() => {
          this.alertShow = false
        }, 2000)
      } else {
        if (!reg.test(this.phone)) {
          this.texts = "请输入正确的手机号码"
          this.alertShow = true
          setTimeout(() => {
            this.alertShow = false
          }, 2000)
        } else {
          //   var sign  = this.$md5(this.phone+'W&WzL42v').toUpperCase()
          let result = await api.getCode({ phoneNum: this.phone })
          if (result.status === 0) {
            const TIME_COUNT = 60
            if (!this.timer) {
              this.count = TIME_COUNT
              this.codeshow = false
              this.clickFalg = 0
              this.timer = setInterval(() => {
                if (this.count > 0 && this.count <= TIME_COUNT) {
                  this.count--
                } else {
                  this.codeshow = true
                  clearInterval(this.timer)
                  this.timer = null
                }
              }, 1000)
            } else {
              // Toast(result.msg)
              this.texts = result.msg
              this.elType = "success"
              this.alertShow = true
              setTimeout(() => {
                this.alertShow = false
                this.elType = "warning"
              }, 2000)
            }
          } else {
            this.texts = result.msg
            this.alertShow = true
            setTimeout(() => {
              this.alertShow = false
            }, 2000)
          }
        }
      }
    },
    async gook() {
      this.dengl = true
      setTimeout(() => {
        this.dengl = false
      }, 1000)
      if (this.loginBtn) {
        return;
      }
      this.loginBtn = true;
      // 注册
      // if (!this.agree) {
      //   Toast('需同意注册协议才能注册!')
      //   this.loginBtn = false;
      // } else
      if (isNull(this.phone) || !isPhone(this.phone)) {
 
        this.texts = "请输入正确的手机号码"
        this.alertShow = true
        setTimeout(() => {
          this.alertShow = false
        }, 2000)
        this.loginBtn = false;
      } else if (isNull(this.userPassword)) {
        this.texts = "请输入密码"
        this.alertShow = true
        setTimeout(() => {
          this.alertShow = false
        }, 2000)
        this.loginBtn = false;
      } else if (isNull(this.rePassword)) {
        this.texts = "请确认密码"
        this.alertShow = true
        setTimeout(() => {
          this.alertShow = false
        }, 2000)
        this.loginBtn = false;
      } else {
        if (this.userPassword !== this.rePassword) {
          this.texts = "两次输入的密码不一致"
          this.alertShow = true
          setTimeout(() => {
            this.alertShow = false
          }, 2000)
          this.password = 0
          this.password2 = 0
          this.loginBtn = false;
        } else if (!pwdReg(this.userPassword)) {
 
          this.texts = "密码为6~12位,数字、字母或符号"
          this.alertShow = true
          setTimeout(() => {
            this.alertShow = false
          }, 2000)
          this.loginBtn = false;
        } else if (isNull(this.userName)) {
          this.texts = "请输入邀请码"
          this.alertShow = true
          setTimeout(() => {
            this.alertShow = false
          }, 2000)
          this.loginBtn = false;
        } else {
          let opts = {
            // agentCode:'4023', // SR330001
            phone: this.phone,
            yzmCode: '6666',
            userPwd: this.userPassword,
            agentCode: this.userName
          }
          let data = await api.register(opts)
          if (data.status === 0) {
            this.texts = "注册成功,请登录"
            this.elType = "success"
            this.alertShow = true
            setTimeout(() => {
              this.$router.push('/login')
              this.alertShow = false
              this.elType = "warning"
            }, 1000)
            this.loginBtn = false;
           
          } else {
            this.texts = data.msg
            this.alertShow = true
            setTimeout(() => {
              this.alertShow = false
            }, 2000)
            this.loginBtn = false;
          }
        }
      }
      if (navigator.vibrate) {
          // 支持
        navigator.vibrate([55]);
      }
        //   if (isNull(this.code)) {
        //     this.texts="请输入验证码"
        // this.alertShow=true
        // setTimeout(()=>{
        //   this.alertShow=false
        // },2000)
        //     this.loginBtn = false;
        //   } else 
       
    },
    isAgree() {
      this.agree = !this.agree
    },
    async checkPhone() {
      // 先验证是否已经注册
      let data = await api.checkPhone({ phoneNum: this.phone })
      if (data.status === 0) {
        // 如果用户已存在返回 0
        this.texts = "用户已注册,请登录"
            this.alertShow = true
            setTimeout(() => {
              this.alertShow = false
            }, 2000)
        this.$router.push('/login')
      } else {
        // this.dialogShow = false
        // this.adminUrl = process.env.API_HOST
        // if (this.adminUrl === undefined) {
        //   this.adminUrl = ''
        // }
        // this.gook()
        this.getcode()
      }
    },
  },
 
}
</script>
 
<style  scoped lang="less">
.login_page {
  position: relative;
  background-color: #fff !important;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overflow-y: auto;
}
 
.logins_content {
 
  width: 100%;
  height: 9.7436rem;
  margin-top: 0.4359rem;
  padding: 0 0.4564rem;
 
  .login_title {
    width: 100%;
    height: 2.0513rem;
    display: flex;
 
    align-items: center;
    font-size: 0.7023rem;
    color: #000;
    font-weight: 600 !important;
 
    >span {
      font-weight: 600 !important;
    }
  }
 
  .login_forms {
    width: 100%;
    height: auto;
    margin-top: 0.35rem;
 
    .top_forms {
      width: 100%;
      height: auto;
      display: flex;
      align-items: center;
      flex-wrap: wrap;
 
      .user_name,
      .password {
        width: 100%;
        height: 35%;
        background: rgb(246, 246, 247);
        // background: #1e1e1e;
        border-radius: 0.3564rem;
 
        >input {
          width: 100%;
          height: 100%;
          padding-left: 0.3564rem;
          font-size: 0.4615rem;
        }
      }
    }
 
    /deep/.el-input__inner {
      width: 100%;
      height: 1.45rem !important;
      background-color: rgb(246, 246, 247) !important;
      // background: #1e1e1e;
      border-radius: 0.3564rem;
      font-size: 0.45rem !important;
    }
 
    .bottom_btns {
      width: 100%;
      height: 3.3333rem;
      margin-top: 0.8528rem;
 
      .top_btn {
        width: 100%;
        height: 1.25rem;
        border-radius: 0.3564rem;
        background: rgb(154, 197, 250);
        color: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.5128rem;
        margin-top: 0.75rem;
 
        >span {
          font-weight: 530 !important;
        }
      }
 
 
 
      .mes {
        width: 100%;
        height: 20%;
        margin-top: 0.4rem;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        font-size: 0.3846rem;
      }
    }
  }
}
 
.login_bom {
  position: absolute;
  bottom: 2.6rem;
  width: 100%;
  height: 4rem;
  padding: 0 2rem;
}
 
.line {
  //分割线
  width: 100%;
  height: 0.3846rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.3846rem;
 
  .left_line {
    width: 20%;
    height: 0.01rem;
    background: #e5e5e5;
  }
 
  .center_line {
    width: 50%;
    height: 0.01rem;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
 
    >span {
      font-size: 0.3046rem;
      color: #000;
      background-color: #fff;
 
    }
  }
 
  .right_line {
    width: 20%;
    height: 0.01rem;
    background: #e5e5e5;
  }
 
}
 
.myzh {
  width: calc(100% - 4rem);
  position: absolute;
  bottom: 0.01rem;
  text-align: center;
 
  .mes {
    width: 100%;
    height: 40%;
 
    font-size: 0.3846rem;
  }
}
 
.imgDemo {
  display: flex;
  justify-content: space-between;
  position: relative;
  transform: translateY(50%);
}
 
.appImg {
  width: 1.4rem;
  height: 1.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: rgb(246, 246, 247);
  border-radius: 100%;
}
 
.appImg img {
  width: 0.8rem;
  height: 0.8rem;
}
 
.img_mess {
  width: 100%;
  height: 4.0513rem;
  display: flex;
  justify-content: center;
  align-items: center;
 
  .logo_content {
    width: 3rem;
    height: 3.5769rem;
 
    >img {
      width: 100%;
      height: 100%;
    }
  }
}
 
/deep/.el-alert {
  width: 70% !important;
  height: 1rem !important;
  position: absolute !important;
  top: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  right: 0 !important;
  margin: auto !important;
  font-size: 0.3rem !important;
}
 
/deep/.el-alert__title {
  font-size: 0.3rem !important;
}
 
/deep/el-input__suffix {
  width: 1rem !important;
}
 
/deep/.el-input__suffix-inner {
  width: 1rem !important;
}
 
/deep/.el-input__icon {
  width: 1rem !important;
}
 
/deep/.el-icon-circle-close::before {
  font-size: 0.5rem !important;
 
}
 
/deep/.el-input__clear {
  font-size: 0.5rem !important;
}
 
.on .top_btn {
  background: #2d8cf0 !important;
}
 
.agree-model {
  margin-top: 0.2rem;
}
</style>