2026-01-20 19:36:49 +08:00
|
|
|
<template>
|
2026-03-05 15:03:07 +08:00
|
|
|
<view class="flex flex-col justify-center items-center h-full" @click="copy()">
|
2026-01-20 19:36:49 +08:00
|
|
|
<image class="flash-logo" src="/static/logo-plain.png" />
|
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
<script setup>
|
2026-01-29 11:42:56 +08:00
|
|
|
import { ref } from "vue";
|
2026-02-04 13:28:47 +08:00
|
|
|
import { storeToRefs } from "pinia";
|
2026-01-20 19:36:49 +08:00
|
|
|
import { onLoad } from "@dcloudio/uni-app";
|
2026-01-29 11:42:56 +08:00
|
|
|
import api from "@/utils/api";
|
2026-01-20 19:36:49 +08:00
|
|
|
import { set } from "@/utils/cache";
|
2026-01-29 11:42:56 +08:00
|
|
|
import { toast } from "@/utils/widget";
|
2026-02-04 13:28:47 +08:00
|
|
|
import useAccountStore from "@/store/account";
|
|
|
|
|
|
|
|
|
|
const env = __VITE_ENV__;
|
|
|
|
|
const appid = env.MP_WX_APP_ID;
|
|
|
|
|
const { account } = storeToRefs(useAccountStore());
|
2026-04-30 17:55:34 +08:00
|
|
|
const { login } = useAccountStore();
|
|
|
|
|
|
2026-02-04 13:28:47 +08:00
|
|
|
|
2026-01-20 19:36:49 +08:00
|
|
|
|
|
|
|
|
const loading = ref(false);
|
2026-01-29 11:42:56 +08:00
|
|
|
const team = ref(null);
|
2026-02-27 10:36:17 +08:00
|
|
|
const opts = ref('');
|
|
|
|
|
|
2026-03-05 15:03:07 +08:00
|
|
|
function copy() {
|
|
|
|
|
uni.setClipboardData({
|
|
|
|
|
data: opts.value || '暂无内容'
|
|
|
|
|
})
|
2026-02-27 10:36:17 +08:00
|
|
|
}
|
2026-01-20 19:36:49 +08:00
|
|
|
|
2026-06-02 10:36:41 +08:00
|
|
|
function safeDecode(value) {
|
|
|
|
|
try {
|
|
|
|
|
return decodeURIComponent(value);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseInviteOptions(options = {}) {
|
|
|
|
|
const href =
|
|
|
|
|
typeof options.q === "string" ? safeDecode(options.q) : "";
|
|
|
|
|
const [, url = ""] = href.split("?");
|
|
|
|
|
const data = url.split("&").reduce((acc, cur) => {
|
|
|
|
|
if (!cur) return acc;
|
|
|
|
|
const [key, ...valueParts] = cur.split("=");
|
|
|
|
|
if (!key) return acc;
|
|
|
|
|
acc[key] = safeDecode(valueParts.join("=") || "");
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
|
|
|
|
return {
|
|
|
|
|
...options,
|
|
|
|
|
...data,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function syncExternalUserRelation({ corpId, externalUserId, corpUserId }) {
|
|
|
|
|
const currentAccount = account.value || {};
|
|
|
|
|
if (!(corpId && externalUserId && currentAccount.openid)) return;
|
|
|
|
|
try {
|
|
|
|
|
const res = await api('syncWxappExternalUserRelation', {
|
|
|
|
|
corpId,
|
|
|
|
|
externalUserId,
|
|
|
|
|
unionid: currentAccount.unionid || '',
|
|
|
|
|
openid: currentAccount.openid,
|
|
|
|
|
corpUserId: corpUserId || '',
|
|
|
|
|
}, false);
|
|
|
|
|
if (!res || !res.success) {
|
|
|
|
|
console.warn('关联 externalUserId 失败:', res && res.message);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.warn('关联 externalUserId 异常:', error && error.message ? error.message : error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function changeTeam({ teamId, corpId, corpUserId, externalUserId, qrid, referenceCustomerId }) {
|
2026-01-20 19:36:49 +08:00
|
|
|
loading.value = true;
|
2026-01-29 11:42:56 +08:00
|
|
|
const res = await api("getTeamData", { teamId, corpId, withCorpName: true });
|
2026-01-20 19:36:49 +08:00
|
|
|
loading.value = false;
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
team.value = res.data;
|
2026-02-04 09:16:36 +08:00
|
|
|
team.value.corpName = res.data.corpName;
|
2026-03-05 15:03:07 +08:00
|
|
|
set('home-invite-team-info', {
|
|
|
|
|
teamId: team.value.teamId,
|
2026-05-19 19:26:16 +08:00
|
|
|
corpUserId: corpUserId || '',
|
2026-06-02 10:36:41 +08:00
|
|
|
externalUserId: externalUserId || '',
|
2026-05-19 19:26:16 +08:00
|
|
|
qrid,
|
|
|
|
|
referenceCustomerId: referenceCustomerId || ''
|
2026-03-05 15:03:07 +08:00
|
|
|
});
|
2026-04-30 17:55:34 +08:00
|
|
|
await login()
|
2026-05-16 11:20:21 +08:00
|
|
|
if (account.value && account.value.mobile) {
|
2026-06-02 10:36:41 +08:00
|
|
|
bindTeam({ corpUserId, externalUserId })
|
2026-02-04 13:28:47 +08:00
|
|
|
} else {
|
|
|
|
|
set("invite-team-info", {
|
2026-03-05 15:03:07 +08:00
|
|
|
corpUserId,
|
2026-06-02 10:36:41 +08:00
|
|
|
externalUserId,
|
2026-05-13 20:38:12 +08:00
|
|
|
qrid,
|
|
|
|
|
referenceCustomerId,
|
2026-02-04 13:28:47 +08:00
|
|
|
corpId: team.value.corpId,
|
|
|
|
|
teamId: team.value.teamId,
|
|
|
|
|
corpName: team.value.corpName,
|
|
|
|
|
teamName: team.value.name,
|
|
|
|
|
avatars:
|
|
|
|
|
team.value && Array.isArray(team.value.memberList)
|
|
|
|
|
? team.value.memberList.map((item) => item.avatar || "")
|
|
|
|
|
: [],
|
|
|
|
|
});
|
|
|
|
|
uni.redirectTo({
|
|
|
|
|
url: "/pages/login/login?source=teamInvite",
|
|
|
|
|
});
|
|
|
|
|
}
|
2026-01-20 19:36:49 +08:00
|
|
|
} else {
|
2026-01-29 11:42:56 +08:00
|
|
|
toast(res?.message || "获取团队信息失败");
|
2026-01-20 19:36:49 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-02 10:36:41 +08:00
|
|
|
async function bindTeam({ corpUserId, externalUserId }) {
|
2026-02-04 13:28:47 +08:00
|
|
|
const res = await api('bindWxappWithTeam', { appid, corpId: team.value.corpId, teamId: team.value.teamId, openid: account.value.openid });
|
|
|
|
|
if (!res || !res.success) {
|
|
|
|
|
return toast("关联团队失败");
|
|
|
|
|
}
|
2026-06-02 10:36:41 +08:00
|
|
|
await syncExternalUserRelation({
|
|
|
|
|
corpId: team.value.corpId,
|
|
|
|
|
externalUserId,
|
|
|
|
|
corpUserId,
|
|
|
|
|
});
|
2026-02-09 16:34:55 +08:00
|
|
|
const res1 = await api('getWxAppCustomerCount', { miniAppId: account.value.openid, corpId: team.value.corpId, teamId: team.value.teamId });
|
2026-02-04 13:28:47 +08:00
|
|
|
if (res1 && res1.data > 0) {
|
|
|
|
|
uni.switchTab({
|
|
|
|
|
url: "/pages/home/home",
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
uni.redirectTo({
|
2026-03-05 15:03:07 +08:00
|
|
|
url: `/pages/archive/edit-archive?corpUserId=${corpUserId || ''}&teamId=${team.value.teamId}&corpId=${team.value.corpId}`
|
2026-02-04 13:28:47 +08:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-29 11:42:56 +08:00
|
|
|
onLoad((options) => {
|
2026-05-13 20:38:12 +08:00
|
|
|
if (options.q) {
|
|
|
|
|
opts.value = JSON.stringify(options)
|
2026-06-02 10:36:41 +08:00
|
|
|
changeTeam(parseInviteOptions(options));
|
2026-06-03 18:47:12 +08:00
|
|
|
} else if (options.type === 'archive' || (options.teamId && options.corpId)) {
|
2026-05-13 20:38:12 +08:00
|
|
|
changeTeam(options);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-29 11:42:56 +08:00
|
|
|
});
|
2026-01-20 19:36:49 +08:00
|
|
|
</script>
|
|
|
|
|
<style>
|
|
|
|
|
.flash-logo {
|
|
|
|
|
width: 200rpx;
|
|
|
|
|
height: 200rpx;
|
|
|
|
|
animation: flash 2.5s infinite;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@keyframes flash {
|
|
|
|
|
0% {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
50% {
|
|
|
|
|
opacity: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
100% {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-06-02 10:36:41 +08:00
|
|
|
</style>
|