From 4c902d1277ed6650a98c581c1222ec06ded27a87 Mon Sep 17 00:00:00 2001 From: xingyy <373639591@qq.com> Date: Wed, 14 Aug 2024 15:51:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E6=8A=95=E7=A5=A8=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=92=8C=E7=9B=B8=E5=85=B3API=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在认证模块中添加了投票功能相关的API调用和前端界面交互。此更改包括后端API的调用、存储状态管理以及前端页面的交互实现,允许用户在系统中对作品进行投票。 --- src/api/auth/index.js | 7 +++++++ src/store/auth/index.js | 18 +++++++++++++++++- src/views/vote/index.vue | 4 ++-- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/api/auth/index.js b/src/api/auth/index.js index 1846559..3a90252 100644 --- a/src/api/auth/index.js +++ b/src/api/auth/index.js @@ -43,3 +43,10 @@ export const workInfo = (data) => { data, }) } +export const voteAPI = (data) => { + return request({ + url: '/api/children/competition/vote', + method: 'POST', + data, + }) +} diff --git a/src/store/auth/index.js b/src/store/auth/index.js index 098c662..21f6769 100644 --- a/src/store/auth/index.js +++ b/src/store/auth/index.js @@ -1,6 +1,14 @@ import {ref,computed} from 'vue' import {createGlobalState,useStorage} from '@vueuse/core' -import {competitionApply, competitionWorks, loginRegister, sendCode, uploadFile, workInfo} from '@/api/auth/index.js' +import { + competitionApply, + competitionWorks, + loginRegister, + sendCode, + uploadFile, + voteAPI, + workInfo +} from '@/api/auth/index.js' import {message} from "@/utils/message.js" import { useRouter } from 'vue-router'; import { showImagePreview } from 'vant'; @@ -18,6 +26,13 @@ export const useAuth=createGlobalState(()=>{ const showTextCode=computed(()=>{ return isCountingDown.value ? `${countdown.value}s` : '获取验证码' }) + const sendVote=async ()=>{ + + const res= await voteAPI({workUid:workUid.value}) + if (res.status===0){ + message.success('投票成功') + } + } const getWorkInfo=async ()=>{ const res=await workInfo({workUid:workUid.value}) if (res.status===0){ @@ -198,6 +213,7 @@ export const useAuth=createGlobalState(()=>{ })*/ } return { + sendVote, workData, workUid, getWorkInfo, diff --git a/src/views/vote/index.vue b/src/views/vote/index.vue index f372d16..d5cae87 100644 --- a/src/views/vote/index.vue +++ b/src/views/vote/index.vue @@ -1,7 +1,7 @@