|
@ -134,7 +134,7 @@ import Announcement from "./Announcement.vue"; |
|
|
// 新增一个变量来控制是否显示公告页面 |
|
|
// 新增一个变量来控制是否显示公告页面 |
|
|
const isAnnouncementVisible = ref(false); |
|
|
const isAnnouncementVisible = ref(false); |
|
|
|
|
|
|
|
|
const showAnnouncement = () => { |
|
|
|
|
|
|
|
|
const showAnnouncement = async () => { |
|
|
console.log("打开公告"); |
|
|
console.log("打开公告"); |
|
|
isScrolling.value = false; //回复滚动到底部方法 |
|
|
isScrolling.value = false; //回复滚动到底部方法 |
|
|
setActiveTab('', -1); // 清空当前选中状态 |
|
|
setActiveTab('', -1); // 清空当前选中状态 |
|
@ -159,11 +159,11 @@ const tabContent = ref(null); |
|
|
const isScrolling = ref(false); //判断用户是否在滚动 |
|
|
const isScrolling = ref(false); //判断用户是否在滚动 |
|
|
|
|
|
|
|
|
const smoothScrollToBottom = async () => { |
|
|
const smoothScrollToBottom = async () => { |
|
|
console.log('调用滚动到底部的方法') |
|
|
|
|
|
|
|
|
// console.log('调用滚动到底部的方法') |
|
|
// await nextTick(); |
|
|
// await nextTick(); |
|
|
const container = tabContent.value; |
|
|
const container = tabContent.value; |
|
|
console.log(container, 'container') |
|
|
|
|
|
console.log(isScrolling.value, 'isScrolling.value') |
|
|
|
|
|
|
|
|
// console.log(container, 'container') |
|
|
|
|
|
// console.log(isScrolling.value, 'isScrolling.value') |
|
|
if (!container) return; |
|
|
if (!container) return; |
|
|
|
|
|
|
|
|
await nextTick(); // 确保在DOM更新后执行 |
|
|
await nextTick(); // 确保在DOM更新后执行 |
|
@ -173,7 +173,7 @@ const smoothScrollToBottom = async () => { |
|
|
// container.scrollTop = container.scrollHeight; |
|
|
// container.scrollTop = container.scrollHeight; |
|
|
// container.scrollTop = container.offsetHeight; |
|
|
// container.scrollTop = container.offsetHeight; |
|
|
// container.scrollTop = container.scrollHeight + container.offsetHeight; |
|
|
// container.scrollTop = container.scrollHeight + container.offsetHeight; |
|
|
console.log(container.scrollHeight, container.offsetHeight,container.scrollHeight-container.offsetHeight, container.scrollTop, "总长度", "可视长度", "位置") |
|
|
|
|
|
|
|
|
// console.log(container.scrollHeight, container.offsetHeight, container.scrollHeight - container.offsetHeight, container.scrollTop, "总长度", "可视长度", "位置") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
@ -183,7 +183,7 @@ const throttledSmoothScrollToBottom = _.throttle(smoothScrollToBottom, 500, { tr |
|
|
watch( |
|
|
watch( |
|
|
() => chatStore.messages, |
|
|
() => chatStore.messages, |
|
|
() => { |
|
|
() => { |
|
|
console.log('messages变化了') |
|
|
|
|
|
|
|
|
// console.log('messages变化了') |
|
|
throttledSmoothScrollToBottom(); |
|
|
throttledSmoothScrollToBottom(); |
|
|
// setTimeout(throttledSmoothScrollToBottom, 100); |
|
|
// setTimeout(throttledSmoothScrollToBottom, 100); |
|
|
}, |
|
|
}, |
|
@ -194,7 +194,7 @@ watch( |
|
|
watch( |
|
|
watch( |
|
|
activeTab, |
|
|
activeTab, |
|
|
async () => { |
|
|
async () => { |
|
|
console.log('activeTab变化了', activeTab.value) |
|
|
|
|
|
|
|
|
// console.log('activeTab变化了', activeTab.value) |
|
|
isScrolling.value = false; //回复滚动到底部方法 |
|
|
isScrolling.value = false; //回复滚动到底部方法 |
|
|
await nextTick(); // 等待DOM更新 |
|
|
await nextTick(); // 等待DOM更新 |
|
|
throttledSmoothScrollToBottom(); |
|
|
throttledSmoothScrollToBottom(); |
|
@ -203,16 +203,20 @@ watch( |
|
|
{ deep: true, immediate: true } |
|
|
{ deep: true, immediate: true } |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在setTimeout中延迟执行 |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
fnGetToken() |
|
|
|
|
|
}, 800) |
|
|
|
|
|
|
|
|
|
|
|
// 获取token的核心函数 |
|
|
// 获取token的核心函数 |
|
|
const fnGetToken = () => { |
|
|
const fnGetToken = () => { |
|
|
|
|
|
// console.log('进入fnGetToken') |
|
|
window.JWready = (ress) => { |
|
|
window.JWready = (ress) => { |
|
|
|
|
|
// console.log('进入JWready') |
|
|
|
|
|
try { |
|
|
|
|
|
ress = JSON.parse(ress) |
|
|
|
|
|
// console.log(ress, 'ress') |
|
|
|
|
|
} catch (error) { |
|
|
|
|
|
console.log(error, 'fnGetToken error') |
|
|
|
|
|
} //platform为5是app端 |
|
|
|
|
|
// platform.value = ress.data.platform |
|
|
// 处理平台判断 |
|
|
// 处理平台判断 |
|
|
|
|
|
console.log(ress.data.platform, 'ress.data.platform') |
|
|
if (!ress.data.platform) { |
|
|
if (!ress.data.platform) { |
|
|
// 非App环境通过URL参数获取 |
|
|
// 非App环境通过URL参数获取 |
|
|
localStorage.setItem('localToken', decodeURIComponent(String(getQueryVariable('token')))) |
|
|
localStorage.setItem('localToken', decodeURIComponent(String(getQueryVariable('token')))) |
|
@ -233,10 +237,16 @@ const fnGetToken = () => { |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
// console.log('出来了') |
|
|
// 触发App桥接 |
|
|
// 触发App桥接 |
|
|
useAppBridge().packageFun('JWwebReady', () => { }, 5, {}) |
|
|
useAppBridge().packageFun('JWwebReady', () => { }, 5, {}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 在setTimeout中延迟执行 |
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
fnGetToken() |
|
|
|
|
|
}, 800) |
|
|
|
|
|
|
|
|
// const tabContainer = tabContent.value |
|
|
// const tabContainer = tabContent.value |
|
|
// let befortop = 0 |
|
|
// let befortop = 0 |
|
|
// tabContainer.addEventListener('scroll', () => { |
|
|
// tabContainer.addEventListener('scroll', () => { |
|
@ -263,23 +273,23 @@ const heightListener = () => { |
|
|
|
|
|
|
|
|
if (activeTab.value === 'AIchat') { |
|
|
if (activeTab.value === 'AIchat') { |
|
|
if (aftertop - befortop > 0) { |
|
|
if (aftertop - befortop > 0) { |
|
|
console.log('向下滚动'); |
|
|
|
|
|
|
|
|
// console.log('向下滚动'); |
|
|
isScrolling.value = true; |
|
|
isScrolling.value = true; |
|
|
} else { |
|
|
} else { |
|
|
console.log('向上滚动'); |
|
|
|
|
|
|
|
|
// console.log('向上滚动'); |
|
|
isScrolling.value = true; |
|
|
isScrolling.value = true; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 添加底部状态检测 |
|
|
// 添加底部状态检测 |
|
|
if (isBottom) { |
|
|
if (isBottom) { |
|
|
console.log('滚动到底部'); |
|
|
|
|
|
|
|
|
// console.log('滚动到底部'); |
|
|
isScrolling.value = false; |
|
|
isScrolling.value = false; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
befortop = aftertop; |
|
|
befortop = aftertop; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
console.log(isScrolling.value, 'isScrolling.value') |
|
|
|
|
|
|
|
|
// console.log(isScrolling.value, 'isScrolling.value') |
|
|
|
|
|
|
|
|
tabContainer.addEventListener('scroll', scrollHandler); |
|
|
tabContainer.addEventListener('scroll', scrollHandler); |
|
|
}; |
|
|
}; |
|
@ -287,6 +297,12 @@ const heightListener = () => { |
|
|
const throttledHeightListener = _.throttle(heightListener, 500, { trailing: false }); |
|
|
const throttledHeightListener = _.throttle(heightListener, 500, { trailing: false }); |
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
onMounted(async () => { |
|
|
|
|
|
const isPhone = |
|
|
|
|
|
/phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone/i.test( |
|
|
|
|
|
navigator.userAgent |
|
|
|
|
|
) |
|
|
|
|
|
!isPhone && |
|
|
|
|
|
localStorage.setItem('localToken', decodeURIComponent(String(getQueryVariable('token')))) |
|
|
setHeight(document.getElementById("testId")); // 给父组件发送窗口高度 |
|
|
setHeight(document.getElementById("testId")); // 给父组件发送窗口高度 |
|
|
await chatStore.getUserCount(); |
|
|
await chatStore.getUserCount(); |
|
|
throttledSmoothScrollToBottom(); |
|
|
throttledSmoothScrollToBottom(); |
|
|