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

@@ -9,67 +9,75 @@
</div>
</div>
<div class="empty-box flexcenter" v-loading="true" v-if="(MyPopupState == 'collect' && collectLoading) || (MyPopupState == 'mj' && publisloading)"></div>
<div class="empty-box flexcenter" v-else-if="showList.length == 0">
<!-- <div class="empty-box flexcenter" v-loading="true" v-if="(MyPopupState == 'collect' && collectLoading) || (MyPopupState == 'mj' && publisloading)"></div> -->
<div class="empty-box flexcenter" v-if="showList.length == 0">
<Empty></Empty>
</div>
<el-scrollbar v-else height="479px">
<div class="content" @scroll="handleListScroll">
<div class="item flexflex" v-for="(item, index) in showList" :key="index" @click="goDetails(item['uniqid'] || item?.data?.uniqid)">
<div class="item flexflex" v-for="(item, index) in showList" :key="item.uniqid" @click="goDetails(item['uniqid'] || item?.data?.uniqid)">
<div class="left flexflex">
<div class="name">{{ item.title }}</div>
<div class="message">{{ item.message }}</div>
<div class="name ellipsis">{{ item.title || item.data?.title }}</div>
<div class="message ellipsis">{{ item.message || item.data?.message }}</div>
<div class="data">
30人参与 <i>|</i> 投票已结束
<span><i>|</i> 我已投不懂围观学习</span>
{{ item.votes || item.data?.votes || 0 }}人参与 <i>|</i> {{ handleDeadline(item.deadline || item?.data?.deadline) }}结束
<span v-if="item.optionvalue || item?.data?.optionvalue"><i>|</i> 我已投{{ item.optionvalue || item?.data?.optionvalue }}</span>
</div>
</div>
<div class="operate-area flexacenter">
<img class="delete-icon" v-if="MyPopupState == 'collect'" @click.stop="cancelCollection(item['token'], index)" src="@/assets/img/delete-icon.svg" />
<div class="anonymous-box flexacenter" v-else @click.stop="openAnonymousState(index)">
<div class="text">{{ item["anonymous"] == 1 ? "匿名" : "公开" }}</div>
<img class="arrow-icon" src="@/assets/img/arrow-gray.svg" />
<div class="state-popup flexflex" v-if="item['anonymousState']" @click.stop="">
<div class="state-popup-item flexacenter flex1" :class="{ 'pitch': item['anonymous'] == 0 }" @click="handleAnonymousState(item['token'], index, 0)">
<div class>公开发表</div>
<img class="state-popup-icon" src="@/assets/img/tick-green.svg" />
</div>
<div class="state-popup-item flexacenter flex1" :class="{ 'pitch': item['anonymous'] == 1 }" @click="handleAnonymousState(item['token'], index, 1)">
<div class>匿名发表</div>
<img class="state-popup-icon" src="@/assets/img/tick-green.svg" />
<!-- <div class="anonymous-box flexacenter" v-if="MyPopupState == 'publish'" @click.stop="openAnonymousState(index)"> -->
<template v-if="MyPopupState == 'publish'">
<div class="anonymous-box flexacenter" @click.stop="openAnonymousState(index)">
<div class="text">{{ item["anonymous"] == 1 ? "匿名" : "公开" }}</div>
<img class="arrow-icon" src="@/assets/img/arrow-gray.svg" />
<div class="state-popup flexflex" v-if="item['anonymousState']" @click.stop="">
<div class="state-popup-item flexacenter flex1" :class="{ 'pitch': item['anonymous'] == 0 }" @click="handleAnonymousState(item['token'], index, 0)">
<div class>公开发表</div>
<img class="state-popup-icon" src="@/assets/img/tick-green.svg" />
</div>
<div class="state-popup-item flexacenter flex1" :class="{ 'pitch': item['anonymous'] == 1 }" @click="handleAnonymousState(item['token'], index, 1)">
<div class>匿名发表</div>
<img class="state-popup-icon" src="@/assets/img/tick-green.svg" />
</div>
</div>
</div>
</div>
<div class="halving-line"></div>
<img class="delete-icon" @click.stop="openDeleteVote(item['token'], index, item.uniqid || item?.data?.uniqid)" src="@/assets/img/delete-icon.svg" />
</template>
<img class="delete-icon" v-if="MyPopupState == 'collect'" @click.stop="cancelCollection(item['token'], index, item.uniqid || item?.data?.uniqid)" src="@/assets/img/delete-icon.svg" />
</div>
</div>
</div>
</el-scrollbar>
</div>
</el-dialog>
<el-dialog class="options-popup" v-model="deleteState" 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="deleteVote">删除投票</div>
<div class="options-popup-item options-yes flexcenter" @click="deleteState = false">不删除</div>
</div>
</el-dialog>
<!-- </div> -->
</template>
<script setup>
let props = defineProps({
// MyPopupState: String, // collect mj
count: Object,
tabList: Array,
})
let deleteState = ref(false) // 确认删除弹窗
let count = inject("count")
let show = ref(false)
const router = useRouter()
const route = useRoute()
let MyPopupState = ref("") // collect participation sponsor
let MyPopupState = ref("") // collect takevote publish
onMounted(() => {
// if (MyPopupState.value == "collect") getCollect();
// else if (MyPopupState.value == "mj") getPublish();
})
const tabList = [
{ name: "我的收藏", type: "collect" },
{ name: "我参与的投票", type: "participation" },
{ name: "我发起的投票", type: "sponsor" },
]
onMounted(() => {})
// 展示的 列表数据
let showList = ref([])
@@ -82,20 +90,20 @@ let collectCount = ref(0)
const getCollect = () => {
if (collectPage == 0 || collectLoading.value) return
collectLoading.value = true
// if (collectPage == 2) return
MyUserCollectHttp({ page: collectPage })
.then(res => {
if (res.code != 200) return
let data = res.data
collectList = collectList.concat(data.data)
showList.value = collectList
// showList.value = showList.value.concat(data.data)
if (collectList.length < data["count"]) collectPage++
else collectPage = 0
collectCount.value = data["count"]
// MyPopupState.value = "collect"
// show.value = true
})
.finally(() => (collectLoading.value = false))
}
@@ -104,11 +112,10 @@ let publishList = []
let publisPage = 1
let publisloading = ref(false)
const getPublish = () => {
return
if (publisPage == 0 && !publisloading.value) return
publisloading.value = true
MyUserPublishHttp({ limit: 4, page: publisPage })
MyUserPublishHttp({ page: publisPage })
.then(res => {
if (res.code != 200) return
let data = res.data
@@ -116,13 +123,28 @@ const getPublish = () => {
if (publishList.length < data["count"]) publisPage++
else publisPage = 0
showList.value = publishList
// MyPopupState.value = "mj"
// show.value = true
})
.finally(() => (publisloading.value = false))
}
let takevoteList = []
let takevotePage = 1
let takevoteloading = ref(false)
const getTakevote = () => {
if (takevotePage == 0 && !takevoteloading.value) return
takevoteloading.value = true
MyUserTakevoteHttp({ page: takevotePage })
.then(res => {
if (res.code != 200) return
let data = res.data
takevoteList = takevoteList.concat(data.data)
if (takevoteList.length < data["count"]) takevotePage++
else takevotePage = 0
showList.value = takevoteList
})
.finally(() => (takevoteloading.value = false))
}
// 切换 isEmpty 是否清空收藏数据, 因为不确定用户是否有新收藏
const cutMy = (key, isEmpty) => {
if (isEmpty) {
@@ -132,10 +154,12 @@ const cutMy = (key, isEmpty) => {
}
if (key == "collect" && collectList.length == 0) getCollect()
else if (key == "mj" && publishList.length == 0) getPublish()
else if (key == "takevote" && takevoteList.length == 0) getTakevote()
else if (key == "publish" && publishList.length == 0) getPublish()
if (key == "collect") showList.value = collectList
else if (key == "mj") showList.value = publishList
else if (key == "takevote") showList.value = takevoteList
else if (key == "publish") showList.value = publishList
MyPopupState.value = key
@@ -161,7 +185,10 @@ const closeAllAnonymousState = () => {
// 修改匿名状态
const handleAnonymousState = (token, index, anonymous) => {
changeAnonymousHttp({ token, anonymous }).then(res => {
if (res.code != 200) return
if (res.code != 200) {
ElMessage.error(res.message)
return
}
publishList[index]["anonymous"] = anonymous
showList.value = [...publishList]
@@ -177,7 +204,8 @@ const handleListScroll = e => {
// 判断滚动到底部
if (el.scrollHeight - el.scrollTop !== el.clientHeight) return
if (MyPopupState.value == "collect") getCollect()
if (MyPopupState.value == "mj") getPublish()
if (MyPopupState.value == "takevote") getTakevote()
if (MyPopupState.value == "publish") getPublish()
}
let clearAllData = inject("clearAllData") || null
@@ -185,7 +213,7 @@ let getDetails = inject("getDetails") || null
// 打开详情页
const goDetails = uniqid => {
return
// return
let path = route["path"] || ""
if (path.indexOf("/details/") != -1) {
clearAllData()
@@ -209,9 +237,12 @@ const closeDialog = () => {
}
// const emit = defineEmits(["cutMy"]);
const unbookmarkSamePage = inject("unbookmarkSamePage")
// 处理取消收藏
const cancelCollection = (token, index) => {
const cancelCollection = (token, index, uniqid) => {
const id = route.params["id"]
MyUserDeleteCollectHttp({ token }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
@@ -219,8 +250,42 @@ const cancelCollection = (token, index) => {
}
collectList.splice(index, 1)
count.value.collect--
collectCount.value--
showList.value = [...collectList]
if (id == uniqid) unbookmarkSamePage()
})
}
let deleteobj = {}
const openDeleteVote = (token, index, uniqid) => {
deleteobj["token"] = token
deleteobj["index"] = index
deleteobj["uniqid"] = uniqid
deleteState.value = true
}
// 点删除投票
const deleteVote = () => {
const id = route.params["id"]
deleteHttp({ token: deleteobj["token"] }).then(res => {
if (res.code != 200) {
ElMessage.error(res.message)
return
}
count.value.publish--
publishList.splice(deleteobj["index"], 1)
showList.value = [...publishList]
if (id == deleteobj["uniqid"]) unbookmarkSamePage()
ElMessage.success(res.message)
deleteobj = {}
deleteState.value = false
})
}
</script>
@@ -302,7 +367,8 @@ const cancelCollection = (token, index) => {
.content {
width: 100%;
height: 100%;
height: 479px;
// height: 100%;
// background: #000000;
overflow: auto;
// padding-right: 13px;
@@ -337,12 +403,14 @@ const cancelCollection = (token, index) => {
line-height: 20px;
font-size: 14px;
margin-bottom: 10px;
width: 550px;
}
.message {
color: #7f7f7f;
line-height: 22px;
font-size: 13px;
margin-bottom: 6px;
width: 550px;
}
.data {
@@ -363,6 +431,13 @@ const cancelCollection = (token, index) => {
cursor: pointer;
}
.halving-line {
margin: 0 20px;
width: 1px;
height: 13px;
border-right: 1px solid #d7d7d7;
}
.anonymous-box {
.text {
font-size: 13px;