客服:使用轮训模拟 websocket

pull/56/head
puhui999 2024-07-02 17:10:17 +08:00
parent a4a8548b5a
commit 166030e3b8
2 changed files with 20 additions and 2 deletions

View File

@ -133,7 +133,7 @@
</template>
<script setup>
import { nextTick, reactive, ref, unref } from 'vue';
import { nextTick, onMounted,onBeforeUnmount, reactive, ref, unref } from 'vue';
import { onLoad } from '@dcloudio/uni-app';
import sheep from '@/sheep';
import KeFuApi from '@/sheep/api/promotion/kefu';
@ -174,6 +174,23 @@
scrollData.value[pageNo ? pageNo - 1 : currentShowPage.value - 1] = data.list;
};
defineExpose({ getMessageList });
const poller = ref(null) // TODO puhui999: websocket
onMounted(() => {
// TODO puhui999:
if (!poller.value) {
poller.value = setInterval(() => {
getMessageList(1)
}, 1000)
}
})
// TODO puhui999:
onBeforeUnmount(() => {
if (!poller.value) {
return
}
clearInterval(poller.value)
})
const scrollTop = ref(0); //
const currentTop = ref(0);
const showGoBottom = ref(false);

View File

@ -166,7 +166,8 @@
//======================= end =======================
onLoad(async () => {
socketInit({}, () => {
socketInit({}, (res) => {
console.log(res);
//
});
await nextTick()