diff --git a/package.json b/package.json index 16c60d7..e46fc69 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host 0.0.0.0", "build": "vite build", "preview": "vite preview" }, diff --git a/src/api/CanApi.js b/src/api/CanApi.js index d7aef9c..02ad5cc 100644 --- a/src/api/CanApi.js +++ b/src/api/CanApi.js @@ -2,18 +2,18 @@ import service from "." const CanApi = { //获取候选人列表 - getCandidates(jwcode){ - return service.get('/getCandidates/'+`${jwcode}`); + getCandidates(token){ + return service.post('/getCandidates/',token); }, //投票 - Vote(voter){ + Vote(token,code){ console.log("+++++++++") - return service.post('/vote',voter) + return service.post('/vote',{token,code}) }, //查看详情 - Detail(code){ - return service.get('/getVotesByCandidate/'+`${code}`) + Detail(token){ + return service.get('/getVotesByCandidate/'+`${token}`) } } diff --git a/src/assets/image.png b/src/assets/image.png index d699648..b1b5c42 100644 Binary files a/src/assets/image.png and b/src/assets/image.png differ diff --git a/src/views/FrontView.vue b/src/views/FrontView.vue index 52e4091..f9e3b33 100644 --- a/src/views/FrontView.vue +++ b/src/views/FrontView.vue @@ -3,6 +3,24 @@ import CanApi from '@/api/CanApi'; import { defaultInitialZIndex, ElMessage } from 'element-plus'; import { ref } from 'vue'; +//地址 +var url = "https://wwww.voted?token=9H0l5gBX0kPIbYe1rBrnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w" +var token = null; +function getToken() { + var url = "https://wwww.voted?token=9H0l5gBX0kPIbYe1rBrnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w" + // 使用 URL 对象解析 URL + var parsedUrl = new URL(url); + + // 使用 URLSearchParams 获取 token 参数 + // token = parsedUrl.searchParams.get("token"); + token = "9H0l5gBX0kPIbYe1rBrnbZi0+fEeMx8pywnIlrmTxo5EOPR/wjWDV7w7+ZUseiBtf9kFa/atmNx6QfSpv5w"; + console.log("token字符串:",token); // 输出 token 的值 + // token = JSON.parse(tokenStr); + // console.log("token json格式:",token); +} +getToken(); + + //候选人 const candidates = ref([]) const first = ref(); @@ -86,8 +104,8 @@ const backCandidates = ref([ ]) let key = 10017; //加载候选人 -function loadCandidates(jwcode) { - CanApi.getCandidates(jwcode).then(result => { +function loadCandidates(token) { + CanApi.getCandidates(token).then(result => { candidates.value = result.data; candidates.value = result.data; first.value = candidates.value[0]; // 假设第一个候选人 @@ -105,26 +123,19 @@ function loadCandidates(jwcode) { console.log("候选人:", backCandidates.value); }) } -loadCandidates(key); +loadCandidates(token); //投票 -const voter = ref({ - jwCode: key, - candidateJwCode: 20010, - name: "小辉" -}) function vote(code) { console.log("code:", code) - voter.value.candidateJwCode = code; - console.log("voter:", voter.value) // voter.value.voterJwcode,voter.value.candidateJwcode,voter.value.voterName - CanApi.Vote(voter.value).then(result => { + CanApi.Vote(token,code).then(result => { if (result.code == 10000) { ElMessage.success(result.msg); - loadCandidates(key); + loadCandidates(token); } else { ElMessage.error(result.msg) - loadCandidates(key); + loadCandidates(token); } }) } @@ -359,17 +370,17 @@ function vote(code) { .cover2 { position: absolute; - left: 11.5%; - top: -6%; - width: 19%; - height: 12%; + left: 11.7%; + top: -5.9%; + width: 19.1%; + height: 9%; border-radius: 50%; } .one-button2 { position: absolute; left: 9%; - top: 3%; + top: 2%; width: 22%; height: 3.5%; border-radius: 20px 20px 20px 20px; @@ -388,7 +399,7 @@ function vote(code) { .buttoned2 { position: absolute; left: 9%; - top: 3%; + top: 2%; width: 22%; height: 3.5%; border-radius: 20px 20px 20px 20px; @@ -407,7 +418,7 @@ function vote(code) { .votes2 { position: absolute; left: 11%; - top: 7%; + top: 6%; width: 25%; height: 3%; font-family: Alibaba PuHuiTi; @@ -425,7 +436,7 @@ function vote(code) { height: 15%; position: absolute; left: 14%; - top: 12%; + top: 10.5%; /* z-index: 999; */ } @@ -436,7 +447,7 @@ function vote(code) { background-repeat: no-repeat; position: absolute; left: 38%; - top: -11%; + top: -10%; width: 25%; height: 20%; } @@ -444,10 +455,10 @@ function vote(code) { .cover1 { position: absolute; - left: 41%; - top: -9.5%; - width: 19%; - height: 12%; + left: 40.9%; + top: -8%; + width: 19.1%; + height: 9%; border-radius: 50%; } @@ -509,7 +520,7 @@ function vote(code) { background-repeat: no-repeat; position: absolute; left: 47%; - top: 9.5%; + top: 8.5%; width: 5%; height: 15%; /* z-index: 999; */ @@ -528,10 +539,10 @@ function vote(code) { .cover3 { position: absolute; - left: 71%; + left: 70.8%; top: -6%; - width: 19%; - height: 12%; + width: 19.1%; + height: 9%; border-radius: 50%; } @@ -539,7 +550,7 @@ function vote(code) { position: absolute; left: 69%; - top: 3%; + top: 2%; width: 22%; height: 3.5%; border-radius: 20px 20px 20px 20px; @@ -558,7 +569,7 @@ function vote(code) { .buttoned3 { position: absolute; left: 69%; - top: 3%; + top: 2%; width: 22%; height: 3.5%; border-radius: 20px 20px 20px 20px; @@ -577,7 +588,7 @@ function vote(code) { .votes3 { position: absolute; left: 72%; - top: 7%; + top: 6%; width: 25%; height: 3%; font-family: Alibaba PuHuiTi; @@ -594,7 +605,7 @@ function vote(code) { background-repeat: no-repeat; position: absolute; left: 75%; - top: 12%; + top: 10.5%; width: 7%; height: 15%; /* z-index: 999; */ @@ -650,7 +661,7 @@ function vote(code) { height: 18%; border-radius: 50%; /* 圆形头像 */ - margin-right: 2%; + margin-right: 2%; } .votes {