regiester2.vue 11.7 KB
Newer Older
李晓兵's avatar
李晓兵 committed
1 2 3 4
<template>
  <h-view id="register" class="public-style">
    <h-content>
      <div class="right-logo">
linxin's avatar
linxin committed
5 6
        <img src="@/assets/login/return.png" @click="returnLogin">
        <img src="@/assets/login/right.png" >
李晓兵's avatar
李晓兵 committed
7
      </div>
linxin's avatar
linxin committed
8 9
      <div class="box">
        <div class="box-content">
linxin's avatar
linxin committed
10
          <img class="register-title" src="../assets/login/right-register.png" >
linxin's avatar
linxin committed
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
          <div class="reg-item">
            <img src="../assets/login/reg-user.png" class="left-icon" >
            <input v-model="phone_number" placeholder="请输入手机号码" >
            <img
              v-if="phone_number"
              class="right-icon"
              src="@/assets/login/reg-de.png"
              @click="clearAccount"
            >
          </div>
          <div class="reg-item">
            <img src="../assets/login/check.png" class="left-icon" >
            <input v-model="verifiedCode" type="text" placeholder="请填写验证码" >
            <div class="verified-code">
              <div v-if="!showTimer" class="verified-code-box" @click="getPhoneCode">点击获取</div>
              <span v-if="showTimer" class="verified-code-des">{{ timerCount }}{{ text }}</span>
            </div>
          </div>
          <div class="reg-item">
            <img src="../assets/login/pass.png" class="left-icon" >
            <input
              v-model="user_password"
              :type="pwdType"
Jennie Shi's avatar
Jennie Shi committed
34
              placeholder="请输入6~20位非纯数字密码"
linxin's avatar
linxin committed
35
              maxlength="20"
linxin's avatar
linxin committed
36
              oninput="value=value.replace(/[\u4E00-\u9FA5]/g,'')"
李晓兵's avatar
李晓兵 committed
37

linxin's avatar
linxin committed
38 39
            >
            <img v-if="user_password" :src="openEye" class="right-icon" @click="changeType" >
李晓兵's avatar
李晓兵 committed
40
          </div>
linxin's avatar
linxin committed
41 42
          <div class="reg-item">
            <img src="../assets/login/pass.png" class="left-icon" >
linxin's avatar
linxin committed
43
            <input
linxin's avatar
linxin committed
44
              v-model="confirm" :type="pwdType" oninput="value=value.replace(/[\u4E00-\u9FA5]/g,'')" placeholder="请重新输入密码"
Jennie Shi's avatar
Jennie Shi committed
45
            >
linxin's avatar
linxin committed
46 47 48 49 50
            <img v-if="confirm" :src="openEye" class="right-icon" @click="changeType" >
          </div>
          <div class="button submit" @click="submit">注册</div>
        </div>
      </div>
李晓兵's avatar
李晓兵 committed
51 52 53 54 55 56 57 58 59
    </h-content>
  </h-view>
