3
This commit is contained in:
@@ -8,21 +8,67 @@ const _sfc_main = {
|
||||
isVip: false,
|
||||
expire: "",
|
||||
price: 0,
|
||||
benefits: []
|
||||
benefits: [],
|
||||
normalAdmin: { isNormalAdmin: false, applicationStatus: "none" }
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.loadVip();
|
||||
this.loadNormalAdminStatus();
|
||||
this.composeBenefits();
|
||||
},
|
||||
computed: {
|
||||
expireDisplay() {
|
||||
const s = String(this.expire || "");
|
||||
return s || "11年11月11日";
|
||||
const v = this.expire;
|
||||
if (v === null || v === void 0)
|
||||
return "";
|
||||
if (typeof v === "number") {
|
||||
const d = new Date(v);
|
||||
if (!isNaN(d.getTime())) {
|
||||
const y = d.getFullYear();
|
||||
const m2 = String(d.getMonth() + 1).padStart(2, "0");
|
||||
const dd = String(d.getDate()).padStart(2, "0");
|
||||
return `${y}-${m2}-${dd}`;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
const s = String(v);
|
||||
const m = s.match(/^(\d{4}-\d{2}-\d{2})/);
|
||||
if (m)
|
||||
return m[1];
|
||||
const idx = s.search(/[ T]/);
|
||||
if (idx > 0) {
|
||||
const head = s.slice(0, idx);
|
||||
if (head)
|
||||
return head;
|
||||
}
|
||||
const d2 = new Date(s);
|
||||
if (!isNaN(d2.getTime())) {
|
||||
const y = d2.getFullYear();
|
||||
const m2 = String(d2.getMonth() + 1).padStart(2, "0");
|
||||
const dd2 = String(d2.getDate()).padStart(2, "0");
|
||||
return `${y}-${m2}-${dd2}`;
|
||||
}
|
||||
return s;
|
||||
},
|
||||
priceDisplay() {
|
||||
const n = Number(this.price);
|
||||
return Number.isFinite(n) && n > 0 ? n.toFixed(2) : "0.00";
|
||||
},
|
||||
applyDisabled() {
|
||||
var _a, _b;
|
||||
const s = String(((_a = this.normalAdmin) == null ? void 0 : _a.applicationStatus) || "none");
|
||||
return !!(((_b = this.normalAdmin) == null ? void 0 : _b.isNormalAdmin) || s === "approved" || s === "pending");
|
||||
},
|
||||
applyBtnText() {
|
||||
var _a, _b, _c;
|
||||
if (((_a = this.normalAdmin) == null ? void 0 : _a.isNormalAdmin) || ((_b = this.normalAdmin) == null ? void 0 : _b.applicationStatus) === "approved")
|
||||
return "已通过";
|
||||
if (((_c = this.normalAdmin) == null ? void 0 : _c.applicationStatus) === "pending")
|
||||
return "审核中";
|
||||
if (!this.isVip)
|
||||
return "仅限VIP";
|
||||
return "提交申请";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -44,6 +90,17 @@ const _sfc_main = {
|
||||
this.isVip = false;
|
||||
}
|
||||
},
|
||||
async loadNormalAdminStatus() {
|
||||
try {
|
||||
const data = await common_http.get("/api/normal-admin/application/status");
|
||||
this.normalAdmin = {
|
||||
isNormalAdmin: !!(data == null ? void 0 : data.isNormalAdmin),
|
||||
applicationStatus: String((data == null ? void 0 : data.applicationStatus) || "none")
|
||||
};
|
||||
} catch (e) {
|
||||
this.normalAdmin = { isNormalAdmin: false, applicationStatus: "none" };
|
||||
}
|
||||
},
|
||||
async onPay() {
|
||||
try {
|
||||
await common_http.post("/api/vip/pay", {});
|
||||
@@ -52,6 +109,20 @@ const _sfc_main = {
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: String(e.message || "开通失败"), icon: "none" });
|
||||
}
|
||||
},
|
||||
async onApplyNormalAdmin() {
|
||||
var _a, _b, _c;
|
||||
if (this.applyDisabled) {
|
||||
const msg = ((_a = this.normalAdmin) == null ? void 0 : _a.isNormalAdmin) || ((_b = this.normalAdmin) == null ? void 0 : _b.applicationStatus) === "approved" ? "已通过,无需重复申请" : ((_c = this.normalAdmin) == null ? void 0 : _c.applicationStatus) === "pending" ? "审核中,请耐心等待" : "不可申请";
|
||||
return common_vendor.index.showToast({ title: msg, icon: "none" });
|
||||
}
|
||||
try {
|
||||
await common_http.post("/api/normal-admin/apply", { remark: "从我的-会员发起申请" });
|
||||
common_vendor.index.showToast({ title: "申请已提交", icon: "success" });
|
||||
await this.loadNormalAdminStatus();
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: String(e.message || "申请失败"), icon: "none" });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -79,9 +150,17 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
e: item.key
|
||||
});
|
||||
}),
|
||||
j: !$data.isVip
|
||||
j: $data.isVip
|
||||
}, $data.isVip ? {
|
||||
k: common_vendor.t($options.applyBtnText),
|
||||
l: common_vendor.n({
|
||||
disabled: $options.applyDisabled
|
||||
}),
|
||||
m: common_vendor.o((...args) => $options.onApplyNormalAdmin && $options.onApplyNormalAdmin(...args))
|
||||
} : {}, {
|
||||
n: !$data.isVip
|
||||
}, !$data.isVip ? {
|
||||
k: common_vendor.o((...args) => $options.onPay && $options.onPay(...args))
|
||||
o: common_vendor.o((...args) => $options.onPay && $options.onPay(...args))
|
||||
} : {});
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
Reference in New Issue
Block a user