详情页服务器请求加缓存
This commit is contained in:
@@ -70,7 +70,7 @@
|
||||
</div>
|
||||
<div class="option-area" v-else>
|
||||
<div class="option-item flexflex unselected" :class="{ pitch: item.selected, 'cursor-no': info.status == 0 }" v-for="(item, index) in option" :key="item.id" @click="handleUnvoteVote(index, item.selected)">
|
||||
<div class="flexflex" style="padding: 2px 0px;">
|
||||
<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" />
|
||||
<div class="option-content flex1">{{ item.value }}</div>
|
||||
@@ -163,196 +163,196 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
useHead({ script: [{ src: "https://app.gter.net/bottom?tpl=header&menukey=vote" }, { src: "https://app.gter.net/bottom?tpl=footer,popupnotification", body: true }] })
|
||||
useHead({ script: [{ src: "https://app.gter.net/bottom?tpl=header&menukey=vote" }, { src: "https://app.gter.net/bottom?tpl=footer,popupnotification", body: true }] });
|
||||
|
||||
import { useRoute, useRouter } from "vue-router"
|
||||
import { ElMessage } from "element-plus"
|
||||
import { useRoute, useRouter } from "vue-router";
|
||||
import { ElMessage } from "element-plus";
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
let isNeedLogin = inject("isNeedLogin")
|
||||
const goLogin = inject("goLogin")
|
||||
let isNeedLogin = inject("isNeedLogin");
|
||||
const goLogin = inject("goLogin");
|
||||
|
||||
let commentComments = ref(0)
|
||||
let commentComments = ref(0);
|
||||
|
||||
let id = route.params.id
|
||||
let uniqidIndex = ref(0)
|
||||
let id = route.params.id;
|
||||
let uniqidIndex = ref(0);
|
||||
|
||||
if (route.query.colorI) uniqidIndex.value = route.query.colorI
|
||||
else uniqidIndex.value = Math.floor(Math.random() * 6)
|
||||
if (uniqidIndex.value > 6) uniqidIndex = 0
|
||||
if (route.query.colorI) uniqidIndex.value = route.query.colorI;
|
||||
else uniqidIndex.value = Math.floor(Math.random() * 6);
|
||||
if (uniqidIndex.value > 6) uniqidIndex = 0;
|
||||
|
||||
onMounted(() => {
|
||||
getDetails()
|
||||
clearBottom()
|
||||
})
|
||||
getDetails();
|
||||
clearBottom();
|
||||
});
|
||||
|
||||
let ripostelist = ref([])
|
||||
let ripostecount = ref({})
|
||||
let riposteoptions = ref([])
|
||||
let ripostelist = ref([]);
|
||||
let ripostecount = ref({});
|
||||
let riposteoptions = ref([]);
|
||||
|
||||
provide("riposteoptions", riposteoptions)
|
||||
provide("riposteoptions", riposteoptions);
|
||||
|
||||
const getRiposte = () => {
|
||||
getRiposteHttp({ token: token.value }).then(res => {
|
||||
if (res.code != 200) return
|
||||
let data = res.data
|
||||
ripostecount.value = data.count || {}
|
||||
ripostelist.value = data.list || []
|
||||
riposteoptions.value = data.options || []
|
||||
getRiposteHttp({ token: token.value }).then((res) => {
|
||||
if (res.code != 200) return;
|
||||
let data = res.data;
|
||||
ripostecount.value = data.count || {};
|
||||
ripostelist.value = data.list || [];
|
||||
riposteoptions.value = data.options || [];
|
||||
|
||||
if (ripostelist.value.length <= 3) randomEmoji()
|
||||
randomBottomEmoji()
|
||||
})
|
||||
}
|
||||
if (ripostelist.value.length <= 3) randomEmoji();
|
||||
randomBottomEmoji();
|
||||
});
|
||||
};
|
||||
|
||||
let randomEmojis = ref([]) // 随机 五个 emoji
|
||||
let randomBottomEmojis = ref([]) // 随机 8个 emoji
|
||||
provide("randomEmojis", randomEmojis)
|
||||
provide("randomBottomEmojis", randomBottomEmojis)
|
||||
let randomEmojis = ref([]); // 随机 五个 emoji
|
||||
let randomBottomEmojis = ref([]); // 随机 8个 emoji
|
||||
provide("randomEmojis", randomEmojis);
|
||||
provide("randomBottomEmojis", randomBottomEmojis);
|
||||
|
||||
// 随机 7 个Emoji
|
||||
const randomEmoji = () => {
|
||||
let emojiList = ripostelist.value
|
||||
let emojiList = ripostelist.value;
|
||||
// 需要排除的 Emoji
|
||||
let exclude = []
|
||||
emojiList.forEach(element => {
|
||||
exclude.push(element.item)
|
||||
})
|
||||
let exclude = [];
|
||||
emojiList.forEach((element) => {
|
||||
exclude.push(element.item);
|
||||
});
|
||||
|
||||
let selectedList = [] // 待选择 Emoji To be selected
|
||||
let selectedList = []; // 待选择 Emoji To be selected
|
||||
// 默认是有点赞的
|
||||
for (const key in riposteoptions.value[0].data) {
|
||||
if (key != "c150") selectedList.push(key)
|
||||
if (key != "c150") selectedList.push(key);
|
||||
}
|
||||
|
||||
const random = []
|
||||
if (!exclude.includes("c150")) random.push("c150") // 添加第一个点赞 emoji
|
||||
selectedList = selectedList.filter(itemB => !exclude.includes(itemB))
|
||||
const random = [];
|
||||
if (!exclude.includes("c150")) random.push("c150"); // 添加第一个点赞 emoji
|
||||
selectedList = selectedList.filter((itemB) => !exclude.includes(itemB));
|
||||
|
||||
// 生成随机索引,确保不重复
|
||||
let indexes = []
|
||||
let indexes = [];
|
||||
while (indexes.length < 7) {
|
||||
let randomIndex = Math.floor(Math.random() * selectedList.length)
|
||||
let randomIndex = Math.floor(Math.random() * selectedList.length);
|
||||
if (indexes.indexOf(randomIndex) === -1) {
|
||||
indexes.push(randomIndex)
|
||||
random.push(selectedList[randomIndex])
|
||||
indexes.push(randomIndex);
|
||||
random.push(selectedList[randomIndex]);
|
||||
}
|
||||
}
|
||||
randomEmojis.value = random
|
||||
}
|
||||
randomEmojis.value = random;
|
||||
};
|
||||
|
||||
const randomBottomEmoji = () => {
|
||||
let selectedList = [] // 待选择 Emoji To be selected
|
||||
let selectedList = []; // 待选择 Emoji To be selected
|
||||
// 默认是有点赞的
|
||||
for (const key in riposteoptions.value[0].data) {
|
||||
selectedList.push(key)
|
||||
selectedList.push(key);
|
||||
}
|
||||
// 打乱数组顺序
|
||||
selectedList.sort(() => Math.random() - 0.5)
|
||||
const randomItems = selectedList.slice(0, 8)
|
||||
randomBottomEmojis.value = randomItems
|
||||
}
|
||||
selectedList.sort(() => Math.random() - 0.5);
|
||||
const randomItems = selectedList.slice(0, 8);
|
||||
randomBottomEmojis.value = randomItems;
|
||||
};
|
||||
|
||||
// 拼接 回应需要的 字符
|
||||
const jointriposte = item => {
|
||||
return `&#x${item};`
|
||||
}
|
||||
const jointriposte = (item) => {
|
||||
return `&#x${item};`;
|
||||
};
|
||||
|
||||
provide("jointriposte", jointriposte)
|
||||
provide("jointriposte", jointriposte);
|
||||
|
||||
// 选择回应
|
||||
const selectListEomji = index => {
|
||||
const selectListEomji = (index) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
let emojiList = ripostelist.value
|
||||
let target = emojiList[index]
|
||||
if (riposteHttpState) return
|
||||
riposteHttpState = true
|
||||
let emojiList = ripostelist.value;
|
||||
let target = emojiList[index];
|
||||
if (riposteHttpState) return;
|
||||
riposteHttpState = true;
|
||||
riposteSubmitHttp({ token: token.value, item: target.item })
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
handleEmojiData(data)
|
||||
let data = res.data;
|
||||
handleEmojiData(data);
|
||||
})
|
||||
.finally(() => {
|
||||
riposteHttpState = false
|
||||
})
|
||||
}
|
||||
riposteHttpState = false;
|
||||
});
|
||||
};
|
||||
|
||||
let riposteHttpState = false // 回应加载中
|
||||
let riposteHttpState = false; // 回应加载中
|
||||
|
||||
// 选择 emoji
|
||||
const selectEomji = item => {
|
||||
const selectEomji = (item) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (riposteHttpState) return
|
||||
riposteHttpState = true
|
||||
if (riposteHttpState) return;
|
||||
riposteHttpState = true;
|
||||
riposteSubmitHttp({ token: token.value, item })
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
handleEmojiData(data)
|
||||
let data = res.data;
|
||||
handleEmojiData(data);
|
||||
})
|
||||
.finally(() => {
|
||||
riposteHttpState = false
|
||||
})
|
||||
}
|
||||
riposteHttpState = false;
|
||||
});
|
||||
};
|
||||
|
||||
provide("selectEomji", selectEomji)
|
||||
provide("selectEomji", selectEomji);
|
||||
|
||||
// 选中 在 Emoji 弹窗中 选择
|
||||
const selectEomjiPop = key => {
|
||||
const selectEomjiPop = (key) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
let emojiList = ripostelist.value
|
||||
let emojiList = ripostelist.value;
|
||||
// 判断 是否已经 有了
|
||||
const index = emojiList.findIndex(item => item.item == key)
|
||||
if (index != -1 && emojiList[index].selected) return
|
||||
if (riposteHttpState) return
|
||||
riposteHttpState = true
|
||||
const index = emojiList.findIndex((item) => item.item == key);
|
||||
if (index != -1 && emojiList[index].selected) return;
|
||||
if (riposteHttpState) return;
|
||||
riposteHttpState = true;
|
||||
riposteSubmitHttp({ token: token.value, item: key })
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
handleEmojiData(data)
|
||||
let data = res.data;
|
||||
handleEmojiData(data);
|
||||
})
|
||||
.finally(() => {
|
||||
riposteHttpState = false
|
||||
})
|
||||
}
|
||||
riposteHttpState = false;
|
||||
});
|
||||
};
|
||||
|
||||
provide("selectEomjiPop", selectEomjiPop)
|
||||
provide("selectEomjiPop", selectEomjiPop);
|
||||
|
||||
// 专门处理 展示列表的 数据结构
|
||||
const handleEmojiData = data => {
|
||||
let emojiList = ripostelist.value
|
||||
let isnew = true
|
||||
const handleEmojiData = (data) => {
|
||||
let emojiList = ripostelist.value;
|
||||
let isnew = true;
|
||||
emojiList.forEach((element, index) => {
|
||||
if (element.item == data.item) {
|
||||
isnew = false
|
||||
if (element.selected) element.num--
|
||||
else element.num++
|
||||
element.selected = !element.selected
|
||||
isnew = false;
|
||||
if (element.selected) element.num--;
|
||||
else element.num++;
|
||||
element.selected = !element.selected;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// 代表是新数据
|
||||
if (isnew) {
|
||||
@@ -360,344 +360,355 @@ const handleEmojiData = data => {
|
||||
item: data.item,
|
||||
num: 1,
|
||||
selected: true,
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
let newArray = []
|
||||
emojiList.forEach(item => {
|
||||
if (item.num > 0) newArray.push(item)
|
||||
})
|
||||
let newArray = [];
|
||||
emojiList.forEach((item) => {
|
||||
if (item.num > 0) newArray.push(item);
|
||||
});
|
||||
|
||||
if (newArray.length < 3) randomEmoji()
|
||||
if (newArray.length < 3) randomEmoji();
|
||||
|
||||
ripostecount.value = data.count
|
||||
ripostelist.value = newArray
|
||||
}
|
||||
ripostecount.value = data.count;
|
||||
ripostelist.value = newArray;
|
||||
};
|
||||
|
||||
let info = ref({})
|
||||
let qrcode = ref("") // 分享二维码
|
||||
let iscollection = ref(0) // 是否收藏
|
||||
let islike = ref(0) // 是否点赞
|
||||
let ismyself = ref(0) // 是否是作者
|
||||
let detailsLoading = ref(false) // 详情加载中
|
||||
let isvote = ref(0) // 是否已经投票
|
||||
let option = ref([])
|
||||
let token = ref("")
|
||||
let cancelPopoverState = ref(false) // 取消投票弹窗
|
||||
let isLoaded = ref(false) // 是否加载了
|
||||
let haveVotedValue = ref("") // 已投的值
|
||||
let info = ref({});
|
||||
let qrcode = ref(""); // 分享二维码
|
||||
let iscollection = ref(0); // 是否收藏
|
||||
let islike = ref(0); // 是否点赞
|
||||
let ismyself = ref(0); // 是否是作者
|
||||
let detailsLoading = ref(false); // 详情加载中
|
||||
let isvote = ref(0); // 是否已经投票
|
||||
let option = ref([]);
|
||||
let token = ref("");
|
||||
let cancelPopoverState = ref(false); // 取消投票弹窗
|
||||
let isLoaded = ref(false); // 是否加载了
|
||||
let haveVotedValue = ref(""); // 已投的值
|
||||
|
||||
provide("info", info)
|
||||
provide("islike", islike)
|
||||
provide("iscollection", iscollection)
|
||||
provide("token", token)
|
||||
provide("qrcode", qrcode)
|
||||
provide("isLoaded", isLoaded)
|
||||
provide("haveVotedValue", haveVotedValue)
|
||||
provide("info", info);
|
||||
provide("islike", islike);
|
||||
provide("iscollection", iscollection);
|
||||
provide("token", token);
|
||||
provide("qrcode", qrcode);
|
||||
provide("isLoaded", isLoaded);
|
||||
provide("haveVotedValue", haveVotedValue);
|
||||
|
||||
const getDetails = async () => {
|
||||
detailsHttp({ uniqid: id }).then(res => {
|
||||
detailsHttp({ uniqid: id }).then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
goToURL("/index.html", false)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
goToURL("/index.html", false);
|
||||
return;
|
||||
}
|
||||
|
||||
let data = res.data
|
||||
let data = res.data;
|
||||
|
||||
info.value = data["info"]
|
||||
isvote.value = data["isvote"]
|
||||
iscollection.value = data["iscollection"]
|
||||
islike.value = data["islike"]
|
||||
ismyself.value = data["ismyself"]
|
||||
option.value = data["option"]
|
||||
qrcode.value = data.share?.qrcode
|
||||
token.value = data["token"]
|
||||
seo.value = data.seo
|
||||
info.value = data["info"];
|
||||
|
||||
isLoaded.value = true
|
||||
isvote.value = data["isvote"];
|
||||
iscollection.value = data["iscollection"];
|
||||
islike.value = data["islike"];
|
||||
ismyself.value = data["ismyself"];
|
||||
option.value = data["option"];
|
||||
qrcode.value = data.share?.qrcode;
|
||||
token.value = data["token"];
|
||||
seo.value = data.seo;
|
||||
|
||||
data["option"].forEach(element => {
|
||||
if (element.selected) haveVotedValue.value = element.value
|
||||
})
|
||||
isLoaded.value = true;
|
||||
|
||||
getRiposte()
|
||||
})
|
||||
}
|
||||
data["option"].forEach((element) => {
|
||||
if (element.selected) haveVotedValue.value = element.value;
|
||||
});
|
||||
|
||||
provide("getDetails", getDetails)
|
||||
getRiposte();
|
||||
});
|
||||
};
|
||||
|
||||
provide("getDetails", getDetails);
|
||||
|
||||
// 点击发送信息
|
||||
const sendMessage = uin => {
|
||||
const sendMessage = (uin) => {
|
||||
if (uin && typeof messagePrivateItem == "function") {
|
||||
|
||||
messagePrivateItem({ uin: uin })
|
||||
}
|
||||
else redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&showmsg=1&uid=${uin}`)
|
||||
}
|
||||
messagePrivateItem({ uin: uin });
|
||||
} else redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&showmsg=1&uid=${uin}`);
|
||||
};
|
||||
|
||||
// 点击ta的主页
|
||||
const TAHomePage = uin => {
|
||||
redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&uid=${uin}`)
|
||||
}
|
||||
const TAHomePage = (uin) => {
|
||||
redirectToExternalWebsite(`https://bbs.gter.net/home.php?mod=space&uid=${uin}`);
|
||||
};
|
||||
|
||||
// 跳转 url
|
||||
const redirectToExternalWebsite = url => {
|
||||
const link = document.createElement("a")
|
||||
link.href = url
|
||||
link.target = "_blank"
|
||||
link.click()
|
||||
}
|
||||
const redirectToExternalWebsite = (url) => {
|
||||
const link = document.createElement("a");
|
||||
link.href = url;
|
||||
link.target = "_blank";
|
||||
link.click();
|
||||
};
|
||||
|
||||
provide("sendMessage", sendMessage)
|
||||
provide("TAHomePage", TAHomePage)
|
||||
provide("sendMessage", sendMessage);
|
||||
provide("TAHomePage", TAHomePage);
|
||||
|
||||
const commentsRef = ref(null)
|
||||
let voteLoading = false
|
||||
const commentsRef = ref(null);
|
||||
let voteLoading = false;
|
||||
|
||||
// 处理点击投票的中转
|
||||
const handleVotesTransfer = index => {
|
||||
const target = option.value[index]
|
||||
if (info.value.status == 1 && isvote.value == 0) handleVote(target.id, index)
|
||||
else handleUnvoteVote(index)
|
||||
}
|
||||
const handleVotesTransfer = (index) => {
|
||||
const target = option.value[index];
|
||||
if (info.value.status == 1 && isvote.value == 0) handleVote(target.id, index);
|
||||
else handleUnvoteVote(index);
|
||||
};
|
||||
|
||||
// 处理点击投票
|
||||
const handleVote = (token, index) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
|
||||
if (voteLoading) return
|
||||
voteLoading = true
|
||||
if (voteLoading) return;
|
||||
voteLoading = true;
|
||||
|
||||
topHeadRef.value.count = {}
|
||||
topHeadRef.value.count = {};
|
||||
operationCollectHttp({ token })
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
let optionList = data["optionList"] || []
|
||||
optionList.forEach(element => {
|
||||
element["selected"] = 0
|
||||
})
|
||||
optionList[index]["selected"] = 1
|
||||
option.value = optionList
|
||||
isvote.value = 1
|
||||
info.value.votes = data["votes"]
|
||||
let data = res.data;
|
||||
let optionList = data["optionList"] || [];
|
||||
optionList.forEach((element) => {
|
||||
element["selected"] = 0;
|
||||
});
|
||||
optionList[index]["selected"] = 1;
|
||||
option.value = optionList;
|
||||
isvote.value = 1;
|
||||
info.value.votes = data["votes"];
|
||||
|
||||
const value = optionList[index]["value"]
|
||||
haveVotedValue.value = value
|
||||
commentsRef.value.changeCommentVoteoption(value)
|
||||
const value = optionList[index]["value"];
|
||||
haveVotedValue.value = value;
|
||||
commentsRef.value.changeCommentVoteoption(value);
|
||||
|
||||
ElMessage.success(res.message)
|
||||
ElMessage.success(res.message);
|
||||
|
||||
if (index != optionList.length - 1) commentsRef.value.reviewsComment(optionList[index]["value"])
|
||||
if (index != optionList.length - 1) commentsRef.value.reviewsComment(optionList[index]["value"]);
|
||||
})
|
||||
.finally(() => (voteLoading = false))
|
||||
}
|
||||
.finally(() => (voteLoading = false));
|
||||
};
|
||||
|
||||
let unvoteVoteIndex = null // 选项下标
|
||||
let unvoteVoteIndex = null; // 选项下标
|
||||
|
||||
// 点击 取消投票
|
||||
const handleUnvoteVote = (index, selected) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
if (selected == 0 || info.value.status == 0) return
|
||||
cancelPopoverState.value = true
|
||||
unvoteVoteIndex = index
|
||||
}
|
||||
if (selected == 0 || info.value.status == 0) return;
|
||||
cancelPopoverState.value = true;
|
||||
unvoteVoteIndex = index;
|
||||
};
|
||||
|
||||
const unvoteVote = () => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
const token = option.value[unvoteVoteIndex].id
|
||||
if (voteLoading) return
|
||||
voteLoading = true
|
||||
const token = option.value[unvoteVoteIndex].id;
|
||||
if (voteLoading) return;
|
||||
voteLoading = true;
|
||||
|
||||
topHeadRef.value.count = {}
|
||||
topHeadRef.value.count = {};
|
||||
|
||||
unvoteCollectHttp({ token })
|
||||
.then(res => {
|
||||
.then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
let optionList = data["optionList"] || []
|
||||
optionList.forEach(element => {
|
||||
element["selected"] = 0
|
||||
})
|
||||
option.value = optionList
|
||||
isvote.value = 0
|
||||
info.value.votes = data["votes"]
|
||||
cancelPopoverState.value = false
|
||||
let data = res.data;
|
||||
let optionList = data["optionList"] || [];
|
||||
optionList.forEach((element) => {
|
||||
element["selected"] = 0;
|
||||
});
|
||||
option.value = optionList;
|
||||
isvote.value = 0;
|
||||
info.value.votes = data["votes"];
|
||||
cancelPopoverState.value = false;
|
||||
|
||||
commentsRef.value.wipeCommentVoteoption()
|
||||
commentsRef.value.wipeCommentVoteoption();
|
||||
})
|
||||
.finally(() => (voteLoading = false))
|
||||
}
|
||||
.finally(() => (voteLoading = false));
|
||||
};
|
||||
|
||||
const clearAllData = () => {
|
||||
info.value = {}
|
||||
qrcode.value = ""
|
||||
iscollection.value = 0
|
||||
islike.value = 0
|
||||
ismyself.value = 0
|
||||
isvote.value = 0
|
||||
option.value = []
|
||||
}
|
||||
info.value = {};
|
||||
qrcode.value = "";
|
||||
iscollection.value = 0;
|
||||
islike.value = 0;
|
||||
ismyself.value = 0;
|
||||
isvote.value = 0;
|
||||
option.value = [];
|
||||
};
|
||||
|
||||
provide("clearAllData", clearAllData)
|
||||
provide("clearAllData", clearAllData);
|
||||
|
||||
// 取消了同页面的收藏
|
||||
const unbookmarkSamePage = () => {
|
||||
iscollection.value = 0
|
||||
info.value.favs--
|
||||
}
|
||||
iscollection.value = 0;
|
||||
info.value.favs--;
|
||||
};
|
||||
|
||||
provide("unbookmarkSamePage", unbookmarkSamePage)
|
||||
provide("unbookmarkSamePage", unbookmarkSamePage);
|
||||
|
||||
// 删除同页面的投票需要跳转到 首页
|
||||
const unbookmark = () => router.push("/index.html")
|
||||
provide("unbookmark", unbookmark)
|
||||
const unbookmark = () => router.push("/index.html");
|
||||
provide("unbookmark", unbookmark);
|
||||
|
||||
let seo = ref({})
|
||||
let seo = ref({});
|
||||
|
||||
// 清除底部的次数
|
||||
let clearBottomCount = 0
|
||||
let clearBottomCount = 0;
|
||||
|
||||
// 清除 底部
|
||||
const clearBottom = () => {
|
||||
const indexFooter = document.querySelector("section.index-footer")
|
||||
const indexFooter = document.querySelector("section.index-footer");
|
||||
if (!indexFooter) {
|
||||
clearBottomCount++
|
||||
setTimeout(() => clearBottom(), 200)
|
||||
return
|
||||
clearBottomCount++;
|
||||
setTimeout(() => clearBottom(), 200);
|
||||
return;
|
||||
}
|
||||
if (clearBottomCount == 5) return
|
||||
if (clearBottomCount == 5) return;
|
||||
|
||||
indexFooter.style.display = "none"
|
||||
}
|
||||
indexFooter.style.display = "none";
|
||||
};
|
||||
|
||||
let topHeadRef = ref(null)
|
||||
provide("topHeadRef", topHeadRef)
|
||||
let topHeadRef = ref(null);
|
||||
provide("topHeadRef", topHeadRef);
|
||||
|
||||
// 底部导航栏 的 点击评论输入值
|
||||
let floorCommentInput = ref("")
|
||||
let floorCommentInput = ref("");
|
||||
|
||||
// 底部导航栏 的 点击发送评论 type input back
|
||||
const floorCommentBtn = type => {
|
||||
if (type == "input") commentsRef.value.bottomNavigationBar(floorCommentInput.value)
|
||||
else floorCommentInput.value = ""
|
||||
}
|
||||
const floorCommentBtn = (type) => {
|
||||
if (type == "input") commentsRef.value.bottomNavigationBar(floorCommentInput.value);
|
||||
else floorCommentInput.value = "";
|
||||
};
|
||||
|
||||
provide("floorCommentInput", floorCommentInput)
|
||||
provide("floorCommentBtn", floorCommentBtn)
|
||||
provide("floorCommentInput", floorCommentInput);
|
||||
provide("floorCommentBtn", floorCommentBtn);
|
||||
|
||||
// 只刷新数据
|
||||
const refreshDataOnly = () => {
|
||||
clearAllData()
|
||||
getDetails()
|
||||
}
|
||||
provide("refreshDataOnly", refreshDataOnly)
|
||||
clearAllData();
|
||||
getDetails();
|
||||
};
|
||||
provide("refreshDataOnly", refreshDataOnly);
|
||||
|
||||
// 点击底部调用关闭讨论输入框
|
||||
const closeDiscussInputFields = () => {
|
||||
commentsRef.value.closeAnswerCommentsChild()
|
||||
}
|
||||
commentsRef.value.closeAnswerCommentsChild();
|
||||
};
|
||||
|
||||
let respondPopListState = ref(false) // 回应列表弹窗状态
|
||||
let respondDetail = ref({}) // 已回应列表
|
||||
let respondPopListState = ref(false); // 回应列表弹窗状态
|
||||
let respondDetail = ref({}); // 已回应列表
|
||||
|
||||
// 打开回应弹窗列表
|
||||
const openPopList = () => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
respondPopListState.value = true
|
||||
getRespondDetail()
|
||||
}
|
||||
respondPopListState.value = true;
|
||||
getRespondDetail();
|
||||
};
|
||||
|
||||
// 关闭回应弹窗列表
|
||||
const closePopList = () => {
|
||||
respondPopListState.value = false
|
||||
}
|
||||
respondPopListState.value = false;
|
||||
};
|
||||
|
||||
// 回应详情
|
||||
const getRespondDetail = () => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
riposteDetailHttp({ token: token.value }).then(res => {
|
||||
if (res.code != 200) return
|
||||
respondDetail.value = res.data
|
||||
})
|
||||
}
|
||||
riposteDetailHttp({ token: token.value }).then((res) => {
|
||||
if (res.code != 200) return;
|
||||
respondDetail.value = res.data;
|
||||
});
|
||||
};
|
||||
|
||||
// 点击回应列表的
|
||||
const selectEomjiListPop = key => {
|
||||
const selectEomjiListPop = (key) => {
|
||||
if (isNeedLogin.value) {
|
||||
goLogin()
|
||||
return
|
||||
goLogin();
|
||||
return;
|
||||
}
|
||||
// let respondDetail = respondDetail.value
|
||||
|
||||
let target = respondDetail.value[key]
|
||||
let target = respondDetail.value[key];
|
||||
|
||||
riposteSubmitHttp({ token: token.value, item: target.item }).then(res => {
|
||||
riposteSubmitHttp({ token: token.value, item: target.item }).then((res) => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
return
|
||||
ElMessage.error(res.message);
|
||||
return;
|
||||
}
|
||||
let data = res.data
|
||||
let data = res.data;
|
||||
|
||||
handleEmojiData(data)
|
||||
handleEmojiData(data);
|
||||
|
||||
if (target.selected) {
|
||||
target.user = target.user.filter(item => item.uin != data.uin)
|
||||
target.user = target.user.filter((item) => item.uin != data.uin);
|
||||
} else {
|
||||
target.user.push(data)
|
||||
target.user.push(data);
|
||||
}
|
||||
|
||||
let emojiList = ripostelist.value
|
||||
let emojiList = ripostelist.value;
|
||||
|
||||
if (target.user.length == 0) {
|
||||
emojiList = emojiList.filter(item => item.item != key)
|
||||
delete respondDetail.value[key]
|
||||
emojiList = emojiList.filter((item) => item.item != key);
|
||||
delete respondDetail.value[key];
|
||||
} else {
|
||||
target.selected = !target.selected
|
||||
respondDetail.value[key] = target
|
||||
target.selected = !target.selected;
|
||||
respondDetail.value[key] = target;
|
||||
}
|
||||
|
||||
ripostelist.value = emojiList
|
||||
})
|
||||
}
|
||||
ripostelist.value = emojiList;
|
||||
});
|
||||
};
|
||||
|
||||
const { $cache } = useNuxtApp();
|
||||
|
||||
try {
|
||||
if (process.server) {
|
||||
await detailsHttp({ uniqid: id }).then(res => {
|
||||
if (res.code != 200) {
|
||||
ElMessage.error(res.message)
|
||||
router.push("/index.html")
|
||||
return
|
||||
}
|
||||
console.log(`----------------------------------`);
|
||||
|
||||
let data = res.data
|
||||
info.value = data["info"]
|
||||
option.value = data["option"]
|
||||
isvote.value = data["isvote"]
|
||||
seo.value = data.seo
|
||||
})
|
||||
const cacheKey = `details_${id}`;
|
||||
const cachedData = $cache.get(cacheKey);
|
||||
console.log(cachedData ? "缓存数据已存在" : "缓存数据不存在");
|
||||
if (cachedData) {
|
||||
let data = cachedData;
|
||||
info.value = data["info"];
|
||||
option.value = data["option"];
|
||||
isvote.value = data["isvote"];
|
||||
seo.value = data.seo;
|
||||
} else {
|
||||
await detailsHttp({ uniqid: id }).then((res) => {
|
||||
if (res.code == 200) {
|
||||
let data = res.data;
|
||||
info.value = data["info"];
|
||||
option.value = data["option"];
|
||||
isvote.value = data["isvote"];
|
||||
seo.value = data.seo;
|
||||
$cache.set(cacheKey, data, 5);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user