</template>
<script>
var CryptoJS = require('crypto-js')
export default {
  data () {
    return {
      pwdType: 'password', // 密码类型
linxin's avatar
linxin committed
60
      openEye: require('@/assets/login/passNoShow.png'), // 图片地址
李晓兵's avatar
李晓兵 committed
61 62 63 64 65 66 67 68 69 70 71
      phone_number: '',
      verifiedCode: '',
      user_password: '',
      confirm: '',

      phoneNumberFlag: false,
      verifiedCodeFlag: false,
      passwordFlag: false,
      confirmPassword: false,
      captchaKey: '123456',
      phoneCodeTimeOut: false,
linxin's avatar
linxin committed
72
      timer: 120000,
李晓兵's avatar
李晓兵 committed
73
      showTimer: false,
linxin's avatar
linxin committed
74
      timerCount: 120,
李晓兵's avatar
李晓兵 committed
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
      text: '获取验证码',
    }
  },
  watch: {
    verifiedCode (value) {
      let vm = this
      if (value.length === 6) {
        vm.verifiedCodeFlag = false
        if (vm.captchaKey.length === 0) {
          hlsPopup.showLongCenter('请先获取验证码')
        } else if (vm.phoneCodeTimeOut) {
          hlsPopup.showLongCenter('验证码已失效,请从新获取')
        } else {
          vm.verifiedCodeFlag = true
        }
      }
    },
    user_password (value) {
      if (value.length > 20) {
        hlsPopup.showLongCenter('密码长度6~20位之间')
      }
    },
    confirm (value) {
      if (value.length > 20) {
        hlsPopup.showLongCenter('密码长度6~20位之间')
      }
    },
  },
  created () {
    let vm = this
JingChao's avatar
JingChao committed
105
    let url = process.env.loginPath + 'appadmin'
李晓兵's avatar
李晓兵 committed
106 107 108 109 110 111 112 113 114 115 116 117 118 119
    let param = {}
    vm.$post(url, param).then(function (res) {
      window.localStorage.setItem('access_token', res.access_token)
    })
  },
  methods: {
    clearAccount: function () {
      this.phone_number = ''
      this.verifiedCode = ''
      this.user_password = ''
      this.confirm = ''
    },
    changeType () {
      this.pwdType = this.pwdType === 'password' ? 'text' : 'password'
linxin's avatar
linxin committed
120 121 122 123
      this.openEye =
        this.pwdType === 'password'
          ? require('@/assets/login/passNoShow.png')
          : require('@/assets/login/passShow.png')
李晓兵's avatar
李晓兵 committed
124 125 126 127
    },
    checkPhone () {
      let vm = this
      vm.phoneNumberFlag = false
linxin's avatar
linxin committed
128 129 130 131
      if (
        hlsUtil.phoneNumber(vm.phone_number) ||
        hlsUtil.phoneNumber86(vm.phone_number)
      ) {
李晓兵's avatar
李晓兵 committed
132 133 134 135 136 137
        vm.phoneNumberFlag = true
      }
    },
    getPhoneCode () {
      let vm = this
      if (!vm.showTimer) {
linxin's avatar
linxin committed
138 139 140 141
        if (
          hlsUtil.phoneNumber(vm.phone_number) ||
          hlsUtil.phoneNumber86(vm.phone_number)
        ) {
李晓兵's avatar
李晓兵 committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155
          vm.phoneNumberFlag = true
          vm.getVerifiedCode()
          vm.showTimer = true
          vm.text = '秒后失效'
          let counter = setInterval(function () {
            if (vm.timerCount >= 0) {
              vm.timerCount = vm.timerCount - 1
            }
          }, 1000)
          setTimeout(function () {
            vm.text = '获取验证码'
            vm.showTimer = false
            clearInterval(counter)
            vm.showTimer = false
linxin's avatar
linxin committed
156 157
            vm.captchaKey = ('000000' + Math.floor(Math.random() * 999999)).slice(-6)
            hlsPopup.showLongCenter('验证码失效,请重新获取')
李晓兵's avatar
李晓兵 committed
158 159 160 161 162 163 164 165 166 167 168 169
            vm.timerCount = vm.timer / 1000
          }, vm.timer)
        } else {
          hlsPopup.showLongCenter('手机号不存在,请重新输入!')
        }
      }
    },
    passwordCheck () {
      let vm = this
      let length = vm.user_password.length
      if (length < 6 || length > 20) {
        hlsPopup.showLongCenter('密码长度6~20位之间')
Jennie Shi's avatar
Jennie Shi committed
170 171
      } else if (new RegExp('^[0-9]*$').test(vm.user_password)) {
        hlsPopup.showLongCenter('密码不能全为数字')
李晓兵's avatar
李晓兵 committed
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
      } else {
        vm.passwordFlag = true
      }
    },
    confirmCheck () {
      let vm = this
      let length = vm.confirm.length
      if (length < 6 || length > 20) {
        hlsPopup.showLongCenter('密码长度6~20位之间')
      } else if (vm.confirm !== vm.user_password) {
        hlsPopup.showLongCenter('两次输入的密码不一致,请从新输入')
      } else {
        vm.confirmPassword = true
      }
    },
Jennie Shi's avatar
Jennie Shi committed
187
    async submit () {
李晓兵's avatar
李晓兵 committed
188 189 190
      let vm = this
      if (!vm.phoneNumberFlag) {
        hlsPopup.showLongCenter('请输入手机号!')
linxin's avatar
linxin committed
191
      } else if (vm.verifiedCode !== vm.captchaKey) {
李晓兵's avatar
李晓兵 committed
192
        hlsPopup.showLongCenter('验证码错误!')
李晓兵's avatar
李晓兵 committed
193
      } else if (!vm.user_password) {
李晓兵's avatar
李晓兵 committed
194
        hlsPopup.showLongCenter('请输入密码!')
李晓兵's avatar
李晓兵 committed
195
      } else if (!vm.confirm) {
李晓兵's avatar
李晓兵 committed
196 197
        hlsPopup.showLongCenter('请确认密码!')
      } else {
李晓兵's avatar
李晓兵 committed
198 199
        await vm.passwordCheck()
        await vm.confirmCheck()
Jennie Shi's avatar
Jennie Shi committed
200
        if (vm.passwordFlag && vm.confirmPassword) {
李晓兵's avatar
李晓兵 committed
201 202 203 204 205 206 207 208 209
          let url = process.env.basePath + 'register'
          let md5passwprd = CryptoJS.MD5(vm.user_password)
            .toString()
            .toUpperCase()
          let params = {
            master: {
              phone: vm.phone_number,
              password: md5passwprd,
            },
李晓兵's avatar
李晓兵 committed
210
          }
李晓兵's avatar
李晓兵 committed
211 212 213 214 215 216 217 218 219 220 221
          hlsHttp.post(url, params).then(function (res) {
            if (res.result === 'S') {
              hlsPopup.showLongCenter('注册成功')
              setTimeout(function () {
                vm.$router.push('login')
              }, 100)
            } else {
              hlsPopup.showLongCenter(res.message)
            }
          })
        }
李晓兵's avatar
李晓兵 committed
222 223
      }
    },
linxin's avatar
linxin committed
224
    returnLogin () {
李晓兵's avatar
李晓兵 committed
225 226 227 228
      this.$router.go(-1)
    },
    getVerifiedCode () {
      let vm = this
linxin's avatar
linxin committed
229 230
      // hlsPopup.showLongCenter('测试验证码为123456')
      let url = process.env.basePath + 'sms_verify_post'
linxin's avatar
linxin committed
231 232 233
      let signcode = ('000000' + Math.floor(Math.random() * 999999)).slice(-6)
      vm.captchaKey = signcode
      let param = {
linxin's avatar
linxin committed
234 235
        'phone': vm.phone_number,
        'signcode': signcode,
linxin's avatar
linxin committed
236 237 238 239 240 241 242
      }
      vm.hlsPopup.showLoading('请稍候')
      vm.hlsHttp.post(url, param).then(function (res) {
        vm.hlsPopup.hideLoading()
        if (res.result === 'S') {
          vm.hlsPopup.showSuccess('验证码已发送')
        } else {
linxin's avatar
linxin committed
243
          vm.hlsPopup.showLongCenter(res.return.description)
linxin's avatar
linxin committed
244
        }
linxin's avatar
linxin committed
245
      })
李晓兵's avatar
李晓兵 committed
246 247 248 249 250 251
    },
  },
}
</script>

