90 lines
3.1 KiB
JavaScript
90 lines
3.1 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const common_http = require("../../common/http.js");
|
|
const common_assets = require("../../common/assets.js");
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
isVip: false,
|
|
expire: "",
|
|
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: {
|
|
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 {
|
|
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;
|
|
}
|
|
},
|
|
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_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 ? {
|
|
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 ? {
|
|
k: common_vendor.o((...args) => $options.onPay && $options.onPay(...args))
|
|
} : {});
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/my/vip.js.map
|