Compare commits
No commits in common. "main" and "dev-260402" have entirely different histories.
main
...
dev-260402
@ -1,5 +1,5 @@
|
|||||||
MP_API_BASE_URL=https://ykt.youcan365.com
|
MP_API_BASE_URL=https://ykt.youcan365.com
|
||||||
MP_CACHE_PREFIX=production
|
MP_CACHE_PREFIX=production
|
||||||
MP_WX_APP_ID=wx6ee11733526b4f04
|
MP_WX_APP_ID=wx6ee11733526b4f04
|
||||||
MP_TIM_SDK_APP_ID=1600136080
|
MP_TIM_SDK_APP_ID=1600123876
|
||||||
MP_CORP_ID=wpLgjyawAA8N0gWmXgyJq8wpjGcOT7fg
|
MP_CORP_ID=wpLgjyawAA8N0gWmXgyJq8wpjGcOT7fg
|
||||||
2
App.vue
2
App.vue
@ -8,7 +8,7 @@ export default {
|
|||||||
console.log("App Launch: ");
|
console.log("App Launch: ");
|
||||||
|
|
||||||
// 获取 openId 并初始化 IM
|
// 获取 openId 并初始化 IM
|
||||||
// await this.initIMOnLaunch();
|
await this.initIMOnLaunch();
|
||||||
},
|
},
|
||||||
onShow: function () {
|
onShow: function () {
|
||||||
const db = dbStore();
|
const db = dbStore();
|
||||||
|
|||||||
@ -190,7 +190,6 @@ async function init() {
|
|||||||
await getCustomer();
|
await getCustomer();
|
||||||
} else {
|
} else {
|
||||||
const res = await getArchives();
|
const res = await getArchives();
|
||||||
console.log('res:', res)
|
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
visible.value = true;
|
visible.value = true;
|
||||||
}
|
}
|
||||||
@ -204,9 +203,14 @@ async function init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function getArchives() {
|
async function getArchives() {
|
||||||
const res = await api('getUnbindMiniAppCustomers', { corpId: corpId.value, mobile: account.value?.mobile || '' });
|
const res = await api('getUnbindMiniAppCustomers', { corpId: corpId.value, mobile: account.value.mobile });
|
||||||
customers.value = res && Array.isArray(res.data) ? res.data : [];
|
if (res && res.success) {
|
||||||
corpName.value = res && res.corpName ? res.corpName : '';
|
corpName.value = res.corpName;
|
||||||
|
customers.value = Array.isArray(res.data) ? res.data : [];
|
||||||
|
} else {
|
||||||
|
toast(res?.message || '查询档案信息失败');
|
||||||
|
return Promise.reject()
|
||||||
|
}
|
||||||
return customers.value
|
return customers.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ import pageLoading from "./loading.vue";
|
|||||||
|
|
||||||
// const { useLoad, useShow } = useGuard();
|
// const { useLoad, useShow } = useGuard();
|
||||||
const { account } = storeToRefs(useAccount());
|
const { account } = storeToRefs(useAccount());
|
||||||
const { login, getTeams } = useAccount();
|
const { login } = useAccount();
|
||||||
|
|
||||||
const team = ref(null);
|
const team = ref(null);
|
||||||
const teams = ref([]);
|
const teams = ref([]);
|
||||||
@ -77,9 +77,10 @@ async function changeTeam({ teamId, corpId, corpName }) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getMatchTeams(inviteTeamId = '') {
|
async function getTeams(inviteTeamId = '') {
|
||||||
loading.value = true;
|
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 matchTeamId = inviteTeamId || (team.value ? team.value.teamId : '');
|
||||||
const validTeam = teams.value.find(i => i.teamId && i.teamId === matchTeamId);
|
const validTeam = teams.value.find(i => i.teamId && i.teamId === matchTeamId);
|
||||||
const firstTeam = teams.value[0]
|
const firstTeam = teams.value[0]
|
||||||
@ -109,7 +110,7 @@ onShow(async () => {
|
|||||||
corpUserIds.value[inviteTeam.teamId] = inviteTeam.corpUserId;
|
corpUserIds.value[inviteTeam.teamId] = inviteTeam.corpUserId;
|
||||||
}
|
}
|
||||||
if (account.value && account.value.openid) {
|
if (account.value && account.value.openid) {
|
||||||
getMatchTeams(inviteTeam && inviteTeam.teamId ? inviteTeam.teamId : '');
|
getTeams(inviteTeam && inviteTeam.teamId ? inviteTeam.teamId : '');
|
||||||
} else {
|
} else {
|
||||||
teams.value = [];
|
teams.value = [];
|
||||||
}
|
}
|
||||||
@ -123,13 +124,11 @@ onShow(async () => {
|
|||||||
|
|
||||||
watch(account, (n, o) => {
|
watch(account, (n, o) => {
|
||||||
if (n && !o) {
|
if (n && !o) {
|
||||||
getMatchTeams();
|
getTeams();
|
||||||
} else if (!n && o) {
|
} else if (!n && o) {
|
||||||
teams.value = [];
|
teams.value = [];
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.home-container {
|
.home-container {
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="currentTeam" class="text-base text-white truncate">
|
<view v-if="currentTeam" class="text-base text-white truncate">
|
||||||
{{ currentTeam.leaderCorp || currentTeam.corpName || '' }}
|
{{ currentTeam.corpName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view v-if="menuButtonInfo && menuButtonInfo.width > 0" class="flex-shrink-0" :style="{
|
<view v-if="menuButtonInfo && menuButtonInfo.width > 0" class="flex-shrink-0" :style="{
|
||||||
@ -37,7 +37,7 @@
|
|||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</view>
|
</view>
|
||||||
<view class="text-base text-gray leading-normal">
|
<view class="text-base text-gray leading-normal">
|
||||||
{{ item.leaderCorp || item.corpName || '' }}
|
{{ item.corpName }}
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="flex">
|
<view class="flex">
|
||||||
|
|||||||
@ -2,17 +2,34 @@
|
|||||||
<view class="message-page">
|
<view class="message-page">
|
||||||
|
|
||||||
<!-- 消息列表 -->
|
<!-- 消息列表 -->
|
||||||
<scroll-view class="message-list" scroll-y="true" refresher-enabled :refresher-triggered="refreshing"
|
<scroll-view
|
||||||
@refresherrefresh="handleRefresh" @scrolltolower="handleLoadMore">
|
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>
|
<text class="loading-text">加载中...</text>
|
||||||
</view>
|
</view>
|
||||||
<!-- 消息列表项 -->
|
<!-- 消息列表项 -->
|
||||||
<view v-for="conversation in conversationList" :key="conversation.groupID || conversation.conversationID"
|
<view
|
||||||
class="message-item" @click="handleClickConversation(conversation)">
|
v-for="conversation in conversationList"
|
||||||
|
:key="conversation.groupID || conversation.conversationID"
|
||||||
|
class="message-item"
|
||||||
|
@click="handleClickConversation(conversation)"
|
||||||
|
>
|
||||||
<view class="avatar-container">
|
<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">
|
<view v-if="conversation.unreadCount > 0" class="unread-badge">
|
||||||
<text class="unread-text">{{
|
<text class="unread-text">{{
|
||||||
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
conversation.unreadCount > 99 ? "99+" : conversation.unreadCount
|
||||||
@ -40,7 +57,10 @@
|
|||||||
</view>
|
</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" />
|
<image class="empty-image" src="/static/empty.svg" mode="aspectFit" />
|
||||||
<text class="empty-text">暂无消息</text>
|
<text class="empty-text">暂无消息</text>
|
||||||
</view>
|
</view>
|
||||||
@ -56,7 +76,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed, onUnmounted, watch } from "vue";
|
import { ref, computed, onUnmounted } from "vue";
|
||||||
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
import { onLoad, onShow, onHide } from "@dcloudio/uni-app";
|
||||||
import { storeToRefs } from "pinia";
|
import { storeToRefs } from "pinia";
|
||||||
import useAccountStore from "@/store/account.js";
|
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";
|
import GroupAvatar from "@/components/group-avatar.vue";
|
||||||
|
|
||||||
// 获取登录状态
|
// 获取登录状态
|
||||||
const { account, openid, isIMInitialized, hasImCorpId } = storeToRefs(useAccountStore());
|
const { account, openid, isIMInitialized } = storeToRefs(useAccountStore());
|
||||||
const { initIMAfterLogin } = useAccountStore();
|
const { initIMAfterLogin } = useAccountStore();
|
||||||
|
|
||||||
// 状态
|
// 状态
|
||||||
@ -459,7 +479,6 @@ const handleLoadMore = () => {
|
|||||||
|
|
||||||
// 下拉刷新
|
// 下拉刷新
|
||||||
const handleRefresh = async () => {
|
const handleRefresh = async () => {
|
||||||
if (!hasImCorpId.value) return;
|
|
||||||
refreshing.value = true;
|
refreshing.value = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -470,7 +489,7 @@ const handleRefresh = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 页面加载
|
// 页面加载
|
||||||
async function init() {
|
onLoad( async() => {
|
||||||
try {
|
try {
|
||||||
// 初始化IM
|
// 初始化IM
|
||||||
const imReady = await initIM();
|
const imReady = await initIM();
|
||||||
@ -484,7 +503,7 @@ async function init() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("页面初始化异常:", error.message);
|
console.log("页面初始化异常:", error.message);
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|
||||||
// 清理消息文本(移除换行符)
|
// 清理消息文本(移除换行符)
|
||||||
const cleanMessageText = (text) => {
|
const cleanMessageText = (text) => {
|
||||||
@ -515,11 +534,6 @@ onHide(() => {
|
|||||||
// 回调链会在页面销毁时自动清理
|
// 回调链会在页面销毁时自动清理
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(hasImCorpId, (n, o) => {
|
|
||||||
if (n && !o) {
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}, { immediate: true })
|
|
||||||
// 页面卸载
|
// 页面卸载
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
console.log("【消息列表页】页面卸载,清理回调");
|
console.log("【消息列表页】页面卸载,清理回调");
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { ref, watch, computed } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import api from '@/utils/api';
|
import api from '@/utils/api';
|
||||||
import { toast } from '@/utils/widget';
|
import { toast } from '@/utils/widget';
|
||||||
@ -13,9 +13,6 @@ export default defineStore("accountStore", () => {
|
|||||||
const isIMInitialized = ref(false);
|
const isIMInitialized = ref(false);
|
||||||
const openid = ref("");
|
const openid = ref("");
|
||||||
const externalUserId = 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 = '') {
|
async function login(phoneCode = '') {
|
||||||
if (loading.value) return;
|
if (loading.value) return;
|
||||||
@ -41,7 +38,7 @@ export default defineStore("accountStore", () => {
|
|||||||
uni.setStorageSync('account', res.data);
|
uni.setStorageSync('account', res.data);
|
||||||
uni.setStorageSync('openid', res.data.openid);
|
uni.setStorageSync('openid', res.data.openid);
|
||||||
|
|
||||||
// initIMAfterLogin(openid.value)
|
initIMAfterLogin(openid.value)
|
||||||
return res.data
|
return res.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -123,21 +120,6 @@ export default defineStore("accountStore", () => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
async function getExternalUserId(corpId) {
|
||||||
const unionid = account.value?.unionid;
|
const unionid = account.value?.unionid;
|
||||||
const openid = account.value?.openid;
|
const openid = account.value?.openid;
|
||||||
@ -148,17 +130,5 @@ export default defineStore("accountStore", () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(hasImCorpId, n => {
|
return { account, login, initIMAfterLogin, logout, openid, isIMInitialized, externalUserId, getExternalUserId }
|
||||||
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 }
|
|
||||||
})
|
})
|
||||||
Loading…
x
Reference in New Issue
Block a user