ValidationEmailStepNew.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>验证邮箱</p>
  5. </div>
  6. <div class="f-form">
  7. <div class="page-part">
  8. <mt-field placeholder="新邮箱地址"
  9. v-model="valid.email"
  10. :state="state.email"
  11. @blur.native.capture="validateEmail"
  12. ></mt-field>
  13. </div>
  14. <div class="page-part">
  15. <mt-button :disabled="hasSend" size="large"
  16. type="primary"
  17. @click="sureAccount()"
  18. v-text="secretEmail">发送验证请求</mt-button>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. export default {
  25. name: 'step-one',
  26. props: ['tokenId'],
  27. data () {
  28. return {
  29. state: {
  30. email: 'error'
  31. },
  32. valid: {
  33. email: ''
  34. },
  35. secretEmail: '发送验证请求',
  36. hasSend: false
  37. }
  38. },
  39. methods: {
  40. // 弹窗处理
  41. downToast (type) {
  42. this.$toast({
  43. message: type,
  44. iconClass: 'el-icon-warning'
  45. })
  46. },
  47. // 验证邮箱号
  48. validateEmail () {
  49. let reg = /^([\w-])+(\.\w+)*@([\w-])+((\.\w{2,3}){1,3})$/
  50. if (!this.valid.email) {
  51. this.downToast('请先填写邮箱号')
  52. this.state.email = 'error'
  53. } else {
  54. if (!reg.test(this.valid.email)) {
  55. this.downToast('请填写正确的邮箱号')
  56. this.state.email = 'warning'
  57. } else {
  58. this.state.email = 'success'
  59. }
  60. }
  61. },
  62. sureAccount () {
  63. if (this.state.email !== 'success') {
  64. this.downToast('请确认填写是否有误')
  65. } else {
  66. this.$indicator.open('发送过程中...')
  67. this.$http.get(`/update/user/setEmail`, {params: {email: this.valid.email, token: this.tokenId ? this.tokenId : this.$route.query.token, url: window.location.href}})
  68. .then(response => {
  69. this.$indicator.close()
  70. if (response.data.success) {
  71. this.hasSend = true
  72. this.secretEmail = '已发送验证邮件,请查收'
  73. } else {
  74. this.hasSend = false
  75. this.downToast(response.data.errMsg)
  76. }
  77. }).catch((err) => {
  78. this.$indicator.close()
  79. this.downToast(err.errMsg)
  80. })
  81. }
  82. }
  83. }
  84. }
  85. </script>