109 lines
2.9 KiB
Vue
Raw Normal View History

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-02-04 15:23:57 +08:00
<customer-archive :corpId="corpId" :team="team" @update:customers="handleCustomersUpdate" />
2026-02-03 15:42:32 +08:00
</view>
<view class="home-section">
<consult :corpId="corpId" :teamId="team.teamId" :customers="customers" />
</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-04 12:51:45 +08:00
import { computed, ref, watch } from "vue";
import { storeToRefs } from "pinia";
import useGuard from "@/hooks/useGuard";
import useAccount from "@/store/account";
import api from "@/utils/api";
import { toast } from "@/utils/widget";
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
const { useLoad, useShow } = useGuard();
const { account } = storeToRefs(useAccount());
const team = ref(null);
const teams = ref([]);
2026-01-28 13:38:05 +08:00
const loading = ref(true);
const customers = ref([]);
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-04 12:51:45 +08:00
const validTeam =
teams.value.find(
(item) => team.value && item.teamId === team.value.teamId
) || teams.value[0];
2026-01-21 10:35:08 +08:00
if (validTeam) {
2026-02-04 12:51:45 +08:00
changeTeam(validTeam);
return;
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-04 12:51:45 +08:00
useLoad((opts) => {
2026-01-20 19:36:49 +08:00
if (opts.teamId) {
team.value = { teamId: opts.teamId, corpId: opts.corpId };
}
2026-02-04 12:51:45 +08:00
});
2026-01-20 19:36:49 +08:00
useShow(() => {
getTeams();
2026-02-04 12:51:45 +08:00
});
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>