no message

This commit is contained in:
A1300399510
2024-01-18 17:25:40 +08:00
parent e01ac5326b
commit 7390c2fc72
11 changed files with 273 additions and 67 deletions

View File

@@ -4,14 +4,16 @@
<Meta name="keyword" :content="seo['keyword']" />
<Meta name="description" :content="seo['description']" />
</Head>
<TopHead></TopHead>
<TopHead ref="topHeadRef"></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">
<span>{{ info.title }}</span>
<span class="views flexcenter">
<img class="eye-icon" src="@/assets/img/eye-icon.svg" />
{{ info.views }}
</span>
<ClientOnly>
<span class="views flexcenter">
<img class="eye-icon" src="@/assets/img/eye-icon.svg" />
{{ info.views }}
</span>
</ClientOnly>
</div>
<div class="left">
<div class="info flexacenter">
@@ -19,7 +21,7 @@
<el-popover placement="bottom-start" :width="140" trigger="click" popper-class="avatar-box-popper" :show-arrow="false">
<template #reference>
<div class="flexcenter">
<img class="avatar" v-if="info.avatar" :src="info.avatar" />
<img class="avatar" :src="info.avatar" />
<div class="username">{{ info.nickname }}</div>
</div>
</template>
@@ -49,7 +51,7 @@
</div>
<div class="message">{{ info.message }}</div>
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes || ""} 人参与,` : `共有 ${info.votes || 0} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<div class="hint">{{ info.status == 1 && isvote == 0 ? `已有 ${info.votes || 0} 人参与,` : `共有 ${info.votes || 0} 人参与` }} {{ `${isvote == 1 ? "你已投票" : info.status == 1 ? "参与投票即可查看实时结果" : ""}` }}</div>
<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)">
@@ -71,7 +73,7 @@
</div>
</div>
</div>
<div class="right"><DetailsComments :token="token"></DetailsComments></div>
<div class="right"><DetailsComments ref="commentsRef" :token="token"></DetailsComments></div>
</div>
<DetailsArea></DetailsArea>
@@ -166,48 +168,82 @@ 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"]
const commentsRef = ref(null)
let voteLoading = false
ElMessage.success(res.message)
})
// 处理点击投票
const handleVote = (token, index) => {
if (isNeedLogin.value) {
goLogin()
return
}
if (voteLoading) return
voteLoading = true
topHeadRef.value.count = {}
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"]
const value = optionList[index]["value"]
commentsRef.value.changeCommentVoteoption(value)
ElMessage.success(res.message)
})
.finally(() => (voteLoading = false))
}
let unvoteVoteIndex = null // 选项下标
// 点击 取消投票
const handleUnvoteVote = (index, selected) => {
if (isNeedLogin.value) {
goLogin()
return
}
if (selected == 0) return
cancelPopoverState.value = true
unvoteVoteIndex = index
}
const unvoteVote = () => {
if (isNeedLogin.value) {
goLogin()
return
}
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
})
if (voteLoading) return
voteLoading = true
topHeadRef.value.count = {}
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
commentsRef.value.wipeCommentVoteoption()
})
.finally(() => (voteLoading = false))
}
const clearAllData = () => {
@@ -227,6 +263,7 @@ const unbookmarkSamePage = () => {
iscollection.value = 0
info.value.favs--
}
provide("unbookmarkSamePage", unbookmarkSamePage)
// 删除同页面的投票需要跳转到 首页
@@ -250,6 +287,27 @@ const clearBottom = () => {
indexFooter.style.display = "none"
}
let topHeadRef = ref(null)
provide("topHeadRef", topHeadRef)
try {
if (process.server) {
await detailsHttp({ uniqid: id }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
router.push("/index.html")
return
}
let data = res.data
info.value = data["info"]
option.value = data["option"]
isvote.value = data["isvote"]
seo.value = data.seo
})
}
} catch (error) {}
</script>
<style scoped lang="less">
@@ -288,7 +346,7 @@ const clearBottom = () => {
.left {
width: 658px;
// height: 500px;
min-height: calc(100vh - 165px);
padding: 30px 42px 100px 30px;
border-right: 16px solid #f6f6f6;
.info {

View File

@@ -44,14 +44,15 @@
</div>
</div>
</a>
<div class="empty-box flexcenter" v-if="keyword && list.length == 0">
<Empty :isNeedIssue="true"></Empty>
</div>
<div class="empty-box flexcenter" v-if="keyword && list.length == 0"><Empty :isNeedIssue="true"></Empty></div>
</div>
</template>
<script setup>
useHead({ script: [{ src: "https://app.gter.net/bottom?tpl=header&menukey=vote" }, { src: "https://app.gter.net/bottom?tpl=footer", body: true }] })
let isNeedLogin = inject("isNeedLogin")
const goLogin = inject("goLogin")
import { useRoute } from "vue-router"
const route = useRoute()
const router = useRouter()
@@ -116,6 +117,10 @@ const handleScroll = () => {
// 处理点赞
const handleLike = (token, index) => {
if (isNeedLogin.value) {
goLogin()
return
}
operateLikeHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
@@ -202,7 +207,7 @@ try {
margin: 0 auto;
display: flex;
flex-wrap: wrap;
min-height: 100vh;
.vote-item {
width: 385px;
background-color: rgba(255, 255, 255, 1);
@@ -312,6 +317,7 @@ try {
font-size: 14px;
color: #333;
line-height: 20px;
word-break: break-word;
}
.vote-option-progress {

View File

@@ -37,9 +37,11 @@
<div class="time-box item-input-box flexacenter">
<el-config-provider :locale="zhCn">
<el-date-picker v-model="info.deadline" type="date" placeholder="请选择" size="large" class="flex1 flexacenter" :clear-icon="{}" value-format="YYYY-MM-DD" :disabled-date="setDisabled" />
<el-date-picker ref="pickerRef" v-model="info.deadline" type="date" placeholder="请选择" size="large" class="flex1 flexacenter" :clear-icon="{}" value-format="YYYY-MM-DD" :disabled-date="setDisabled" />
</el-config-provider>
<img class="calendar-icon" src="@/assets/img/calendar-icon.svg" />
<div class="flexacenter">
<img class="calendar-icon" @click="handlePicker" src="@/assets/img/calendar-icon.svg" />
</div>
</div>
</div>
</div>
@@ -122,7 +124,15 @@ import Sortable from "sortablejs"
const router = useRouter()
const goLogin = inject("goLogin")
const setDisabled = time => {
return time.getTime() < Date.now() // 可选历史天、可选当前天、不可选未来天
// return time.getTime() < Date.now() // 可选历史天、可选当前天、不可选未来天
const today = new Date()
const tomorrow = new Date(today)
tomorrow.setDate(today.getDate())
const thirtyDaysLater = new Date(today)
thirtyDaysLater.setDate(today.getDate() + 29)
return time < tomorrow || time > thirtyDaysLater
}
onMounted(() => {})
@@ -190,6 +200,16 @@ const submit = (status = 1) => {
return
}
const hash = {}
for (let i = 0; i < option.length; i++) {
if (hash[option[i]]) {
ElMessage.error("选项名称不能重复")
loading = false
return // 有重复值
}
hash[option[i]] = true
}
option.push("不懂,围观学习")
}
@@ -239,11 +259,16 @@ const getinit = () => {
const data = res.data
// data.info.option = []
const option = data.info?.option || []
if (option.length == 0) {
for (let index = 0; index < 2; index++) {
optionList.value.push({ id: index, message: "" })
}
} else {
while (option.length < 2) {
option.push(null)
}
option.forEach((message, index) => {
optionList.value.push({ id: index, message })
})
@@ -321,6 +346,11 @@ const deleteOption = index => {
const clearMessage = index => {
optionList.value[index]["message"] = ""
}
let pickerRef = ref(null)
const handlePicker = () => {
pickerRef.value.handleOpen()
}
</script>
<style scoped lang="less">
@@ -417,9 +447,9 @@ const clearMessage = index => {
.time-box {
.calendar-icon {
width: 15px;
height: 16px;
margin: 0 12px;
width: 17px;
// height: 16px;
margin: 0 9px;
cursor: auto;
}
@@ -540,6 +570,7 @@ const clearMessage = index => {
font-size: 14px;
color: #333;
cursor: pointer;
margin-bottom: 50px;
// max-width: max-content;
}
}