cyl/master-0822
zsk 3 months ago
parent 7dd8471bb7
commit 2cd0bb91c0

@ -21,7 +21,7 @@ export default {
// //
uni.addInterceptor("navigateTo", { uni.addInterceptor("navigateTo", {
invoke(args) { invoke(args) {
console.log("navigateTo 跳转前", args); // console.log("navigateTo ", args);
that.G.watchUserPage(args.url); that.G.watchUserPage(args.url);
}, },
}); });
@ -83,7 +83,7 @@ export default {
} }
uni.$on("isGlogin", function (data) { uni.$on("isGlogin", function (data) {
console.log("app.vue 接收", data); // console.log("app.vue ", data);
if (uni.getStorageSync("apply-uid")) { if (uni.getStorageSync("apply-uid")) {
that.initWyyx(); that.initWyyx();
} }
@ -91,7 +91,7 @@ export default {
// //
if (uni.getStorageSync("apply-token")) { if (uni.getStorageSync("apply-token")) {
console.log("app.vue 检查IM连接状态"); // console.log("app.vue IM");
that.checkAndReconnectIM(); that.checkAndReconnectIM();
} }
}, },
@ -102,9 +102,9 @@ export default {
// //
if (uni.$UIKitNIM && uni.$UIKitNIM.V2NIMLoginService) { if (uni.$UIKitNIM && uni.$UIKitNIM.V2NIMLoginService) {
uni.$UIKitNIM.V2NIMLoginService.ping().then(() => { uni.$UIKitNIM.V2NIMLoginService.ping().then(() => {
console.log("后台心跳发送成功"); // console.log("");
}).catch(err => { }).catch(err => {
console.error("后台心跳发送失败,准备重连", err); // console.error("", err);
this.reconnectIM(); this.reconnectIM();
}); });
} }
@ -130,7 +130,7 @@ export default {
setTimeout(() => { setTimeout(() => {
if (uni.$UIKitNIM && uni.$UIKitStore) { if (uni.$UIKitNIM && uni.$UIKitStore) {
const connectStatus = uni.$UIKitStore.connectStore.connectStatus; const connectStatus = uni.$UIKitStore.connectStore.connectStatus;
console.log('当前IM连接状态:', connectStatus); // console.log('IM:', connectStatus);
// //
// 0: // 0:
@ -138,11 +138,11 @@ export default {
// 2: // 2:
// 3: // 3:
if (connectStatus !== 2 && connectStatus !== 3) { if (connectStatus !== 2 && connectStatus !== 3) {
console.log("IM连接已断开尝试重连..."); // console.log("IM...");
that.reconnectIM(); that.reconnectIM();
} }
} else if (uni.getStorageSync("apply-token") && uni.getStorageSync("apply-uid")) { } else if (uni.getStorageSync("apply-token") && uni.getStorageSync("apply-uid")) {
console.log("IM SDK未初始化重新初始化..."); // console.log("IM SDK...");
that.initWyyx(); that.initWyyx();
} }
}, 1000); }, 1000);
@ -154,14 +154,14 @@ export default {
// //
if (this.globalData.reconnectTimer) { if (this.globalData.reconnectTimer) {
console.log("正在重连中,无需重复操作"); // console.log("");
return; return;
} }
// //
const attemptReconnect = () => { const attemptReconnect = () => {
if (!uni.getStorageSync("apply-token") || !uni.getStorageSync("apply-uid")) { if (!uni.getStorageSync("apply-token") || !uni.getStorageSync("apply-uid")) {
console.log("用户未登录,停止重连"); // console.log("");
clearInterval(that.globalData.reconnectTimer); clearInterval(that.globalData.reconnectTimer);
that.globalData.reconnectTimer = null; that.globalData.reconnectTimer = null;
return; return;
@ -175,15 +175,15 @@ export default {
console.log(`尝试重连IM (account: ${account})`); console.log(`尝试重连IM (account: ${account})`);
uni.$UIKitNIM.V2NIMLoginService.login(account, token) uni.$UIKitNIM.V2NIMLoginService.login(account, token)
.then(() => { .then(() => {
console.log("IM重连成功"); // console.log("IM");
clearInterval(that.globalData.reconnectTimer); clearInterval(that.globalData.reconnectTimer);
that.globalData.reconnectTimer = null; that.globalData.reconnectTimer = null;
}) })
.catch((error) => { .catch((error) => {
console.error("IM重连失败将再次尝试", error); // console.error("IM", error);
}); });
} else { } else {
console.log("重连信息不全重新初始化IM"); // console.log("IM");
that.initWyyx(); that.initWyyx();
} }
} else { } else {
@ -200,7 +200,7 @@ export default {
this.globalData.reconnectTimer = setInterval(() => { this.globalData.reconnectTimer = setInterval(() => {
reconnectAttempts++; reconnectAttempts++;
if (reconnectAttempts >= 10) { if (reconnectAttempts >= 10) {
console.log("重连尝试次数已达上限,停止重连"); // console.log("");
clearInterval(that.globalData.reconnectTimer); clearInterval(that.globalData.reconnectTimer);
that.globalData.reconnectTimer = null; that.globalData.reconnectTimer = null;
return; return;
@ -385,7 +385,7 @@ export default {
// IM // IM
nim.V2NIMLoginService.login(opts.account, opts.token) nim.V2NIMLoginService.login(opts.account, opts.token)
.then(() => { .then(() => {
console.log("IM登录成功"); // console.log("IM");
// //
if (that.globalData.reconnectTimer) { if (that.globalData.reconnectTimer) {
clearInterval(that.globalData.reconnectTimer); clearInterval(that.globalData.reconnectTimer);
@ -393,18 +393,18 @@ export default {
} }
}) })
.catch((error) => { .catch((error) => {
console.error("IM登录失败", error); // console.error("IM", error);
// //
that.reconnectIM(); that.reconnectIM();
}); });
// //
nim.V2NIMConversationService.on("onConversationChanged", function (conversationList: V2NIMConversation[]) { nim.V2NIMConversationService.on("onConversationChanged", function (conversationList: V2NIMConversation[]) {
console.log("初始化监听会话:", conversationList); // console.log(":", conversationList);
let unreadConversations = conversationList.filter((item) => { let unreadConversations = conversationList.filter((item) => {
return Number(item.unreadCount) > 0; return Number(item.unreadCount) > 0;
}); });
console.log("未读会话数量:", unreadConversations.length); // console.log(":", unreadConversations.length);
if (unreadConversations.length > 0) { if (unreadConversations.length > 0) {
that.playAudio(); that.playAudio();
} }

@ -2,8 +2,9 @@
<div class="msg-list-wrapper" @click="handleTapMessageList" :style="{'height':msgKeyHeight}"> <div class="msg-list-wrapper" @click="handleTapMessageList" :style="{'height':msgKeyHeight}">
<scroll-view id="message-scroll-list" scroll-y="true" @scroll="handleScroll" @click.stop="nothing" <scroll-view id="message-scroll-list" scroll-y="true" @scroll="handleScroll" @click.stop="nothing"
:scroll-top="scrollTop" class="message-scroll-list g_flex_column_end" style="overflow-x: hidden;"> :scroll-top="scrollTop" class="message-scroll-list g_flex_column_end" style="overflow-x: hidden;" :style="{'height':msgKeyHeight}">
<view class="g_clear_scroll" style="overflow-y: auto;overflow-x: hidden;" :style="paddingBottom"> <view class="g_clear_scroll" style="overflow-y: auto;overflow-x: hidden;">
<!-- :style="paddingBottom" -->
<!-- <div v-show="!noMore" @click.stop="onLoadMore" class="view-more-text"> <!-- <div v-show="!noMore" @click.stop="onLoadMore" class="view-more-text">
{{ t("viewMoreText") }} {{ t("viewMoreText") }}
底部往上推paddingBottom + {{paddingBottom}} 底部往上推paddingBottom + {{paddingBottom}}
@ -11,6 +12,7 @@
// msgKeyHeight + {{msgKeyHeight}} // msgKeyHeight + {{msgKeyHeight}}
{{rell}} {{rell}}
</div> --> </div> -->
<view class="msg-tip" v-show="noMore"></view> <view class="msg-tip" v-show="noMore"></view>
<div v-for="(item, index) in finalMsgs" :key="item.renderKey"> <div v-for="(item, index) in finalMsgs" :key="item.renderKey">
<MessageItem :msg="item" :index="index" :key="item.renderKey" :reply-msgs-map="replyMsgsMap" <MessageItem :msg="item" :index="index" :key="item.renderKey" :reply-msgs-map="replyMsgsMap"
@ -18,6 +20,12 @@
<!-- {{screenHeight1}} <!-- {{screenHeight1}}
顶部聊天区域高度传过来{{msgKeyHeight}} 本页面{{screenHeight1}} {{rell}}--> 顶部聊天区域高度传过来{{msgKeyHeight}} 本页面{{screenHeight1}} {{rell}}-->
</div> </div>
<!-- 底部往上推paddingBottom + {{paddingBottom}}
底部往上推paddingBottom + {{paddingBottom}}
聊天内容高度msgKeyHeight + {{msgKeyHeight}}
-->
</view> </view>
</scroll-view> </scroll-view>
</div> </div>
@ -136,7 +144,7 @@
onMounted(() => { onMounted(() => {
// {{keyHeight}} {{writeStyle}}{{screenHeight}}{{msgKeyHeight}}
uni.$on('msgKeyHeight', (res) => { uni.$on('msgKeyHeight', (res) => {
mlwHeight.value = res; mlwHeight.value = res;

Loading…
Cancel
Save