Browse Source

chat页面data接口根据环境判断接口。

根据url地址上的参数判断是否充值回归,并且展示弹窗,使用缓存rechargeFlag来判断是否展示过。
milestone-20250820-金币兑换Token
no99 4 days ago
parent
commit
5b0c0353e2
  1. 5
      src/views/AIchat.vue
  2. 90
      src/views/homePage.vue

5
src/views/AIchat.vue

@ -1261,8 +1261,9 @@ watch(
const env = import.meta.env.VITE_ENV; const env = import.meta.env.VITE_ENV;
const result20 = await dataListAPI({ const result20 = await dataListAPI({
token: token:
// "8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0",
"8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA",
env == "development" || env == "test"
? "8Csj5VVX1UbIb4C3oxrnbZi0+fEeMx8pywnIlrmTm45Cb/EllzWACLto9J9+fCFsfdgBOvKvyY94FvqlvM0"
: "8nkj4QBV1RPIb4CzoRTnbZi0+fEeMx8pywnIlrmTxdwROKkuwWqAWu9orpkpeXVqL98DPfeonNYpHv+mucA",
market: codeData.value.market, market: codeData.value.market,
code: codeData.value.code, code: codeData.value.code,
language: "cn", //t.value.suoxie, language: "cn", //t.value.suoxie,

90
src/views/homePage.vue

@ -373,9 +373,9 @@ const aiEmotionScrollTimer = ref(null); // 滚动检测定时器
// //
const getCurrentScrollContainer = () => { const getCurrentScrollContainer = () => {
if (activeTab.value === 'AIchat') {
if (activeTab.value === "AIchat") {
return tabContentAIchat.value; return tabContentAIchat.value;
} else if (activeTab.value === 'AiEmotion') {
} else if (activeTab.value === "AiEmotion") {
return tabContentAiEmotion.value; return tabContentAiEmotion.value;
} }
return null; return null;
@ -406,7 +406,11 @@ const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 300, {
// AiEmotion // AiEmotion
const debouncedAiEmotionScrollToBottom = _.debounce(() => { const debouncedAiEmotionScrollToBottom = _.debounce(() => {
if (activeTab.value === 'AiEmotion' && isAiEmotionAutoScrollEnabled.value && !isAiEmotionUserScrolling.value) {
if (
activeTab.value === "AiEmotion" &&
isAiEmotionAutoScrollEnabled.value &&
!isAiEmotionUserScrolling.value
) {
const container = tabContentAiEmotion.value; const container = tabContentAiEmotion.value;
if (container) { if (container) {
container.scrollTop = container.scrollHeight - container.offsetHeight; container.scrollTop = container.scrollHeight - container.offsetHeight;
@ -418,21 +422,21 @@ const debouncedAiEmotionScrollToBottom = _.debounce(() => {
const startAiEmotionHeightObserver = () => { const startAiEmotionHeightObserver = () => {
// //
stopAiEmotionHeightObserver(); stopAiEmotionHeightObserver();
isAiEmotionAutoScrollEnabled.value = true; isAiEmotionAutoScrollEnabled.value = true;
// ResizeObserver // ResizeObserver
aiEmotionHeightObserver.value = new ResizeObserver((entries) => { aiEmotionHeightObserver.value = new ResizeObserver((entries) => {
if (isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') {
if (isAiEmotionAutoScrollEnabled.value && activeTab.value === "AiEmotion") {
debouncedAiEmotionScrollToBottom(); debouncedAiEmotionScrollToBottom();
} }
}); });
// document.body // document.body
if (document.body) { if (document.body) {
aiEmotionHeightObserver.value.observe(document.body); aiEmotionHeightObserver.value.observe(document.body);
} }
// MutationObserverDOM // MutationObserverDOM
const mutationObserver = new MutationObserver((mutations) => { const mutationObserver = new MutationObserver((mutations) => {
let shouldScroll = false; let shouldScroll = false;
@ -453,12 +457,16 @@ const startAiEmotionHeightObserver = () => {
} }
} }
}); });
if (shouldScroll && isAiEmotionAutoScrollEnabled.value && activeTab.value === 'AiEmotion') {
if (
shouldScroll &&
isAiEmotionAutoScrollEnabled.value &&
activeTab.value === "AiEmotion"
) {
debouncedAiEmotionScrollToBottom(); debouncedAiEmotionScrollToBottom();
} }
}); });
// AiEmotionDOM // AiEmotionDOM
const aiEmotionContainer = tabContentAiEmotion.value; const aiEmotionContainer = tabContentAiEmotion.value;
if (aiEmotionContainer) { if (aiEmotionContainer) {
@ -469,17 +477,19 @@ const startAiEmotionHeightObserver = () => {
characterData: true, characterData: true,
}); });
} }
// mutationObserver便 // mutationObserver便
aiEmotionHeightObserver.value.mutationObserver = mutationObserver; aiEmotionHeightObserver.value.mutationObserver = mutationObserver;
// AiEmotion // AiEmotion
if (aiEmotionContainer) { if (aiEmotionContainer) {
aiEmotionContainer.addEventListener('scroll', handleAiEmotionUserScroll, { passive: true });
aiEmotionContainer.addEventListener("scroll", handleAiEmotionUserScroll, {
passive: true,
});
// 便 // 便
aiEmotionHeightObserver.value.scrollListener = handleAiEmotionUserScroll; aiEmotionHeightObserver.value.scrollListener = handleAiEmotionUserScroll;
} }
console.log("AiEmotion页面高度监听器已启动"); console.log("AiEmotion页面高度监听器已启动");
}; };
@ -487,12 +497,12 @@ const startAiEmotionHeightObserver = () => {
const handleAiEmotionUserScroll = () => { const handleAiEmotionUserScroll = () => {
// //
isAiEmotionUserScrolling.value = true; isAiEmotionUserScrolling.value = true;
// //
if (aiEmotionScrollTimer.value) { if (aiEmotionScrollTimer.value) {
clearTimeout(aiEmotionScrollTimer.value); clearTimeout(aiEmotionScrollTimer.value);
} }
// 2 // 2
// aiEmotionScrollTimer.value = setTimeout(() => { // aiEmotionScrollTimer.value = setTimeout(() => {
// isAiEmotionUserScrolling.value = false; // isAiEmotionUserScrolling.value = false;
@ -502,7 +512,7 @@ const handleAiEmotionUserScroll = () => {
// AiEmotion // AiEmotion
const handleAiEmotionScrollToBottom = () => { const handleAiEmotionScrollToBottom = () => {
if (activeTab.value === 'AiEmotion') {
if (activeTab.value === "AiEmotion") {
const container = tabContentAiEmotion.value; const container = tabContentAiEmotion.value;
if (container) { if (container) {
// 使nextTickDOM // 使nextTickDOM
@ -518,32 +528,38 @@ const handleAiEmotionScrollToBottom = () => {
const stopAiEmotionHeightObserver = () => { const stopAiEmotionHeightObserver = () => {
isAiEmotionAutoScrollEnabled.value = false; isAiEmotionAutoScrollEnabled.value = false;
isAiEmotionUserScrolling.value = false; isAiEmotionUserScrolling.value = false;
// //
if (aiEmotionScrollTimer.value) { if (aiEmotionScrollTimer.value) {
clearTimeout(aiEmotionScrollTimer.value); clearTimeout(aiEmotionScrollTimer.value);
aiEmotionScrollTimer.value = null; aiEmotionScrollTimer.value = null;
} }
if (aiEmotionHeightObserver.value) { if (aiEmotionHeightObserver.value) {
// ResizeObserver // ResizeObserver
aiEmotionHeightObserver.value.disconnect(); aiEmotionHeightObserver.value.disconnect();
// MutationObserver // MutationObserver
if (aiEmotionHeightObserver.value.mutationObserver) { if (aiEmotionHeightObserver.value.mutationObserver) {
aiEmotionHeightObserver.value.mutationObserver.disconnect(); aiEmotionHeightObserver.value.mutationObserver.disconnect();
aiEmotionHeightObserver.value.mutationObserver = null; aiEmotionHeightObserver.value.mutationObserver = null;
} }
// //
if (aiEmotionHeightObserver.value.scrollListener && tabContentAiEmotion.value) {
tabContentAiEmotion.value.removeEventListener('scroll', aiEmotionHeightObserver.value.scrollListener);
if (
aiEmotionHeightObserver.value.scrollListener &&
tabContentAiEmotion.value
) {
tabContentAiEmotion.value.removeEventListener(
"scroll",
aiEmotionHeightObserver.value.scrollListener
);
aiEmotionHeightObserver.value.scrollListener = null; aiEmotionHeightObserver.value.scrollListener = null;
} }
aiEmotionHeightObserver.value = null; aiEmotionHeightObserver.value = null;
} }
console.log("AiEmotion页面高度监听器已停止"); console.log("AiEmotion页面高度监听器已停止");
}; };
@ -655,7 +671,7 @@ setTimeout(() => {
const heightListener = () => { const heightListener = () => {
const tabContainer = getCurrentScrollContainer(); const tabContainer = getCurrentScrollContainer();
if (!tabContainer) return; if (!tabContainer) return;
let befortop = 0; let befortop = 0;
const scrollHandler = () => { const scrollHandler = () => {
@ -807,7 +823,8 @@ const touchmoveHandler = (e) => {
} }
// //
const currentContainer = getCurrentScrollContainer(); const currentContainer = getCurrentScrollContainer();
const isScrollableArea = currentContainer && currentContainer.contains(e.target);
const isScrollableArea =
currentContainer && currentContainer.contains(e.target);
// //
if (!isScrollableArea) { if (!isScrollableArea) {
@ -925,6 +942,8 @@ const changeToken = () => {
}; };
const goRecharge = () => { const goRecharge = () => {
sessionStorage.setItem("rechargeFlag", "1");
if (isMobile.value) { if (isMobile.value) {
console.log("用户是移动端"); console.log("用户是移动端");
} else { } else {
@ -953,9 +972,7 @@ const goChange = () => {
setTimeout(() => { setTimeout(() => {
changeSuccessDialogVisible.value = false; changeSuccessDialogVisible.value = false;
}, 3000); }, 3000);
}; };
// 8.18Token end // 8.18Token end
onMounted(async () => { onMounted(async () => {
@ -984,12 +1001,12 @@ onMounted(async () => {
// //
window.addEventListener("resize", throttledJudgeDevice); window.addEventListener("resize", throttledJudgeDevice);
if (getQueryVariable("successType") == "success") {
if (
sessionStorage.getItem("rechargeFlag") == "1" &&
getQueryVariable("successType") == "success"
) {
dialogVisible.value = true; dialogVisible.value = true;
window.parent.location.href = window.parent.location.href.replace(
"successType=success",
""
);
sessionStorage.setItem("rechargeFlag", "0");
} }
}); });
@ -1101,7 +1118,6 @@ onUnmounted(() => {
<div class="pc-count-number">{{ UserCount }}</div> <div class="pc-count-number">{{ UserCount }}</div>
</div> </div>
<div class="pc-clickGetCount">点击获取Token</div> <div class="pc-clickGetCount">点击获取Token</div>
</div> </div>
<div class="pc-backToHomeBtn" @click="backToHome()"> <div class="pc-backToHomeBtn" @click="backToHome()">
<img <img
@ -1133,7 +1149,7 @@ onUnmounted(() => {
@enableInput="enableInput" @enableInput="enableInput"
/> />
</div> </div>
<!-- AiEmotion页面的独立滚动容器 --> <!-- AiEmotion页面的独立滚动容器 -->
<div <div
v-show="activeTab === 'AiEmotion'" v-show="activeTab === 'AiEmotion'"

Loading…
Cancel
Save