<style lang="less">
linxin's avatar
linxin committed
252 253
@import "../styles/mixin";
@import "../styles/vue-1px";
李晓兵's avatar
李晓兵 committed
254

linxin's avatar
linxin committed
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271
#register {
  .content {
    background: url("../assets/login/register.png");
    background-size: 100% 100%;
  }
  .box {
    width: 327px;
    height: 512px;
    margin: 0 auto;
    margin-top:80px;
    background: #1d3fff;
    border-radius: 8px;
    .box-content {
      width: 279px;
      margin: 0 auto;
      .register-title {
        width: 156px;
李晓兵's avatar
李晓兵 committed
272
      }
linxin's avatar
linxin committed
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
      .reg-item {
        position: relative;
        width: 100%;
        height: 40px;
        margin-top: 30px;
        line-height: 30px;
        img {
          width: 28px;
          height: 28px;
        }
        .left-icon {
          position: absolute;
        }
        .right-icon {
          width: 24px;
          height: 24px;
          position: absolute;
          right: 0px;
          top: 5px;
        }
        .verified-code {
          position: absolute;
          right: 0px;
          top: 0px;
          .verified-code-box {
            padding-left: 12px;
            border-left: 1px solid #ffffff;
            color: #fff;
            font-family: PingFangSC-Regular;
            font-size: 14px;
            line-height: 30px;
          }
          .verified-code-des {
            font-size: 10px;
            color: #fff;
          }
        }
        input {
          width: 100%;
          text-indent: 30px;
          background-color: #1d3fff;
          font-family: PingFangSC-Regular;
          padding-bottom: 8px;
          font-size: 14px;
          color: #ffffff;
linxin's avatar
linxin committed
318
          line-height: 30px;
linxin's avatar
linxin committed
319 320 321 322 323 324 325 326 327 328
          border-bottom: 1px solid rgba(255, 255, 255, 0.4);
        }
        input::placeholder {
          font-family: PingFangSC-Regular;
          font-size: 14px;
          color: rgba(255, 255, 255, 0.6);
        }
        input:focus {
          border-bottom: 1px solid #fff;
        }
李晓兵's avatar
李晓兵 committed
329 330
      }
    }
linxin's avatar
linxin committed
331 332 333 334 335 336 337 338
  }
  .right-logo {
        width: 327px;
margin: 0 auto;
margin-top:10%;
    img:last-child{
float: right;
    width: 50px;
李晓兵's avatar
李晓兵 committed
339
    }
linxin's avatar
linxin committed
340 341 342
  img:first-child{
float:left;
    width: 20px;
李晓兵's avatar
李晓兵 committed
343
    }
linxin's avatar
linxin committed
344 345 346 347
    // img {
    //   width: 50px;
    // }
  }
