| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- <template>
- <div class="f-main">
- <div class="content-top">
- <p>验证邮箱</p>
- <a href="javascript:void(0)" class="back" @click="jump('select')"><i class="el-icon-back"></i></a>
- </div>
- <div class="f-form">
- <div class="page-part">
- <span>使用手机号<strong>{{info | hide}}</strong>接收验证码</span>
- </div>
- <div class="page-part">
- <mt-field auto-complete="off"
- placeholder="短信验证码"
- v-model="code"
- :state="state.code"
- @blur.native.capture="validateCode">
- <span class="token" @click="getCheckCode" v-text="tokenText">获取验证码</span>
- </mt-field>
- </div>
- <div class="page-part">
- <mt-button size="large" type="primary" @click="sureAccount">下一步</mt-button>
- </div>
- </div>
- </div>
- </template>
- <script>
- export default {
- name: 'step-mobile',
- props: ['info'],
- data () {
- return {
- state: {
- code: 'error'
- },
- code: '',
- tokenCode: '',
- tokenText: '获取验证码',
- tokenTime: '60'
- }
- },
- filters: {
- hide: function (value) {
- let reg = /^(\d{3})\d{6}(\d{2})$/
- return value.replace(reg, '$1******$2')
- }
- },
- methods: {
- jump (type) {
- this.$emit('stepEvent', type)
- },
- // 警告弹窗
- downToast (type) {
- this.$toast({
- message: type,
- iconClass: 'el-icon-warning'
- })
- },
- // 验证码验证
- validateCode () {
- if (!this.code) {
- this.downToast('请填写验证码信息')
- this.state.code = 'error'
- } else {
- let param = new FormData()
- param.append('mobile', this.info)
- param.append('code', this.code)
- param.append('token', this.tokenCode)
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post(`/update/user/checkCode/mobile`, param, config)
- .then(response => {
- if (response.data.success) {
- this.state.code = 'success'
- } else {
- this.state.code = 'error'
- return Promise.reject(response.data)
- }
- }).catch(err => {
- this.downToast(err.errMsg)
- })
- }
- },
- // 获取验证码
- getCheckCode () {
- if (this.tokenTime > 0 && this.tokenTime < 60) {
- this.downToast('请稍后再点击,我在倒计时')
- } else {
- this.$indicator.open('获取中...')
- let _this = this
- this.$http.get('/update/user/check/mobile', {params: {mobile: this.info}})
- .then(response => {
- this.$indicator.close()
- if (response.data) {
- this.tokenCode = response.data.content.token
- this.$toast({
- message: '验证码已经发送到您的手机,请注意查收',
- iconClass: 'el-icon-success'
- })
- this.tokenText = '已发送(' + this.tokenTime + 'S)'
- let setTime = setInterval(() => {
- _this.tokenTime--
- this.tokenText = '已发送(' + this.tokenTime + 'S)'
- if (this.tokenTime <= 0) {
- clearInterval(setTime)
- _this.tokenText = '获取验证码'
- _this.tokenTime = 60
- }
- }, 1000)
- }
- }).catch((err) => {
- this.$indicator.close()
- this.downToast(err.errMsg)
- })
- }
- },
- // 验证信息
- sureAccount () {
- if (this.state.code !== 'success') {
- this.downToast('请确认填写部分是否有误')
- } else {
- this.$indicator.open('验证过程中...')
- let param = new FormData()
- param.append('mobile', this.info)
- param.append('code', this.code)
- param.append('token', this.tokenCode)
- let config = {
- headers: {'Content-Type': 'multipart/form-data'}
- }
- this.$http.post('/update/user/check/mobile', param, config)
- .then(response => {
- this.$indicator.close()
- if (response.data.success) {
- this.$emit('stepEvent', 'new')
- this.$emit('tokenEvent', response.data.content)
- } else {
- this.downToast(response.data.errMsg)
- }
- }).catch((err) => {
- this.$indicator.close()
- this.downToast(err.errMsg)
- })
- }
- }
- }
- }
- </script>
|