stepMobile.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <div class="f-main">
  3. <div class="content-top">
  4. <p>密码重置</p>
  5. <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
  6. </div>
  7. <div class="f-form">
  8. <div class="page-part">
  9. <span>使用手机号<strong v-text="mobileText">183*****08</strong>接收验证码</span>
  10. </div>
  11. <div class="page-part">
  12. <mt-field auto-complete="off"
  13. placeholder="短信验证码"
  14. v-model="token"
  15. :state="state.token"
  16. @blur.native.capture="validateCode">
  17. <span class="token" @click="getCheckCode" v-text="tokenText">获取验证码</span>
  18. </mt-field>
  19. </div>
  20. <div class="page-part">
  21. <mt-button size="large" type="primary" @click="sureAccount('select')">确定</mt-button>
  22. </div>
  23. </div>
  24. </div>
  25. </template>
  26. <script>
  27. export default {
  28. name: 'step-mobile',
  29. data () {
  30. return {
  31. state: {
  32. token: 'error'
  33. },
  34. mobileText: '183*****08',
  35. token: '',
  36. tokenCode: '',
  37. tokenText: '获取验证码',
  38. tokenTime: '60'
  39. }
  40. },
  41. methods: {
  42. jump (type) {
  43. this.$emit('stepEvent', type)
  44. },
  45. // 警告弹窗
  46. downToast (type) {
  47. this.$toast({
  48. message: type,
  49. iconClass: 'el-icon-warning'
  50. })
  51. },
  52. // 验证码验证
  53. validateCode () {
  54. if (!this.token) {
  55. this.downToast('请填写验证码信息')
  56. this.state.token = 'error'
  57. } else {
  58. this.state.token = 'success'
  59. }
  60. },
  61. // 获取验证码
  62. getCheckCode () {
  63. if (this.tokenTime > 0 && this.tokenTime < 60) {
  64. this.downToast('请稍后再点击,我在倒计时')
  65. } else {
  66. this.$indicator.open('获取中...')
  67. let _this = this
  68. this.$http.get('/sso/personal/register/checkCode', {params: {mobile: this.mobile}})
  69. .then(response => {
  70. this.$indicator.close()
  71. if (response.data) {
  72. this.tokenCode = response.data.token
  73. this.$toast({
  74. message: '验证码已经发送到您的手机,请注意查收',
  75. iconClass: 'el-icon-success'
  76. })
  77. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  78. let setTime = setInterval(() => {
  79. _this.tokenTime--
  80. this.tokenText = '已发送(' + this.tokenTime + 'S)'
  81. if (this.tokenTime <= 0) {
  82. clearInterval(setTime)
  83. _this.tokenText = '获取验证码'
  84. _this.tokenTime = 60
  85. }
  86. }, 1000)
  87. }
  88. }).catch(() => {
  89. this.$indicator.close()
  90. this.downToast('请检查网络是否正常或联系服务商')
  91. })
  92. }
  93. },
  94. // 验证信息
  95. sureAccount (type) {
  96. if (this.state.token !== 'success') {
  97. this.downToast('请确认填写部分是否有误')
  98. } else {
  99. this.$indicator.open('验证过程中...')
  100. let param = new FormData()
  101. param.append('code', this.valid.token)
  102. param.append('token', this.tokenCode)
  103. let config = {
  104. headers: {'Content-Type': 'multipart/form-data'}
  105. }
  106. this.$http.post('/sso/resetPwd/check/mobile', param, config)
  107. .then(response => {
  108. this.$indicator.close()
  109. if (response.data.success) {
  110. this.$emit('stepEvent', type)
  111. this.$store.commit('login/GET_TOKEN', response.data.content.token)
  112. } else {
  113. this.getCode()
  114. this.downToast(response.data.errMsg)
  115. }
  116. }).catch(() => {
  117. this.$indicator.close()
  118. this.downToast('请检查网络是否正常或联系服务商')
  119. })
  120. }
  121. }
  122. }
  123. }
  124. </script>