2026-01-20 19:36:49 +08:00
|
|
|
|
<template>
|
2026-02-04 15:23:57 +08:00
|
|
|
|
<page-loading v-if="loading && teams.length === 0" />
|
|
|
|
|
|
<full-page v-else-if="teams.length && team" class="home-container" :pageStyle="pageStyle">
|
2026-01-20 19:36:49 +08:00
|
|
|
|
<template #header>
|
|
|
|
|
|
<team-head :team="team" :teams="teams" @changeTeam="changeTeam" />
|
|
|
|
|
|
</template>
|
2026-02-03 15:42:32 +08:00
|
|
|
|
<view class="home-section home-section--first">
|
2026-03-04 17:19:52 +08:00
|
|
|
|
<customer-archive ref="archiveRef" :corpId="corpId" :team="team" @update:customers="handleCustomersUpdate" />
|
2026-02-03 15:42:32 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
<view class="home-section">
|
2026-03-04 10:49:25 +08:00
|
|
|
|
<consult ref="consultRef" :corpId="corpId" :teamId="team.teamId" :team="team" :customers="customers" />
|
2026-02-03 15:42:32 +08:00
|
|
|
|
</view>
|
2026-02-05 10:27:20 +08:00
|
|
|
|
<!-- <view class="home-section">
|
2026-02-03 15:42:32 +08:00
|
|
|
|
<team-mate :team="team" />
|
2026-02-05 10:27:20 +08:00
|
|
|
|
</view> -->
|
2026-02-03 15:42:32 +08:00
|
|
|
|
<view class="home-section">
|
|
|
|
|
|
<article-list :team="team" />
|
|
|
|
|
|
</view>
|
2026-01-20 19:36:49 +08:00
|
|
|
|
</full-page>
|
|
|
|
|
|
<yc-home v-else />
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
2026-02-12 10:45:53 +08:00
|
|
|
|
import { computed, ref, watch } from "vue";
|
2026-02-04 12:51:45 +08:00
|
|
|
|
import { storeToRefs } from "pinia";
|
2026-02-10 11:08:00 +08:00
|
|
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
|
|
|
|
// import useGuard from "@/hooks/useGuard";
|
2026-02-04 12:51:45 +08:00
|
|
|
|
import useAccount from "@/store/account";
|
|
|
|
|
|
import api from "@/utils/api";
|
|
|
|
|
|
import { toast } from "@/utils/widget";
|
2026-02-09 15:17:45 +08:00
|
|
|
|
import { get, remove } from "@/utils/cache";
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
2026-02-04 12:51:45 +08:00
|
|
|
|
import FullPage from "@/components/full-page.vue";
|
|
|
|
|
|
import articleList from "./article-list.vue";
|
|
|
|
|
|
import consult from "./consult.vue";
|
|
|
|
|
|
import customerArchive from "./customer-archive.vue";
|
|
|
|
|
|
import teamHead from "./team-head.vue";
|
|
|
|
|
|
import teamMate from "./team-mate.vue";
|
|
|
|
|
|
import ycHome from "./yc-home.vue";
|
|
|
|
|
|
import pageLoading from "./loading.vue";
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
2026-02-10 11:08:00 +08:00
|
|
|
|
// const { useLoad, useShow } = useGuard();
|
2026-01-20 19:36:49 +08:00
|
|
|
|
const { account } = storeToRefs(useAccount());
|
2026-02-10 16:44:01 +08:00
|
|
|
|
const { login } = useAccount();
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
|
|
|
|
|
const team = ref(null);
|
|
|
|
|
|
const teams = ref([]);
|
2026-02-10 11:08:00 +08:00
|
|
|
|
const loading = ref(false);
|
2026-01-28 13:38:05 +08:00
|
|
|
|
const customers = ref([]);
|
2026-03-04 17:19:52 +08:00
|
|
|
|
const consultRef = ref(null);
|
|
|
|
|
|
const archiveRef = ref(null);
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
|
|
|
|
|
const corpId = computed(() => team.value?.corpId);
|
|
|
|
|
|
|
2026-02-03 15:42:32 +08:00
|
|
|
|
// UI 两段式背景:顶部 281px 渐变 + 下方纯色(按 375 设计稿,281px ≈ 562rpx)
|
|
|
|
|
|
const pageStyle =
|
2026-02-04 12:51:45 +08:00
|
|
|
|
"background: linear-gradient(180deg, #065BD6 15.05%, #F6FAFA 95.37%) 0 0/100% 562rpx no-repeat, #F6FAFA;";
|
2026-02-03 09:59:49 +08:00
|
|
|
|
|
2026-01-28 13:38:05 +08:00
|
|
|
|
function handleCustomersUpdate(newCustomers) {
|
|
|
|
|
|
customers.value = newCustomers;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-20 19:36:49 +08:00
|
|
|
|
async function changeTeam({ teamId, corpId, corpName }) {
|
|
|
|
|
|
loading.value = true;
|
2026-02-04 12:51:45 +08:00
|
|
|
|
const res = await api("getTeamData", { teamId, corpId });
|
2026-01-20 19:36:49 +08:00
|
|
|
|
loading.value = false;
|
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
|
team.value = res.data;
|
|
|
|
|
|
team.value.corpName = corpName;
|
|
|
|
|
|
} else {
|
2026-02-04 12:51:45 +08:00
|
|
|
|
toast(res?.message || "获取团队信息失败");
|
2026-01-20 19:36:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
async function getTeams() {
|
|
|
|
|
|
loading.value = true;
|
2026-02-04 13:28:47 +08:00
|
|
|
|
const res = await api('getWxappRelateTeams', { openid: account.value.openid });
|
2026-01-20 19:36:49 +08:00
|
|
|
|
teams.value = res && Array.isArray(res.data) ? res.data : [];
|
2026-02-09 15:17:45 +08:00
|
|
|
|
const matchTeamId = get('home-invite-teamId') || (team.value ? team.value.teamId : '');
|
|
|
|
|
|
const validTeam = teams.value.find(i => i.teamId && i.teamId === matchTeamId);
|
|
|
|
|
|
const firstTeam = teams.value[0]
|
|
|
|
|
|
if (validTeam || firstTeam) {
|
|
|
|
|
|
remove('home-invite-teamId');
|
|
|
|
|
|
changeTeam(validTeam || firstTeam);
|
2026-01-21 10:35:08 +08:00
|
|
|
|
} else {
|
2026-01-20 19:36:49 +08:00
|
|
|
|
team.value = null;
|
|
|
|
|
|
}
|
2026-02-04 12:51:45 +08:00
|
|
|
|
loading.value = false;
|
2026-01-20 19:36:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-02-10 11:08:00 +08:00
|
|
|
|
// useLoad((opts) => {
|
|
|
|
|
|
// if (opts.teamId) {
|
|
|
|
|
|
// team.value = { teamId: opts.teamId, corpId: opts.corpId };
|
|
|
|
|
|
// }
|
|
|
|
|
|
// });
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
2026-02-10 16:44:01 +08:00
|
|
|
|
onLoad(() => {
|
|
|
|
|
|
if (!account.value) login();
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
onShow(async () => {
|
|
|
|
|
|
if (!account.value) await login();
|
2026-02-10 11:08:00 +08:00
|
|
|
|
if (account.value && account.value.openid) {
|
|
|
|
|
|
getTeams();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
teams.value = [];
|
|
|
|
|
|
}
|
2026-03-04 10:49:25 +08:00
|
|
|
|
if (consultRef.value && typeof consultRef.value.getBadgeCount === 'function') {
|
|
|
|
|
|
consultRef.value.getBadgeCount()
|
|
|
|
|
|
}
|
2026-03-04 17:19:52 +08:00
|
|
|
|
if (archiveRef.value && typeof archiveRef.value.getCustomers === 'function') {
|
|
|
|
|
|
archiveRef.value.getCustomers()
|
|
|
|
|
|
}
|
2026-02-04 12:51:45 +08:00
|
|
|
|
});
|
2026-03-04 10:49:25 +08:00
|
|
|
|
|
2026-02-12 10:45:53 +08:00
|
|
|
|
watch(account, (n, o) => {
|
|
|
|
|
|
if (n && !o) {
|
|
|
|
|
|
getTeams();
|
|
|
|
|
|
} else if (!n && o) {
|
|
|
|
|
|
teams.value = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2026-01-20 19:36:49 +08:00
|
|
|
|
</script>
|
2026-02-03 09:59:49 +08:00
|
|
|
|
<style scoped>
|
|
|
|
|
|
.home-container {
|
|
|
|
|
|
min-height: 100vh;
|
|
|
|
|
|
}
|
2026-02-03 15:42:32 +08:00
|
|
|
|
|
|
|
|
|
|
.home-section {
|
|
|
|
|
|
margin-top: 24rpx;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.home-section--first {
|
|
|
|
|
|
margin-top: 0;
|
|
|
|
|
|
}
|
2026-02-03 09:59:49 +08:00
|
|
|
|
</style>
|