完善个人中心、报名逻辑

This commit is contained in:
awei 2024-02-24 14:10:40 +08:00
parent 95bc54d191
commit 626bb5f9f6
4 changed files with 205 additions and 7 deletions

View File

@ -1,9 +1,10 @@
<script lang="ts" setup>
import type { PropType } from 'vue'
import { showToast } from 'vant'
import { showSuccessToast, showToast } from 'vant'
import FormItem from './FormItem.vue'
import { getSignUpFormConfig, signUp, smsSend } from '@/api/mice'
import useUserStore from '@/stores/modules/user'
import router from '@/router'
defineProps({
disabled: {
@ -19,6 +20,7 @@ const form = defineModel({
const userStore = useUserStore()
const miceLink = getUrlMiceLink()
const sendBtnText = ref('发送验证码')
//
const formConfigs = ref<any[]>([])
@ -35,6 +37,8 @@ function onSubmit() {
form.value.openId = userStore.openId
signUp(form.value).then(() => {
// console.log(res)
showSuccessToast('报名成功')
router.push(`/user/${router.currentRoute.value.params.miceLink}`)
})
}
@ -43,8 +47,18 @@ async function sendSmsHandler() {
if (!form.value.phone || !/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(form.value.phone)) {
return showToast('请输入正确的手机号')
}
//
let count = 60
sendBtnText.value = `${count}秒后重发`
const timer = setInterval(() => {
count--
sendBtnText.value = `${count}秒后重发`
if (count <= 0) {
clearInterval(timer)
sendBtnText.value = '发送验证码'
}
}, 1000)
await smsSend(form.value.phone)
// console.log(res)
}
</script>
@ -56,8 +70,8 @@ async function sendSmsHandler() {
<!-- 验证码 -->
<van-field v-model="form.verifyCode" center clearable label="短信验证码" placeholder="请输入短信验证码">
<template #button>
<van-button size="small" type="primary" @click="sendSmsHandler">
发送验证码
<van-button size="small" :disabled="sendBtnText !== '发送验证码'" type="primary" @click="sendSmsHandler">
{{ sendBtnText }}
</van-button>
</template>
</van-field>

View File

@ -15,7 +15,6 @@ function checkIsApply() {
const miceLink = getUrlMiceLink()
openidIsApply({ openId: userStore.wxInfo.openid, miceLink }).then((res: any) => {
userIsApply.value = res
if (res) {
router.replace(`/user/${miceLink}`)
}

View File

@ -3,13 +3,34 @@ import vueQr from 'vue-qr/src/packages/vue-qr.vue'
import useMiceStore from '@/stores/modules/mice'
import useUserStore from '@/stores/modules/user'
import SignForm from '@/views/signUp/components/SignForm.vue'
import { openidIsApply } from '@/api/weixin'
import router from '@/router'
const userStore = useUserStore()
const miceStore = useMiceStore()
const userApplyInfo = ref<any>({})
const userApplyInfo = ref<any>({
auditStatus: 3,
})
const userIsApply = ref(false)
//
function checkIsApply() {
const miceLink = getUrlMiceLink()
openidIsApply({ openId: userStore.wxInfo.openid, miceLink }).then((res: any) => {
userIsApply.value = res
if (res) {
router.replace(`/user/${miceLink}`)
}
else {
router.replace(`/signUp/${miceLink}`)
}
})
}
onMounted(() => {
checkIsApply()
userStore.getApplyUserInfo(getUrlMiceLink()).then((res) => {
userApplyInfo.value = res
})
@ -58,7 +79,7 @@ onMounted(() => {
<!-- 电子票 -->
<div class="ticket-qrcode">
<span>签到二维码</span>
<vue-qr :text="userApplyInfo.code" />
<vue-qr v-if="userApplyInfo.code" :text="userApplyInfo.code" />
<div class="tips">
出示二维码签到更方便
</div>

File diff suppressed because one or more lines are too long