You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

"use strict";
const common_vendor = require("../../common/vendor.js");
const _sfc_main = {
data() {
return {
availablePoints: 140,
// 固定的个人可用积分
products: [
{ name: "提问转移", price: 25, description: "该商品允许用户将自己的提问转移到其他用户", message: "" },
// 产品1信息
{ name: "免密钥签到", price: 50, description: "购买此商品后,用户可以享受一次免密钥签到服务", message: "" },
// 产品2信息
{ name: "成绩+1", price: 200, description: "购买此商品后,用户可以获得额外的分数", message: "" }
// 产品3信息
]
};
},
methods: {
confirmPurchase(product) {
if (product.price > this.availablePoints) {
product.message = "积分不足,无法购买该商品!";
} else {
this.availablePoints -= product.price;
product.message = `购买成功!${product.name} 已购买,消耗 ${product.price} 积分。`;
}
}
}
};
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return {
a: common_vendor.t($data.availablePoints),
b: common_vendor.f($data.products, (product, index, i0) => {
return common_vendor.e({
a: common_vendor.t(product.name),
b: common_vendor.t(product.price),
c: common_vendor.t(product.description),
d: common_vendor.o(($event) => $options.confirmPurchase(product), index),
e: product.message
}, product.message ? {
f: common_vendor.t(product.message)
} : {}, {
g: index
});
})
};
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2a6aaf81"]]);
wx.createPage(MiniProgramPage);