Create team.js

This commit is contained in:
huxuejian 2026-01-29 10:45:50 +08:00
parent 2cf940e0b9
commit 5f1f83f6c7

31
store/team.js Normal file
View File

@ -0,0 +1,31 @@
import { ref } from "vue";
import { defineStore, storeToRefs } from "pinia";
import api from '@/utils/api';
import { toast } from '@/utils/widget';
import useAccountStore from "./account";
export default defineStore("teamStore", () => {
const { account, doctorInfo } = storeToRefs(useAccountStore());
const teams = ref([]);
async function getTeam(teamId) {
if (!teamId || !account.value?.corpId) return;
const res = await api('getTeamData', { teamId, corpId: account.value.corpId });
if (res && res.data) {
return res.data;
} else {
toast(res?.message || '获取团队信息失败')
}
}
async function getTeams() {
const corpId = account.value?.corpId;
const mateId = doctorInfo.value?.corpId;
if (!corpId || !mateId) return;
const res = await api('getJoinedTeams', { corpId, mateId });
teams.value = res && Array.isArray(res.data) ? res.data : [];
}
return { teams, getTeam, getTeams }
})