2
This commit is contained in:
@@ -1,50 +1,87 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../../common/vendor.js");
|
||||
const common_config = require("../../common/config.js");
|
||||
const common_http = require("../../common/http.js");
|
||||
const common_assets = require("../../common/assets.js");
|
||||
const _sfc_main = {
|
||||
data() {
|
||||
return {
|
||||
isVip: false,
|
||||
expire: "",
|
||||
price: common_config.VIP_PRICE_PER_MONTH
|
||||
price: 0,
|
||||
benefits: []
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.loadVip();
|
||||
this.composeBenefits();
|
||||
},
|
||||
computed: {
|
||||
expireDisplay() {
|
||||
const s = String(this.expire || "");
|
||||
return s || "11年11月11日";
|
||||
},
|
||||
priceDisplay() {
|
||||
const n = Number(this.price);
|
||||
return Number.isFinite(n) && n > 0 ? n.toFixed(2) : "0.00";
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadVip() {
|
||||
composeBenefits() {
|
||||
this.benefits = [
|
||||
{ key: "history", title: "完整历史留存", desc: "无限期保留交易、库存与客户数据", icon: "/static/icons/icons8-graph-report-50.png" },
|
||||
{ key: "analysis", title: "高级统计面板", desc: "秒级汇总销售毛利,掌握生意节奏", icon: "/static/icons/icons8-profit-50.png" },
|
||||
{ key: "priority", title: "优先客服支持", desc: "遇到问题优先处理,响应更迅速", icon: "/static/icons/icons8-account-male-100.png" }
|
||||
];
|
||||
},
|
||||
async loadVip() {
|
||||
try {
|
||||
this.isVip = String(common_vendor.index.getStorageSync("USER_VIP_IS_VIP") || "false").toLowerCase() === "true";
|
||||
this.expire = common_vendor.index.getStorageSync("USER_VIP_END") || "";
|
||||
const data = await common_http.get("/api/vip/status");
|
||||
this.isVip = !!(data == null ? void 0 : data.isVip);
|
||||
this.expire = (data == null ? void 0 : data.expireAt) || "";
|
||||
if (typeof (data == null ? void 0 : data.price) === "number")
|
||||
this.price = data.price;
|
||||
} catch (e) {
|
||||
this.isVip = false;
|
||||
}
|
||||
},
|
||||
onPay() {
|
||||
common_vendor.index.showToast({ title: "静态页面演示:支付功能未接入", icon: "none" });
|
||||
async onPay() {
|
||||
try {
|
||||
await common_http.post("/api/vip/pay", {});
|
||||
common_vendor.index.showToast({ title: "已开通VIP", icon: "success" });
|
||||
await this.loadVip();
|
||||
} catch (e) {
|
||||
common_vendor.index.showToast({ title: String(e.message || "开通失败"), icon: "none" });
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
return common_vendor.e({
|
||||
a: common_vendor.t($data.isVip ? "VIP会员" : "成为VIP会员"),
|
||||
b: common_vendor.t($data.isVip ? "尊享专属特权" : "解锁更多权益"),
|
||||
c: common_vendor.t($data.isVip ? "VIP会员" : "普通用户"),
|
||||
d: $data.isVip ? 1 : "",
|
||||
e: $data.isVip
|
||||
a: common_assets._imports_0$3,
|
||||
b: common_vendor.t($data.isVip ? "VIP会员" : "升级 VIP 会员"),
|
||||
c: common_vendor.t($data.isVip ? "尊享完整数据与高效体验" : "开通后可查看全部历史数据并解锁高级功能"),
|
||||
d: common_vendor.t($data.isVip ? "已开通" : "普通用户"),
|
||||
e: $data.isVip ? 1 : "",
|
||||
f: $data.isVip
|
||||
}, $data.isVip ? {
|
||||
f: common_vendor.t($options.expireDisplay)
|
||||
} : {}, {
|
||||
g: !$data.isVip
|
||||
g: common_vendor.t($options.expireDisplay)
|
||||
} : {
|
||||
h: common_vendor.t($options.priceDisplay)
|
||||
}, {
|
||||
i: common_vendor.f($data.benefits, (item, k0, i0) => {
|
||||
return common_vendor.e({
|
||||
a: item.icon
|
||||
}, item.icon ? {
|
||||
b: item.icon
|
||||
} : {}, {
|
||||
c: common_vendor.t(item.title),
|
||||
d: common_vendor.t(item.desc),
|
||||
e: item.key
|
||||
});
|
||||
}),
|
||||
j: !$data.isVip
|
||||
}, !$data.isVip ? {
|
||||
h: common_vendor.t($data.price),
|
||||
i: common_vendor.o((...args) => $options.onPay && $options.onPay(...args))
|
||||
k: 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