432 lines
17 KiB
Vue
432 lines
17 KiB
Vue
<script>
|
|
/** 首页推介摘要:区分申请权限、已开通和加载失败,永久关系模式额外展示邀请人数,所有入口转入完整推介页。 */
|
|
import "~/assets/styles/HomeReferralPanel.DsgN33ME.css";
|
|
import { toDisplayString } from "vue";
|
|
import { renderList } from "vue";
|
|
import { onMounted } from "vue";
|
|
import { ref } from "vue";
|
|
import { withCtx } from "vue";
|
|
import { createCommentVNode } from "vue";
|
|
import { computed } from "vue";
|
|
import { createElementBlock } from "vue";
|
|
import { Fragment } from "vue";
|
|
import { createElementVNode } from "vue";
|
|
import { createTextVNode } from "vue";
|
|
import { unref } from "vue";
|
|
import { defineComponent } from "vue";
|
|
import { createVNode } from "vue";
|
|
import { openBlock } from "vue";
|
|
import { NuxtLink } from "#components";
|
|
import { useApi } from "~/lib/auth.js";
|
|
import { Icon } from "#components";
|
|
import button from "primevue/button";
|
|
import { t as _plugin_vue_export_helper_t } from "~/lib/_plugin-vue_export-helper.js";
|
|
import skeleton from "primevue/skeleton";
|
|
var x = [`aria-busy`],
|
|
S = {
|
|
class: `home-card-head`,
|
|
},
|
|
C = {
|
|
id: `home-referral-title`,
|
|
class: `home-card-title`,
|
|
},
|
|
w = {
|
|
key: 0,
|
|
class: `referral-body referral-loading`,
|
|
role: `status`,
|
|
"aria-label": `正在加载推介数据`,
|
|
},
|
|
T = {
|
|
class: `referral-placeholders`,
|
|
},
|
|
E = {
|
|
key: 1,
|
|
class: `referral-body referral-empty`,
|
|
role: `status`,
|
|
},
|
|
D = {
|
|
key: 2,
|
|
class: `referral-body`,
|
|
},
|
|
O = {
|
|
class: `referral-overview`,
|
|
},
|
|
k = {
|
|
class: `referral-balance`,
|
|
},
|
|
A = {
|
|
key: 0,
|
|
},
|
|
j = {
|
|
key: 0,
|
|
class: `referral-invitees`,
|
|
},
|
|
M = {
|
|
class: `referral-stats`,
|
|
},
|
|
N = {
|
|
key: 0,
|
|
},
|
|
P = {
|
|
class: `referral-footer`,
|
|
},
|
|
F = {
|
|
key: 3,
|
|
class: `referral-body referral-empty`,
|
|
},
|
|
I = Object.assign(
|
|
_plugin_vue_export_helper_t(
|
|
defineComponent({
|
|
__name: `HomeReferralPanel`,
|
|
setup(f) {
|
|
let y = useApi(),
|
|
I = ref(null),
|
|
L = ref(!0),
|
|
R = ref(``),
|
|
z = !1,
|
|
B = computed(() => !!I.value?.url),
|
|
V = computed(() => I.value?.permission === 1),
|
|
H = computed(() => I.value?.relation_mode === `permanent`),
|
|
U = computed(() => [
|
|
{
|
|
label: `待结算`,
|
|
value: I.value?.pending_amount,
|
|
},
|
|
{
|
|
label: `已生效`,
|
|
value: I.value?.active_amount,
|
|
},
|
|
{
|
|
label: `已提现`,
|
|
value: I.value?.withdrawn_amount,
|
|
},
|
|
]);
|
|
// 金额固定两位小数,人数要求非负整数;缺失或非有限值显示占位,不冒充零值。
|
|
function W(e, t = !0) {
|
|
if (
|
|
(typeof e != `number` && typeof e != `string`) ||
|
|
String(e).trim() === ``
|
|
)
|
|
return `—`;
|
|
let n = Number(e);
|
|
return !Number.isFinite(n) ||
|
|
(!t && (!Number.isInteger(n) || n < 0))
|
|
? `—`
|
|
: n.toLocaleString(`zh-CN`, {
|
|
minimumFractionDigits: t ? 2 : 0,
|
|
maximumFractionDigits: t ? 2 : 0,
|
|
});
|
|
}
|
|
// 请求有 10 秒截止时间;无链接时必须有明确的 0/1 权限,否则不展示错误的开通状态。
|
|
async function G() {
|
|
if (!z) {
|
|
((z = !0), (L.value = !0), (R.value = ``));
|
|
try {
|
|
let e = (
|
|
await y.get(`/recommend/promoter`, void 0, !1, {
|
|
timeoutMs: 1e4,
|
|
})
|
|
)?.promoter;
|
|
if (!e || (!e.url && e.permission !== 0 && e.permission !== 1))
|
|
throw Error(`暂时无法获取推介数据,请重试。`);
|
|
I.value = e;
|
|
} catch (e) {
|
|
((I.value = null),
|
|
(R.value =
|
|
e instanceof Error
|
|
? e.message
|
|
: `暂时无法获取推介数据,请重试。`));
|
|
} finally {
|
|
((L.value = !1), (z = !1));
|
|
}
|
|
}
|
|
}
|
|
return (
|
|
onMounted(G),
|
|
// 加载、错误、已开通和未开通分支互斥;未知金额不显示货币前缀。
|
|
(n, r) => {
|
|
let o = Icon,
|
|
f = NuxtLink,
|
|
g = skeleton,
|
|
y = button;
|
|
return (
|
|
openBlock(),
|
|
createElementBlock(
|
|
`section`,
|
|
{
|
|
class: `home-card home-referral`,
|
|
"aria-labelledby": `home-referral-title`,
|
|
"aria-busy": unref(L),
|
|
},
|
|
[
|
|
createElementVNode(`div`, S, [
|
|
createElementVNode(`h2`, C, [
|
|
createVNode(o, {
|
|
name: `lucide:gift`,
|
|
"aria-hidden": `true`,
|
|
}),
|
|
(r[0] ||= createTextVNode(`推介计划`, -1)),
|
|
]),
|
|
createVNode(
|
|
f,
|
|
{
|
|
to: `/recommend`,
|
|
class: `home-card-more`,
|
|
"aria-label": `查看推介计划`,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
...(r[1] ||= [
|
|
createElementVNode(
|
|
`i`,
|
|
{
|
|
class: `pi pi-angle-right`,
|
|
"aria-hidden": `true`,
|
|
},
|
|
null,
|
|
-1,
|
|
),
|
|
]),
|
|
]),
|
|
_: 1,
|
|
},
|
|
),
|
|
]),
|
|
unref(L)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, w, [
|
|
createVNode(g, {
|
|
width: `6rem`,
|
|
height: `14px`,
|
|
}),
|
|
createVNode(g, {
|
|
width: `11rem`,
|
|
height: `36px`,
|
|
}),
|
|
createElementVNode(`div`, T, [
|
|
(openBlock(),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(3, (e) =>
|
|
createVNode(g, {
|
|
key: e,
|
|
height: `48px`,
|
|
}),
|
|
),
|
|
64,
|
|
)),
|
|
]),
|
|
]))
|
|
: unref(R)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, E, [
|
|
(r[2] ||= createElementVNode(
|
|
`h3`,
|
|
null,
|
|
`推介数据加载失败`,
|
|
-1,
|
|
)),
|
|
createElementVNode(
|
|
`p`,
|
|
null,
|
|
toDisplayString(unref(R)),
|
|
1,
|
|
),
|
|
createVNode(y, {
|
|
label: `重试`,
|
|
icon: `pi pi-refresh`,
|
|
severity: `secondary`,
|
|
outlined: ``,
|
|
size: `small`,
|
|
onClick: G,
|
|
}),
|
|
]))
|
|
: unref(B)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, D, [
|
|
createElementVNode(`dl`, O, [
|
|
createElementVNode(`div`, k, [
|
|
(r[3] ||= createElementVNode(
|
|
`dt`,
|
|
null,
|
|
`可提现奖励`,
|
|
-1,
|
|
)),
|
|
createElementVNode(`dd`, null, [
|
|
W(unref(I)?.withdrawable_amount) === `—`
|
|
? createCommentVNode(``, !0)
|
|
: (openBlock(),
|
|
createElementBlock(`small`, A, `¥`)),
|
|
createTextVNode(
|
|
toDisplayString(
|
|
W(unref(I)?.withdrawable_amount),
|
|
),
|
|
1,
|
|
),
|
|
]),
|
|
]),
|
|
unref(H)
|
|
? (openBlock(),
|
|
createElementBlock(`div`, j, [
|
|
(r[5] ||= createElementVNode(
|
|
`dt`,
|
|
null,
|
|
`邀请人数`,
|
|
-1,
|
|
)),
|
|
createElementVNode(`dd`, null, [
|
|
createTextVNode(
|
|
toDisplayString(
|
|
W(unref(I)?.invitee_count, !1),
|
|
),
|
|
1,
|
|
),
|
|
(r[4] ||= createElementVNode(
|
|
`small`,
|
|
null,
|
|
`人`,
|
|
-1,
|
|
)),
|
|
]),
|
|
]))
|
|
: createCommentVNode(``, !0),
|
|
]),
|
|
createElementVNode(`dl`, M, [
|
|
(openBlock(!0),
|
|
createElementBlock(
|
|
Fragment,
|
|
null,
|
|
renderList(
|
|
unref(U),
|
|
(t) => (
|
|
openBlock(),
|
|
createElementBlock(
|
|
`div`,
|
|
{
|
|
key: t.label,
|
|
class: `referral-stat`,
|
|
},
|
|
[
|
|
createElementVNode(
|
|
`dt`,
|
|
null,
|
|
toDisplayString(t.label),
|
|
1,
|
|
),
|
|
createElementVNode(`dd`, null, [
|
|
W(t.value) === `—`
|
|
? createCommentVNode(``, !0)
|
|
: (openBlock(),
|
|
createElementBlock(
|
|
`small`,
|
|
N,
|
|
`¥`,
|
|
)),
|
|
createTextVNode(
|
|
toDisplayString(W(t.value)),
|
|
1,
|
|
),
|
|
]),
|
|
],
|
|
)
|
|
),
|
|
),
|
|
128,
|
|
)),
|
|
]),
|
|
createElementVNode(`div`, P, [
|
|
(r[7] ||= createElementVNode(
|
|
`p`,
|
|
null,
|
|
`查看邀请记录与奖励结算进度`,
|
|
-1,
|
|
)),
|
|
createVNode(
|
|
f,
|
|
{
|
|
to: `/recommend`,
|
|
class: `referral-details`,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
...(r[6] ||= [
|
|
createTextVNode(`查看推介明细`, -1),
|
|
createElementVNode(
|
|
`i`,
|
|
{
|
|
class: `pi pi-angle-right`,
|
|
"aria-hidden": `true`,
|
|
},
|
|
null,
|
|
-1,
|
|
),
|
|
]),
|
|
]),
|
|
_: 1,
|
|
},
|
|
),
|
|
]),
|
|
]))
|
|
: (openBlock(),
|
|
createElementBlock(`div`, F, [
|
|
createElementVNode(
|
|
`h3`,
|
|
null,
|
|
toDisplayString(
|
|
unref(V)
|
|
? `尚未开通推介计划`
|
|
: `暂未开放推介申请`,
|
|
),
|
|
1,
|
|
),
|
|
createElementVNode(
|
|
`p`,
|
|
null,
|
|
toDisplayString(
|
|
unref(V)
|
|
? `开通后获取专属链接,邀请好友。你的邀请人数与推介奖励将在这里展示。`
|
|
: `目前暂不接受新的推介申请,可前往推介计划查看详情。`,
|
|
),
|
|
1,
|
|
),
|
|
createVNode(
|
|
f,
|
|
{
|
|
to: `/recommend`,
|
|
class: `home-button`,
|
|
},
|
|
{
|
|
default: withCtx(() => [
|
|
createTextVNode(
|
|
toDisplayString(
|
|
unref(V)
|
|
? `了解并开通`
|
|
: `查看推介计划`,
|
|
),
|
|
1,
|
|
),
|
|
]),
|
|
_: 1,
|
|
},
|
|
),
|
|
])),
|
|
],
|
|
8,
|
|
x,
|
|
)
|
|
);
|
|
}
|
|
);
|
|
},
|
|
}),
|
|
[[`__scopeId`, `data-v-8690c3a5`]],
|
|
),
|
|
{
|
|
__name: `HomeReferralPanel`,
|
|
},
|
|
);
|
|
export {};
|
|
export default I;
|
|
</script>
|