You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

129 lines
3.6 KiB

4 weeks ago
  1. <template>
  2. <div class="main">
  3. <div class="title">
  4. <a href="/login">登录</a>
  5. <span>·</span>
  6. <a class="active" href="/register">注册</a>
  7. </div>
  8. <div class="sign-up-container">
  9. <form action="register">
  10. <div class="input-prepend restyle">
  11. <input
  12. v-model="member.nickname"
  13. type="text"
  14. placeholder="你的昵称">
  15. <i class="iconfont icon-user"/>
  16. </div>
  17. <div class="input-prepend restyle no-radius">
  18. <input
  19. v-model="member.mobile"
  20. type="text"
  21. placeholder="手机号">
  22. <i class="iconfont icon-phone"/>
  23. </div>
  24. <div class="input-prepend restyle no-radius" style="position:relative">
  25. <input
  26. v-model="member.code"
  27. type="text"
  28. placeholder="验证码">
  29. <i class="iconfont icon-yanzhengma"/>
  30. <a
  31. href="javascript:"
  32. type="button"
  33. style="position:absolute;right: 10px;top: 15px;"
  34. @click="getCodeFun()">{{ codeText }}</a>
  35. </div>
  36. <div class="input-prepend">
  37. <input
  38. v-model="member.password"
  39. type="password"
  40. placeholder="设置密码">
  41. <i class="iconfont icon-password"/>
  42. </div>
  43. <div class="btn">
  44. <input
  45. type="button"
  46. class="sign-up-button"
  47. value="注册"
  48. @click="submitRegister()">
  49. </div>
  50. <p class="sign-up-msg">
  51. 点击 注册 即表示您同意并愿意遵守简书
  52. <br>
  53. <a target="_blank" href="http://www.jianshu.com/p/c44d171298ce">用户协议</a>
  54. <a target="_blank" href="http://www.jianshu.com/p/2ov8x3">隐私政策</a>
  55. </p>
  56. </form>
  57. <!-- 更多注册方式 -->
  58. <div class="more-sign">
  59. <h6>社交帐号直接注册</h6>
  60. <ul>
  61. <li><a id="weixin" class="weixin" href="http://localhost:8160/api/ucenter/wx/login"><i class="iconfont icon-weixin"/></a></li>
  62. <li><a id="qq" class="qq" target="_blank" href="#"><i class="iconfont icon-qq"/></a></li>
  63. </ul>
  64. </div>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import '~/assets/css/sign.css'
  70. import '~/assets/css/iconfont.css'
  71. import registerApi from '~/api/register'
  72. export default {
  73. layout: 'sign',
  74. data() {
  75. return {
  76. member: {
  77. mobile: '',
  78. code: '',
  79. nickname: '',
  80. password: ''
  81. },
  82. sending: false, // 是否发送验证码
  83. second: 30, // 倒计时间
  84. codeText: '获取验证码'
  85. }
  86. },
  87. methods: {
  88. // 获取验证码
  89. getCodeFun() {
  90. if (this.sending) return
  91. this.sending = true// 用户已点击
  92. registerApi.sendMessage(this.member.mobile).then(response => {
  93. // 倒计时
  94. this.timeDown()
  95. // 提示用户发送成功
  96. this.$message.success(response.message)
  97. })
  98. },
  99. // 倒计时
  100. timeDown() {
  101. this.codeText = this.second
  102. // 定义计数器
  103. const timer = setInterval(() => {
  104. this.codeText--
  105. if (this.codeText < 1) {
  106. clearInterval(timer)
  107. this.codeText = '获取验证码'
  108. this.sending = false
  109. // this.second = 30
  110. }
  111. }, 1000)
  112. },
  113. // 注册
  114. submitRegister() {
  115. registerApi.register(this.member).then(response => {
  116. // 提示注成功
  117. this.$message.success(response.message)
  118. this.$router.push({ path: 'login' })
  119. })
  120. }
  121. }
  122. }
  123. </script>