优化
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const components_VerifyLogin = require("../VerifyLogin.js");
|
||||
const components_goEasyTool_tool = require("../goEasyTool/tool.js");
|
||||
if (!Math) {
|
||||
NewAddedPk();
|
||||
}
|
||||
@@ -9,45 +10,18 @@ const _sfc_main = {
|
||||
__name: "tabBar",
|
||||
props: {
|
||||
tabIndex: Number
|
||||
//当前tab索引
|
||||
},
|
||||
emits: ["publishSucces"],
|
||||
setup(__props, { emit: __emit }) {
|
||||
require.async("../../TUIKit/components/TUIConversation/entry.js");
|
||||
setup(__props) {
|
||||
const instance = common_vendor.getCurrentInstance();
|
||||
const $goeasy = instance.appContext.config.globalProperties.$goeasy;
|
||||
const Unread = common_vendor.ref(0);
|
||||
var im = $goeasy.im;
|
||||
function onConversationsUpdated(conversations) {
|
||||
common_vendor.index.__f__("log", "at components/tabBar/tabBar.vue:47", "监听会话列表", conversations);
|
||||
Unread.value = conversations.unreadTotal;
|
||||
}
|
||||
let showMiddleButton = common_vendor.ref(false);
|
||||
const conversationList = common_vendor.ref([]);
|
||||
let Unread = common_vendor.ref(0);
|
||||
common_vendor.onMounted(() => {
|
||||
common_vendor.Jt.watch(common_vendor.o.CONV, {
|
||||
conversationList: onConversationListUpdated
|
||||
});
|
||||
});
|
||||
common_vendor.onUnmounted(() => {
|
||||
common_vendor.Jt.unwatch(common_vendor.o.CONV, {
|
||||
conversationList: onConversationListUpdated
|
||||
});
|
||||
});
|
||||
function onConversationListUpdated(list) {
|
||||
conversationList.value = list;
|
||||
Unread.value = calculateUnreadCount(list);
|
||||
}
|
||||
const emit = __emit;
|
||||
function publishSuccesss() {
|
||||
emit("publishSucces");
|
||||
}
|
||||
function calculateUnreadCount(arr) {
|
||||
let total = 0;
|
||||
for (const item of arr) {
|
||||
if (!item.hasOwnProperty("unreadCount")) {
|
||||
return null;
|
||||
}
|
||||
const count = item.unreadCount;
|
||||
if (typeof count !== "number" || !Number.isFinite(count)) {
|
||||
return null;
|
||||
}
|
||||
total += count;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
let tabList = common_vendor.reactive([
|
||||
{
|
||||
iconPath: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Pk.png",
|
||||
@@ -73,7 +47,9 @@ const _sfc_main = {
|
||||
{
|
||||
iconPath: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Message.png",
|
||||
selectedIconPath: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Messageclick.png",
|
||||
text: "消息"
|
||||
text: "消息",
|
||||
pagePath: "/pages/index/index",
|
||||
middleClass: ""
|
||||
},
|
||||
{
|
||||
iconPath: "https://vv-1317974657.cos.ap-shanghai.myqcloud.com/util/Mine.png",
|
||||
@@ -85,6 +61,12 @@ const _sfc_main = {
|
||||
]);
|
||||
common_vendor.onMounted(() => {
|
||||
setTabBar();
|
||||
setTimeout(() => {
|
||||
components_goEasyTool_tool.getConversationList($goeasy).then((conversations) => {
|
||||
Unread.value = conversations.unreadTotal;
|
||||
});
|
||||
im.on(common_vendor.jo.IM_EVENT.CONVERSATIONS_UPDATED, onConversationsUpdated);
|
||||
}, 1e3);
|
||||
});
|
||||
common_vendor.index.getSystemInfo({
|
||||
success: function(res) {
|
||||
@@ -108,16 +90,7 @@ const _sfc_main = {
|
||||
return false;
|
||||
};
|
||||
function handlePush(item, index) {
|
||||
if (index === 3) {
|
||||
components_VerifyLogin.VerifyLogin().then((res) => {
|
||||
if (res) {
|
||||
common_vendor.index.redirectTo({
|
||||
url: "/TUIKit/components/TUIConversation/index",
|
||||
animationType: "none"
|
||||
});
|
||||
}
|
||||
});
|
||||
} else if (index === 2) {
|
||||
if (index === 2) {
|
||||
components_VerifyLogin.VerifyLogin().then((res) => {
|
||||
if (res) {
|
||||
openPopupQuantity();
|
||||
@@ -144,23 +117,23 @@ const _sfc_main = {
|
||||
a: common_vendor.f(common_vendor.unref(tabList), (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: __props.tabIndex == index ? item.selectedIconPath : item.iconPath,
|
||||
b: index === 3 && common_vendor.unref(Unread) > 0
|
||||
}, index === 3 && common_vendor.unref(Unread) > 0 ? {
|
||||
c: common_vendor.t(common_vendor.unref(Unread) > 99 ? "99+" : common_vendor.unref(Unread))
|
||||
b: index === 3 && Unread.value > 0
|
||||
}, index === 3 && Unread.value > 0 ? {
|
||||
c: common_vendor.t(Unread.value > 99 ? "99+" : Unread.value)
|
||||
} : {}, {
|
||||
d: common_vendor.t(item.text),
|
||||
e: __props.tabIndex == index ? "#1DD2F9" : "#A7A3A3",
|
||||
f: common_vendor.n("list-item flex flex-column flex-middle " + item.middleClass),
|
||||
g: common_vendor.o$1(($event) => handlePush(item, index), index),
|
||||
g: common_vendor.o(($event) => handlePush(item, index), index),
|
||||
h: index
|
||||
});
|
||||
}),
|
||||
b: common_vendor.n(common_vendor.unref(showMiddleButton) === true ? "tab-list-middle" : "tab-list-default"),
|
||||
c: common_vendor.o$1(disabledScroll),
|
||||
c: common_vendor.o(disabledScroll),
|
||||
d: common_vendor.sr(createModule, "c497a889-0", {
|
||||
"k": "createModule"
|
||||
}),
|
||||
e: common_vendor.o$1(publishSuccesss)
|
||||
e: common_vendor.o(_ctx.publishSuccesss)
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user