vip.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_api = require("../../utils/api.js");
  4. const _sfc_main = {
  5. data() {
  6. return {
  7. selectedPlan: 0,
  8. vipPlans: [],
  9. loading: false
  10. };
  11. },
  12. computed: {
  13. selectedPlanInfo() {
  14. return this.vipPlans[this.selectedPlan] || {};
  15. }
  16. },
  17. onLoad() {
  18. this.loadVipPlans();
  19. },
  20. methods: {
  21. async loadVipPlans() {
  22. this.loading = true;
  23. try {
  24. const res = await utils_api.getVipPlans();
  25. if (res && res.code === 200 && res.data) {
  26. this.vipPlans = res.data;
  27. } else {
  28. this.vipPlans = [
  29. {
  30. type: "month",
  31. name: "月卡VIP",
  32. price: 30,
  33. desc: "适合短期阅读",
  34. benefits: ["无限阅读", "免费听书", "专属客服"]
  35. },
  36. {
  37. type: "quarter",
  38. name: "季卡VIP",
  39. price: 80,
  40. desc: "超值优惠",
  41. benefits: ["无限阅读", "免费听书", "专属客服", "优先更新"]
  42. },
  43. {
  44. type: "year",
  45. name: "年卡VIP",
  46. price: 288,
  47. desc: "最超值选择",
  48. benefits: ["无限阅读", "免费听书", "专属客服", "优先更新", "专属活动"]
  49. }
  50. ];
  51. }
  52. } catch (error) {
  53. common_vendor.index.__f__("error", "at pages/vip/vip.vue:97", "加载VIP套餐失败:", error);
  54. this.vipPlans = [
  55. {
  56. type: "month",
  57. name: "月卡VIP",
  58. price: 30,
  59. desc: "适合短期阅读",
  60. benefits: ["无限阅读", "免费听书", "专属客服"]
  61. },
  62. {
  63. type: "quarter",
  64. name: "季卡VIP",
  65. price: 80,
  66. desc: "超值优惠",
  67. benefits: ["无限阅读", "免费听书", "专属客服", "优先更新"]
  68. },
  69. {
  70. type: "year",
  71. name: "年卡VIP",
  72. price: 288,
  73. desc: "最超值选择",
  74. benefits: ["无限阅读", "免费听书", "专属客服", "优先更新", "专属活动"]
  75. }
  76. ];
  77. } finally {
  78. this.loading = false;
  79. }
  80. },
  81. goBack() {
  82. common_vendor.index.navigateBack();
  83. },
  84. selectPlan(index) {
  85. this.selectedPlan = index;
  86. },
  87. goToPayment() {
  88. if (!this.selectedPlanInfo || !this.selectedPlanInfo.type) {
  89. common_vendor.index.showToast({
  90. title: "请选择VIP套餐",
  91. icon: "none"
  92. });
  93. return;
  94. }
  95. const plan = this.selectedPlanInfo;
  96. common_vendor.index.navigateTo({
  97. url: `/pages/payment/payment?planId=${this.selectedPlan}&planType=${plan.type}&planName=${encodeURIComponent(plan.name)}&price=${plan.price}`
  98. });
  99. }
  100. }
  101. };
  102. function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  103. return {
  104. a: common_vendor.o((...args) => $options.goBack && $options.goBack(...args)),
  105. b: common_vendor.f($data.vipPlans, (plan, index, i0) => {
  106. return {
  107. a: common_vendor.t(plan.name),
  108. b: common_vendor.t(plan.price),
  109. c: common_vendor.t(plan.desc),
  110. d: common_vendor.f(plan.benefits, (benefit, i, i1) => {
  111. return {
  112. a: common_vendor.t(benefit),
  113. b: i
  114. };
  115. }),
  116. e: index,
  117. f: $data.selectedPlan === index ? 1 : "",
  118. g: common_vendor.o(($event) => $options.selectPlan(index), index)
  119. };
  120. }),
  121. c: common_vendor.t($options.selectedPlanInfo.price),
  122. d: common_vendor.o((...args) => $options.goToPayment && $options.goToPayment(...args))
  123. };
  124. }
  125. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-61fb1047"]]);
  126. wx.createPage(MiniProgramPage);
  127. //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/vip/vip.js.map