完善个人中心、报名逻辑
This commit is contained in:
parent
95bc54d191
commit
626bb5f9f6
@ -1,9 +1,10 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { PropType } from 'vue'
|
import type { PropType } from 'vue'
|
||||||
import { showToast } from 'vant'
|
import { showSuccessToast, showToast } from 'vant'
|
||||||
import FormItem from './FormItem.vue'
|
import FormItem from './FormItem.vue'
|
||||||
import { getSignUpFormConfig, signUp, smsSend } from '@/api/mice'
|
import { getSignUpFormConfig, signUp, smsSend } from '@/api/mice'
|
||||||
import useUserStore from '@/stores/modules/user'
|
import useUserStore from '@/stores/modules/user'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
disabled: {
|
disabled: {
|
||||||
@ -19,6 +20,7 @@ const form = defineModel({
|
|||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const miceLink = getUrlMiceLink()
|
const miceLink = getUrlMiceLink()
|
||||||
|
const sendBtnText = ref('发送验证码')
|
||||||
|
|
||||||
// 表单配置项
|
// 表单配置项
|
||||||
const formConfigs = ref<any[]>([])
|
const formConfigs = ref<any[]>([])
|
||||||
@ -35,6 +37,8 @@ function onSubmit() {
|
|||||||
form.value.openId = userStore.openId
|
form.value.openId = userStore.openId
|
||||||
signUp(form.value).then(() => {
|
signUp(form.value).then(() => {
|
||||||
// console.log(res)
|
// 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)) {
|
if (!form.value.phone || !/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(form.value.phone)) {
|
||||||
return showToast('请输入正确的手机号')
|
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)
|
await smsSend(form.value.phone)
|
||||||
// console.log(res)
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -56,8 +70,8 @@ async function sendSmsHandler() {
|
|||||||
<!-- 验证码 -->
|
<!-- 验证码 -->
|
||||||
<van-field v-model="form.verifyCode" center clearable label="短信验证码" placeholder="请输入短信验证码">
|
<van-field v-model="form.verifyCode" center clearable label="短信验证码" placeholder="请输入短信验证码">
|
||||||
<template #button>
|
<template #button>
|
||||||
<van-button size="small" type="primary" @click="sendSmsHandler">
|
<van-button size="small" :disabled="sendBtnText !== '发送验证码'" type="primary" @click="sendSmsHandler">
|
||||||
发送验证码
|
{{ sendBtnText }}
|
||||||
</van-button>
|
</van-button>
|
||||||
</template>
|
</template>
|
||||||
</van-field>
|
</van-field>
|
||||||
|
@ -15,7 +15,6 @@ function checkIsApply() {
|
|||||||
const miceLink = getUrlMiceLink()
|
const miceLink = getUrlMiceLink()
|
||||||
openidIsApply({ openId: userStore.wxInfo.openid, miceLink }).then((res: any) => {
|
openidIsApply({ openId: userStore.wxInfo.openid, miceLink }).then((res: any) => {
|
||||||
userIsApply.value = res
|
userIsApply.value = res
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
router.replace(`/user/${miceLink}`)
|
router.replace(`/user/${miceLink}`)
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,34 @@ import vueQr from 'vue-qr/src/packages/vue-qr.vue'
|
|||||||
import useMiceStore from '@/stores/modules/mice'
|
import useMiceStore from '@/stores/modules/mice'
|
||||||
import useUserStore from '@/stores/modules/user'
|
import useUserStore from '@/stores/modules/user'
|
||||||
import SignForm from '@/views/signUp/components/SignForm.vue'
|
import SignForm from '@/views/signUp/components/SignForm.vue'
|
||||||
|
import { openidIsApply } from '@/api/weixin'
|
||||||
|
import router from '@/router'
|
||||||
|
|
||||||
const userStore = useUserStore()
|
const userStore = useUserStore()
|
||||||
const miceStore = useMiceStore()
|
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(() => {
|
onMounted(() => {
|
||||||
|
checkIsApply()
|
||||||
userStore.getApplyUserInfo(getUrlMiceLink()).then((res) => {
|
userStore.getApplyUserInfo(getUrlMiceLink()).then((res) => {
|
||||||
userApplyInfo.value = res
|
userApplyInfo.value = res
|
||||||
})
|
})
|
||||||
@ -58,7 +79,7 @@ onMounted(() => {
|
|||||||
<!-- 电子票 -->
|
<!-- 电子票 -->
|
||||||
<div class="ticket-qrcode">
|
<div class="ticket-qrcode">
|
||||||
<span>签到二维码</span>
|
<span>签到二维码</span>
|
||||||
<vue-qr :text="userApplyInfo.code" />
|
<vue-qr v-if="userApplyInfo.code" :text="userApplyInfo.code" />
|
||||||
<div class="tips">
|
<div class="tips">
|
||||||
出示二维码,签到更方便
|
出示二维码,签到更方便
|
||||||
</div>
|
</div>
|
||||||
|
164
vite.config.ts.timestamp-1708754004762-94ff511867383.mjs
Normal file
164
vite.config.ts.timestamp-1708754004762-94ff511867383.mjs
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user