123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- <template>
- <div class="club-register">
- <el-form :model="formData" :rules="rules" ref="form" label-width="0">
- <el-form-item prop="mobile">
- <el-input
- v-model="formData.mobile"
- placeholder="手机号"
- @blur="onMobileBlur"
- maxlength="11"
- show-word-limit
- ></el-input>
- </el-form-item>
- <el-form-item prop="verifyCode">
- <div class="verifyCode flex justify-between">
- <el-input
- v-model="formData.verifyCode"
- placeholder="验证码"
- maxlength="6"
- show-word-limit
- ></el-input>
- <div class="send ml-8">获取验证码</div>
- </div>
- </el-form-item>
- <el-form-item prop="password">
- <el-input v-model="formData.password" placeholder="密码"></el-input>
- </el-form-item>
- <el-form-item prop="confirmPwd">
- <el-input
- v-model="formData.confirmPwd"
- placeholder="再次输入密码"
- ></el-input>
- </el-form-item>
- </el-form>
- <SimpleDialog
- v-model="active"
- @confirm="onConfirm"
- @cancel="onCancel"
- description="抱歉,该手机号已注册,您可以登录后再来进行正品授权申请!"
- :center="true"
- />
- </div>
- </template>
- <script>
- import { mapGetters } from 'vuex'
- import { isMobile } from '@/utils/validator'
- export default {
- data() {
- const confirmPwdValide = (rule, value, callback) => {
- if (this.formData.password !== value) {
- callback(new Error('两次输入的密码不一致'))
- } else {
- callback()
- }
- }
- return {
- formData: {
- mobile: '',
- verifyCode: '',
- password: '',
- confirmPwd: '',
- },
- active: false,
- rules: {
- mobile: [
- { required: true, message: '手机号不能为空', trigger: ['blur'] },
- ],
- verifyCode: [
- { required: true, message: '验证码不能为空', trigger: ['blur'] },
- ],
- password: [
- { required: true, message: '密码不能为空', trigger: ['blur'] },
- ],
- confirmPwd: [
- { required: true, message: '请再次输入密码', trigger: ['blur'] },
- { validator: confirmPwdValide, trigger: ['blur'] },
- ],
- },
- }
- },
- computed: {
- ...mapGetters(['authUserId', 'routePrefix', 'accessToken']),
- },
- methods: {
- onConfirm() {
- this.$router.push(`${this.routePrefix}`)
- },
- onCancel() {
- this.active = false
- },
- onMobileBlur() {
- this.checkouMobileBindClub()
- },
- // 判断用户手机号是否绑定机构
- async checkouMobileBindClub() {
- if (!isMobile(this.formData.mobile)) return
- try {
- const res = await this.$http.api.checkouMobileBindClub({
- authUserId: this.authUserId,
- mobile: this.formData.mobile,
- })
- if (res.data.clubUser) {
- this.active = true
- }
- } catch (error) {
- console.log(error)
- }
- },
- // 表单验证
- validate() {
- this.$emit('step', this.formData)
- return this.$refs.form.validate()
- },
- },
- }
- </script>
- <style lang="scss" scoped>
- .verifyCode {
- .send {
- cursor: pointer;
- white-space: nowrap;
- @include themify($themes) {
- color: themed('color');
- }
- }
- }
- </style>
|