no message

This commit is contained in:
A1300399510
2024-01-15 19:02:10 +08:00
parent 6a7d5f221e
commit e01ac5326b
12 changed files with 479 additions and 119 deletions

View File

@@ -1,4 +1,9 @@
<template>
<Head>
<Title>{{ `${seo["title"] || "投票"} - 寄托天下出国留学网` }}</Title>
<Meta name="keyword" :content="seo['keyword']" />
<Meta name="description" :content="seo['description']" />
</Head>
<TopHead></TopHead>
<div class="content flexflex" :style="{ '--main-color': colourValue[uniqidIndex]['main'], '--bg-color': colourValue[uniqidIndex]['bg'], '--bc-color': colourValue[uniqidIndex]['bc'] }">
<div class="header flexacenter">
@@ -43,18 +48,17 @@
</div>
</div>
<div class="message">{{ info.message }}</div>
<!-- 共有 58 人参与你已投票 -->
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes} 人参与,` : `共有 ${info.votes} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes || ""} 人参与,` : `共有 ${info.votes || 0} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<div class="option-list flexflex" v-if="info['status'] == 1">
<div class="option-item flexflex" v-for="(item, index) in option" :key="item.id">
<div class="option-list flexflex" v-if="info['status'] == 1 && isvote == 0">
<div class="option-item flexflex" v-for="(item, index) in option" :key="item.id" @click="handleVote(item.id, index)">
<div class="serial flexcenter">{{ index + 1 }}</div>
<span class="flex1">{{ item.value }} </span>
</div>
</div>
<div class="option-area" v-else>
<div class="option-item flexflex" :class="{ 'pitch': item.selected }" v-for="(item, index) in option" :key="item.id">
<div class="option-item flexflex" :class="{ 'pitch': item.selected }" v-for="(item, index) in option" :key="item.id" @click="handleUnvoteVote(index, item.selected)">
<div class="flexflex" style="padding: 2px 0px;">
<div class="option-number flexcenter">{{ index + 1 }}</div>
<img class="tick-icon" src="@/assets/img/tick-black.svg" />
@@ -70,13 +74,25 @@
<div class="right"><DetailsComments :token="token"></DetailsComments></div>
</div>
<DetailsArea></DetailsArea>
<el-dialog class="options-popup" v-model="cancelPopoverState" width="488px" align-center>
<div class="options-popup-text">您要取消投票吗</div>
<div class="options-popup-btn flexflex">
<div class="options-popup-item options-no flexcenter" @click="unvoteVote">取消投票</div>
<div class="options-popup-item options-yes flexcenter" @click="cancelPopoverState = false">不取消</div>
</div>
</el-dialog>
</template>
<script setup>
import { useRoute } from "vue-router"
useHead({ script: [{ src: "https://app.gter.net/bottom?tpl=header&menukey=mj" }, { src: "https://app.gter.net/bottom?tpl=footer", body: true }] })
import { useRoute, useRouter } from "vue-router"
import { ElMessage } from "element-plus"
const route = useRoute()
// console.log(route, "route")
const router = useRouter()
let isNeedLogin = inject("isNeedLogin")
const goLogin = inject("goLogin")
@@ -84,7 +100,10 @@ let id = route.params.id
const uniqidEnd = id.charAt(id.length - 1)
const uniqidIndex = base62ToDecimal(uniqidEnd) % 6
onMounted(() => getinit())
onMounted(() => {
getDetails()
clearBottom()
})
let info = ref({})
let qrcode = ref("") // 分享二维码
@@ -95,17 +114,19 @@ let detailsLoading = ref(false) // 详情加载中
let isvote = ref(0) // 是否已经投票
let option = ref([])
let token = ref("")
let cancelPopoverState = ref(false) // 取消投票弹窗
provide("info", info)
provide("islike", islike)
provide("iscollection", iscollection)
provide("token", token)
provide("qrcode", qrcode)
const getinit = () => {
const getDetails = () => {
detailsHttp({ uniqid: id }).then(res => {
console.log(res)
if (res.code != 200) {
ElMessage.error(res.message)
router.push("/index.html")
return
}
@@ -118,11 +139,12 @@ const getinit = () => {
option.value = data["option"]
qrcode.value = data.share?.qrcode
token.value = data["token"]
console.log(data.share?.qrcode, "data.share?.qrcode")
seo.value = data.seo
})
}
provide("getDetails", getDetails)
// 点击发送信息
const sendMessage = uin => {
redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&showmsg=1&uid=${uin}`)
@@ -143,6 +165,91 @@ const redirectToExternalWebsite = url => {
provide("sendMessage", sendMessage)
provide("TAHomePage", TAHomePage)
// 处理点进投票
const handleVote = (token, index) => {
operationCollectHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[index]["selected"] = 1
option.value = optionList
isvote.value = 1
info.value.votes = data["votes"]
ElMessage.success(res.message)
})
}
let unvoteVoteIndex = null // 选项下标
// 点击 取消投票
const handleUnvoteVote = (index, selected) => {
if (selected == 0) return
cancelPopoverState.value = true
unvoteVoteIndex = index
}
const unvoteVote = () => {
const token = option.value[unvoteVoteIndex].id
unvoteCollectHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
let data = res.data
let optionList = data["optionList"] || []
optionList[unvoteVoteIndex]["selected"] = 0
option.value = optionList
isvote.value = 0
info.value.votes = data["votes"]
cancelPopoverState.value = false
})
}
const clearAllData = () => {
info.value = {}
qrcode.value = ""
iscollection.value = 0
islike.value = 0
ismyself.value = 0
isvote.value = 0
option.value = []
}
provide("clearAllData", clearAllData)
// 取消了同页面的收藏
const unbookmarkSamePage = () => {
iscollection.value = 0
info.value.favs--
}
provide("unbookmarkSamePage", unbookmarkSamePage)
// 删除同页面的投票需要跳转到 首页
const unbookmark = () => router.push("/index.html")
provide("unbookmark", unbookmark)
let seo = ref({})
// 清除底部的次数
let clearBottomCount = 0
// 清除 底部
const clearBottom = () => {
const indexFooter = document.querySelector("section.index-footer")
if (!indexFooter) {
clearBottomCount++
setTimeout(() => clearBottom(), 200)
return
}
if (clearBottomCount == 5) return
indexFooter.style.display = "none"
}
</script>
<style scoped lang="less">
@@ -153,6 +260,7 @@ provide("TAHomePage", TAHomePage)
border-radius: 16px;
background: #fff;
flex-wrap: wrap;
// min-height: 100vh;
--main-color: rgba(44, 186, 230, 1);
--bg-color: rgba(234, 245, 248, 1);
@@ -234,6 +342,7 @@ provide("TAHomePage", TAHomePage)
line-height: 24px;
color: #333;
margin-bottom: 30px;
word-wrap: break-word;
}
.hint {
@@ -326,10 +435,12 @@ provide("TAHomePage", TAHomePage)
padding: 7px 15px 10px;
flex-direction: column;
word-break: break-all;
cursor: no-drop;
&:not(:last-of-type) {
border-bottom: 1px solid var(--bc-color);
}
&.pitch {
cursor: pointer;
.option-number {
display: none;
}
@@ -395,3 +506,50 @@ provide("TAHomePage", TAHomePage)
}
}
</style>
<style lang="less">
.options-popup {
border-radius: 10px;
.el-dialog__header {
padding: 0;
.el-dialog__headerbtn {
width: 36px;
height: 36px;
}
}
padding: 44px 74px;
.el-dialog__body {
padding: 0;
}
.options-popup-text {
font-size: 14px;
color: #333333;
text-align: center;
margin-bottom: 71px;
}
.options-popup-btn {
justify-content: space-between;
.options-popup-item {
font-size: 13px;
width: 160px;
height: 40px;
border-radius: 150px;
border: 1px solid;
cursor: pointer;
&.options-yes {
background-color: rgba(114, 219, 134, 1);
border-color: rgba(114, 219, 134, 1);
color: #fff;
}
&.options-no {
background-color: #fff;
border-color: rgba(170, 170, 170, 1);
color: #333;
}
}
}
}
</style>