diff --git a/src/api/auth/index.js b/src/api/auth/index.js index a78cfdb..062228a 100644 --- a/src/api/auth/index.js +++ b/src/api/auth/index.js @@ -28,3 +28,11 @@ export const uploadFile = (data) => { data, }) } +export const competitionWorks = (data) => { + return request({ + isFormData:true, + url: '/api/children/competition/works', + method: 'POST', + data, + }) +} diff --git a/src/assets/image/zu3222@2x.png b/src/assets/image/zu3222@2x.png new file mode 100644 index 0000000..b4004d6 Binary files /dev/null and b/src/assets/image/zu3222@2x.png differ diff --git a/src/assets/image/zu3316@2x.png b/src/assets/image/zu3316@2x.png new file mode 100644 index 0000000..67b2b0f Binary files /dev/null and b/src/assets/image/zu3316@2x.png differ diff --git a/src/main.js b/src/main.js index 7588280..6617765 100644 --- a/src/main.js +++ b/src/main.js @@ -4,9 +4,13 @@ import App from './App.vue' import '@unocss/reset/sanitize/sanitize.css' import '@unocss/reset/sanitize/assets.css' import 'virtual:uno.css' +import { ImagePreview } from 'vant'; + import router from "./router/index.js"; const app = createApp(App); app.use(router); +app.use(ImagePreview); + app.directive('no-space', { mounted(el) { el.addEventListener('input', (e) => { diff --git a/src/router/index.js b/src/router/index.js index 64d593a..6e4ac02 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -20,6 +20,11 @@ const routes = [ name: 'confirm', component: () => import('@/views/confirm/index.vue') }, + { + path: '/details', + name: 'details', + component: () => import('@/views/details/index.vue') + }, ]; diff --git a/src/service/index.js b/src/service/index.js index 80ce91a..3cf915e 100644 --- a/src/service/index.js +++ b/src/service/index.js @@ -1,5 +1,6 @@ import { useRouter } from 'vue-router'; import Request from '@/service/request/index.js' +import {message} from "@/utils/message.js"; const request = new Request({ baseURL: import.meta.env.VITE_BASEURL, timeout: 1000 * 60 * 5, @@ -20,6 +21,9 @@ const request = new Request({ }, //实例的响应拦截器 responseInterceptors: async (response) => { + if (response.data.status===1){ + message.warning(response.data.msg) + } if ([200, 201, 204].includes(response.status)) { return response.config.responseType === 'blob' ? response : response; } else { diff --git a/src/store/auth/index.js b/src/store/auth/index.js index 741e62e..f64d6a9 100644 --- a/src/store/auth/index.js +++ b/src/store/auth/index.js @@ -1,16 +1,16 @@ import {ref,computed} from 'vue' import {createGlobalState,useStorage} from '@vueuse/core' -import {competitionApply, loginRegister, sendCode} from '@/api/auth/index.js' +import {competitionApply, competitionWorks, loginRegister, sendCode} from '@/api/auth/index.js' import {message} from "@/utils/message.js" import { useRouter } from 'vue-router'; export const useAuth=createGlobalState(()=>{ const router = useRouter(); const token = useStorage('token', '', localStorage) - const telNum =ref('') + const telNum =useStorage('telNum', '', localStorage) const code=ref('') - const countdown = ref(0); - const isCountingDown = ref(false); + const countdown = ref(0) + const isCountingDown = ref(false) const showTextCode=computed(()=>{ return isCountingDown.value ? `${countdown.value}s` : '获取验证码' }) @@ -18,20 +18,38 @@ export const useAuth=createGlobalState(()=>{ {text:'男',value:'男'}, {text:'女',value:'女'} ]) - - const formData=ref({ +// 验证 formData 中的字段 + function validateFormData() { + // 验证基本信息 + const baseFields = ['name', 'age', 'gender']; + if (baseFields.some(field => !Boolean(formData.value[field]))) { + return false; + } + // 验证 works 数组中的每一个作品 + if (formData.value.works.some(work => + !Boolean(work.picUrl) || + !Boolean(work.workName) || + !Boolean(work.length) || + !Boolean(work.wide))) { + return false; + } + return true; + } + const detailData=useStorage('detailData', {}, localStorage) + const formData=useStorage('formData',{ name:'', age:'', gender:'', works:[ { + imgList:[], picUrl: "", //作品图片url workName: "", //作品名称 length: undefined, //长度 wide:undefined//宽度 } ] - }) + },localStorage) const clickAddWorks=()=>{ formData.value.works.push({ picUrl: "", //作品图片url @@ -44,15 +62,32 @@ export const useAuth=createGlobalState(()=>{ formData.value.works.splice(index,1) } const clickApply=async ()=>{ + const isValid = validateFormData(); + if (!isValid){ + message.warning('作品信息不全,请补充') + return + } const data={ ...formData.value } const res=await competitionApply(data) if(res.status===0){ message.success('报名成功') + router.push('/confirm') } } let timer = null; + const getDetail=async ()=>{ + if (!telNum.value){ + message.error('获取手机号失败') + return + } + const res=await competitionWorks({telNum:telNum.value}) + if (res.status===0){ + console.log(res.data,'getDetail') + detailData.value=res.data + } + } const clickLogin=async ()=>{ const data={ telNum:telNum.value, @@ -60,9 +95,16 @@ export const useAuth=createGlobalState(()=>{ } const res=await loginRegister(data) if(res.status===0){ - message.success('登录成功') - token.value=res.data.token - router.push('/signup') + if (res.data.status===1){ + message.warning('您已经报名') + await getDetail() + router.push('/details') + }else { + message.success('登录成功') + token.value=res.data.token + router.push('/signup') + } + } } const clickSendCode=async ()=>{ @@ -94,6 +136,7 @@ export const useAuth=createGlobalState(()=>{ } } return { + detailData, removeWorks, clickAddWorks, genderOptions, diff --git a/src/views/details/index.vue b/src/views/details/index.vue new file mode 100644 index 0000000..b5acbf9 --- /dev/null +++ b/src/views/details/index.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/views/details/size375/index.vue b/src/views/details/size375/index.vue new file mode 100644 index 0000000..3eb2508 --- /dev/null +++ b/src/views/details/size375/index.vue @@ -0,0 +1,330 @@ + + + + + diff --git a/src/views/details/size768/index.vue b/src/views/details/size768/index.vue new file mode 100644 index 0000000..0f5f9f8 --- /dev/null +++ b/src/views/details/size768/index.vue @@ -0,0 +1,45 @@ + + + + + diff --git a/src/views/signup/size375/index.vue b/src/views/signup/size375/index.vue index 3062425..9d83943 100644 --- a/src/views/signup/size375/index.vue +++ b/src/views/signup/size375/index.vue @@ -8,11 +8,18 @@ function onConfirm(data){ formData.value.gender=data.selectedValues?.[0] showPicker.value=false } -const afterRead=(file)=>{ - const formData = new FormData() - formData.append("file", file.file) - formData.append("type", 'image') - uploadFile(formData) +const afterRead=async (file,item)=>{ + const formData1 = new FormData() + formData1.append("file", file.file) + formData1.append("type", 'image') +const res=await uploadFile(formData1) + if (res.status===0){ + item.picUrl=res.data + } +} +const deleteImg=(item)=>{ +item.picUrl='' + item.imgList=[] }