实现投票功能和相关API调用
在认证模块中添加了投票功能相关的API调用和前端界面交互。此更改包括后端API的调用、存储状态管理以及前端页面的交互实现,允许用户在系统中对作品进行投票。
This commit is contained in:
parent
34d23f8ea8
commit
4c902d1277
@ -43,3 +43,10 @@ export const workInfo = (data) => {
|
||||
data,
|
||||
})
|
||||
}
|
||||
export const voteAPI = (data) => {
|
||||
return request({
|
||||
url: '/api/children/competition/vote',
|
||||
method: 'POST',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script setup>
|
||||
import {useAuth} from "@/store/auth/index.js";
|
||||
import { useRoute } from 'vue-router';
|
||||
const {detailData,workUid,getWorkInfo,workData,openMask} =useAuth()
|
||||
const {detailData,workUid,getWorkInfo,workData,openMask,sendVote} =useAuth()
|
||||
const route = useRoute()
|
||||
if (route.query.uid){
|
||||
workUid.value = route.query.uid;
|
||||
@ -14,7 +14,7 @@ if (route.query.uid){
|
||||
<div class="mt-[123px] w-[1654px] h-[2729px] bg-[url('@/assets/image/zu3186@2x.png')] bg-cover bg-no-repeat flex flex-col items-center ">
|
||||
<img :src="workData?.picUrl" @click="openMask(workData?.picUrl)" class="max-w-1362px max-h-1362px mt-404px rounded-20px object-contain" alt="">
|
||||
<div class="text-primary text-72px mt-51px">{{workData?.workName}}</div>
|
||||
<div class="bg-[url('@/assets/image/fbbb@4x.png')] w-866px h-200px bg-no-repeat bg-cover text-white text-82px flex-center mt-[205px] font-bold">投票</div>
|
||||
<div class="bg-[url('@/assets/image/fbbb@4x.png')] w-866px h-200px bg-no-repeat bg-cover text-white text-82px flex-center mt-[205px] font-bold" @click="sendVote">投票</div>
|
||||
</div>
|
||||
<div class="absolute top-0 left-0 w-[671px] h-[728px] bg-cover">
|
||||
<img src="@/assets/image/gdz27.png" alt="" />
|
||||
|
Loading…
Reference in New Issue
Block a user