李晓兵's avatar
李晓兵 committed
348

linxin's avatar
linxin committed
349 350 351
  .register-title {
    margin-top: 16%;
    // margin-left: 10%;
李晓兵's avatar
李晓兵 committed
352

linxin's avatar
linxin committed
353 354
    img {
      width: 180px;
李晓兵's avatar
李晓兵 committed
355
    }
linxin's avatar
linxin committed
356
  }
李晓兵's avatar
李晓兵 committed
357

linxin's avatar
linxin committed
358 359 360 361 362 363
  .hls-list-item {
    width: 90%;
    margin-left: 8%;
    margin-top: 6%;
    background: #1d3fff;
  }
李晓兵's avatar
李晓兵 committed
364

linxin's avatar
linxin committed
365 366 367 368
  .hls-item .contents {
    //.setBottomLine(rgba(29,63,255,0.25))
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
  }
李晓兵's avatar
李晓兵 committed
369

linxin's avatar
linxin committed
370 371 372
  .hls-item .contents .add-name .left-icon {
    width: 26px;
  }
李晓兵's avatar
李晓兵 committed
373

linxin's avatar
linxin committed
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
  .hls-item .contents .add-content input {
    text-align: left;
    background-color: #1d3fff;
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: #ffffff;
  }
  .hls-item .contents .add-content input::placeholder {
    font-family: PingFangSC-Regular;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.6);
  }
  .add-content {
    .right-icon {
      width: 14px;
    }
  }
李晓兵's avatar
李晓兵 committed
391

linxin's avatar
linxin committed
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
  .submit {
    background: #ffffff;
    border-radius: 4px;
    color: @headerColor;
    width: 279px;
    height: 40px;
    margin-top: 50px;
    display: flex;
    display: -webkit-flex;
    justify-content: center;
    -webkit-justify-content: center;
    align-items: center;
    -webkit-align-items: center;
    &.activated {
      opacity: 0.8;
      -webkit-transform: scale(1, 1);
      transform: scale(1, 1);
李晓兵's avatar
李晓兵 committed
409 410
    }
  }
linxin's avatar
linxin committed
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431
  .return {
    opacity: 1;
    background: #fff;
    border-radius: 8px 0 0 8px;
    height: 50px;
    margin: 0 0 6% 12%;
    font-size: 16px;
    color: #000000;
    display: flex;
    display: -webkit-flex;
    justify-content: center;
    -webkit-justify-content: center;
    align-items: center;
    -webkit-align-items: center;
    &.activated {
      opacity: 0.8;
      -webkit-transform: scale(1, 1);
      transform: scale(1, 1);
    }
  }
}
李晓兵's avatar
李晓兵 committed
432
</style>