Compare commits

..

No commits in common. "main" and "dev-260402" have entirely different histories.

7 changed files with 65 additions and 78 deletions

View File

@ -1,5 +1,5 @@
MP_API_BASE_URL=https://ykt.youcan365.com
MP_CACHE_PREFIX=production
MP_WX_APP_ID=wx6ee11733526b4f04
MP_TIM_SDK_APP_ID=1600136080
MP_TIM_SDK_APP_ID=1600123876
MP_CORP_ID=wpLgjyawAA8N0gWmXgyJq8wpjGcOT7fg

View File

@ -8,7 +8,7 @@ export default {
console.log("App Launch: ");
// openId IM
// await this.initIMOnLaunch();
await this.initIMOnLaunch();
},
onShow: function () {
const db = dbStore();

View File

@ -190,7 +190,6 @@ async function init() {
await getCustomer();
} else {
const res = await getArchives();
console.log('res:', res)
if (res.length > 0) {
visible.value = true;
}
@ -204,9 +203,14 @@ async function init() {
}
async function getArchives() {
const res = await api('getUnbindMiniAppCustomers', { corpId: corpId.value, mobile: account.value?.mobile || '' });
customers.value = res && Array.isArray(res.data) ? res.data : [];
corpName.value = res && res.corpName ? res.corpName : '';
const res = await api('getUnbindMiniAppCustomers', { corpId: corpId.value, mobile: account.value.mobile });
if (res && res.success) {
corpName.value = res.corpName;
customers.value = Array.isArray(res.data) ? res.data : [];
} else {
toast(res?.message || '查询档案信息失败');
return Promise.reject()
}
return customers.value
}

View File

@ -45,7 +45,7 @@ import pageLoading from "./loading.vue";
// const { useLoad, useShow } = useGuard();
const { account } = storeToRefs(useAccount());
const { login, getTeams } = useAccount();
const { login } = useAccount();
const team = ref(null);
const teams = ref([]);
@ -77,9 +77,10 @@ async function changeTeam({ teamId, corpId, corpName }) {
}
}
async function getMatchTeams(inviteTeamId = '') {
async function getTeams(inviteTeamId = '') {
loading.value = true;
teams.value = await getTeams();
const res = await api('getWxappRelateTeams', { openid: account.value.openid });
teams.value = res && Array.isArray(res.data) ? res.data : [];
const matchTeamId = inviteTeamId || (team.value ? team.value.teamId : '');
const validTeam = teams.value.find(i => i.teamId && i.teamId === matchTeamId);
const firstTeam = teams.value[0]
@ -109,7 +110,7 @@ onShow(async () => {
corpUserIds.value[inviteTeam.teamId] = inviteTeam.corpUserId;
}
if (account.value && account.value.openid) {
getMatchTeams(inviteTeam && inviteTeam.teamId ? inviteTeam.teamId : '');
getTeams(inviteTeam && inviteTeam.teamId ? inviteTeam.teamId : '');
} else {
teams.value = [];
}
@ -123,13 +124,11 @@ onShow(async () => {
watch(account, (n, o) => {
if (n && !o) {
getMatchTeams();
getTeams();
} else if (!n && o) {
teams.value = [];
}
})
</script>
<style scoped>
.home-container {

View File

@ -14,7 +14,7 @@
</view>
</view>
<view v-if="currentTeam" class="text-base text-white truncate">
{{ currentTeam.leaderCorp || currentTeam.corpName || '' }}
{{ currentTeam.corpName }}
</view>
</view>
<view v-if="menuButtonInfo && menuButtonInfo.width > 0" class="flex-shrink-0" :style="{
@ -37,7 +37,7 @@
{{ item.name }}
</view>
<view class="text-base text-gray leading-normal">
{{ item.leaderCorp || item.corpName || '' }}
{{ item.corpName }}
</view>
</view>
<view class="flex">

View File

@ -2,17 +2,34 @@
<view class="message-page">
<!-- 消息列表 -->
<scroll-view class="message-list" scroll-y="true" refresher-enabled :refresher-triggered="refreshing"
@refresherrefresh="handleRefresh" @scrolltolower="handleLoadMore">
<scroll-view
class="message-list"
scroll-y="true"
refresher-enabled
:refresher-triggered="refreshing"
@refresherrefresh="handleRefresh"
@scrolltolower="handleLoadMore"
>
<!-- 加载状态 -->
<view v-if="loading && conversationList.length === 0" class="loading-container">
<view
v-if="loading && conversationList.length === 0"
class="loading-container"
>
<text class="loading-text">加载中...</text>
</view>
<!-- 消息列表项 -->
<view v-for="conversation in conversationList" :key="conversation.groupID || conversation.conversationID"
class="message-item" @click="handleClickConversation(conversation)">
<view
v-for="conversation in conversationList"
:key="conversation.groupID || conversation.conversationID"
class="message-item"
@click="handleClickConversation(conversation)"
>
<view class="avatar-container">
<GroupAvatar :avatarList="getAvatarList(conversation.groupID)" :size="96" classType="square" />
<GroupAvatar
:avatarList="getAvatarList(conversation.groupID)"
:size="96"
classType="square"
/>
<view v-if="conversation.unreadCount > 0" class="unread-badge">
<text class="unread-text">{{
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
@ -40,7 +57,10 @@
</view>
<!-- 空状态 -->
<view v-if="!loading && conversationList.length === 0" class="empty-container">
<view
v-if="!loading && conversationList.length === 0"
class="empty-container"
>
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
<text class="empty-text">暂无消息</text>
</view>
@ -56,7 +76,7 @@
</template>
<script setup>
import { ref, computed, onUnmounted, watch } from "vue";
import { ref, computed, onUnmounted } from "vue";
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
import { storeToRefs } from "pinia";
import useAccountStore from "@/store/account.js";
@ -67,7 +87,7 @@ import useGroupAvatars from "./hooks/use-group-avatars.js";
import GroupAvatar from "@/components/group-avatar.vue";
//
const { account, openid, isIMInitialized, hasImCorpId } = storeToRefs(useAccountStore());
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
const { initIMAfterLogin } = useAccountStore();
//
@ -235,7 +255,7 @@ let updateTimer = null;
//
const handleConversationListUpdate = async (eventData) => {
console.log("【消息列表页】会话列表更新事件:", eventData);
//
if (eventData && !Array.isArray(eventData) && eventData.conversationID) {
const conversationID = eventData.conversationID;
@ -354,9 +374,9 @@ const handleMessageReceived = (message) => {
//
const setupConversationListener = () => {
if (!globalTimChatManager) return;
console.log("【消息列表页】设置会话监听器");
//
//
if (globalUnreadListenerManager.isInitialized) {
@ -416,7 +436,7 @@ const formatMessageTime = (timestamp) => {
//
const handleClickConversation = async (conversation) => {
console.log("点击会话:", conversation);
//
const conversationIndex = conversationList.value.findIndex(
(conv) => conv.conversationID === conversation.conversationID
@ -432,7 +452,7 @@ const handleClickConversation = async (conversation) => {
conversationID: conversation.conversationID,
});
console.log("✓ 已标记会话为已读:", conversation.conversationID);
// tabBar
// await globalUnreadListenerManager.refreshBadge();
} catch (error) {
@ -459,7 +479,6 @@ const handleLoadMore = () => {
//
const handleRefresh = async () => {
if (!hasImCorpId.value) return;
refreshing.value = true;
try {
@ -470,7 +489,7 @@ const handleRefresh = async () => {
};
//
async function init() {
onLoad( async() => {
try {
// IM
const imReady = await initIM();
@ -484,7 +503,7 @@ async function init() {
} catch (error) {
console.log("页面初始化异常:", error.message);
}
};
});
//
const cleanMessageText = (text) => {
@ -503,33 +522,28 @@ onShow(async () => {
//
onHide(() => {
console.log("【消息列表页】页面隐藏");
//
if (updateTimer) {
clearTimeout(updateTimer);
updateTimer = null;
}
// globalTimChatManager
//
//
});
watch(hasImCorpId, (n, o) => {
if (n && !o) {
init();
}
}, { immediate: true })
//
onUnmounted(() => {
console.log("【消息列表页】页面卸载,清理回调");
//
if (updateTimer) {
clearTimeout(updateTimer);
updateTimer = null;
}
// //
// if (globalUnreadListenerManager.isInitialized) {
// globalUnreadListenerManager.removeCallback("onConversationListUpdated", handleConversationListUpdate);

View File

@ -1,4 +1,4 @@
import { ref, watch, computed } from "vue";
import { ref, watch } from "vue";
import { defineStore } from "pinia";
import api from '@/utils/api';
import { toast } from '@/utils/widget';
@ -13,9 +13,6 @@ export default defineStore("accountStore", () => {
const isIMInitialized = ref(false);
const openid = ref("");
const externalUserId = ref('');
const teams = ref([]);
const hasImCorpId = computed(() => teams.value.some(i => i.corpId === 'wpLgjyawAA8N0gWmXgyJq8wpjGcOT7fg'));
const teamsPromise = ref(null);
async function login(phoneCode = '') {
if (loading.value) return;
@ -41,7 +38,7 @@ export default defineStore("accountStore", () => {
uni.setStorageSync('account', res.data);
uni.setStorageSync('openid', res.data.openid);
// initIMAfterLogin(openid.value)
initIMAfterLogin(openid.value)
return res.data
}
}
@ -80,10 +77,10 @@ export default defineStore("accountStore", () => {
isIMInitialized.value = true;
console.log('IM 初始化成功');
// IM 初始化成功后,设置全局未读消息监听
// globalUnreadListenerManager.setup();
return true;
} catch (error) {
console.log('IM初始化异常跳过 IM 初始化:', error.message);
@ -99,7 +96,7 @@ export default defineStore("accountStore", () => {
await globalTimChatManager.destroy();
console.log('腾讯IM退出成功');
}
// 清除全局未读监听
if (globalUnreadListenerManager.isInitialized) {
// globalUnreadListenerManager.destroy();
@ -116,28 +113,13 @@ export default defineStore("accountStore", () => {
// 清除本地存储
uni.removeStorageSync('account');
uni.removeStorageSync('openid');
// 清除 tabBar 徽章
uni.removeTabBarBadge({
index: 1
});
}
async function searchTeams() {
const res = await api('getWxappRelateTeams', { openid: account.value.openid });
teams.value = res && Array.isArray(res.data) ? res.data : [];
return teams.value;
}
async function getTeams() {
if (!teamsPromise.value) {
teamsPromise.value = searchTeams();
}
await teamsPromise.value;
teamsPromise.value = null;
return teams.value;
}
async function getExternalUserId(corpId) {
const unionid = account.value?.unionid;
const openid = account.value?.openid;
@ -148,17 +130,5 @@ export default defineStore("accountStore", () => {
}
}
watch(hasImCorpId, n => {
if (n) {
initIMAfterLogin();
}
}, { immediate: true })
watch(openid, (n, o) => {
if (n && !o) {
getTeams();
}
}, { immediate: true })
return { account, teams, hasImCorpId, login, initIMAfterLogin, logout, openid, isIMInitialized, externalUserId, getExternalUserId, getTeams }
return { account, login, initIMAfterLogin, logout, openid, isIMInitialized, externalUserId, getExternalUserId }
})