transaction.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_auth = require("../../utils/auth.js");
  4. require("../../utils/api.js");
  5. const _sfc_main = {
  6. __name: "transaction",
  7. setup(__props) {
  8. const subscriptions = common_vendor.ref([]);
  9. const isLoggedIn = common_vendor.ref(false);
  10. const checkLogin = () => {
  11. isLoggedIn.value = utils_auth.isLoggedIn();
  12. console.log("[订阅记录] 登录状态:", isLoggedIn.value);
  13. };
  14. const handleBack = () => {
  15. const pages = getCurrentPages();
  16. if (pages.length > 1) {
  17. common_vendor.index.navigateBack();
  18. } else {
  19. common_vendor.index.switchTab({
  20. url: "/pages/mine/mine"
  21. });
  22. }
  23. };
  24. const formatDateTime = (timestamp) => {
  25. const date = new Date(timestamp);
  26. const year = date.getFullYear();
  27. const month = String(date.getMonth() + 1).padStart(2, "0");
  28. const day = String(date.getDate()).padStart(2, "0");
  29. const hours = String(date.getHours()).padStart(2, "0");
  30. const minutes = String(date.getMinutes()).padStart(2, "0");
  31. return `${year}-${month}-${day} ${hours}:${minutes}`;
  32. };
  33. const loadSubscriptions = () => {
  34. try {
  35. const now = Date.now();
  36. const allSubscriptions = [];
  37. const poolPurchase = common_vendor.index.getStorageSync("pool_purchase");
  38. if (poolPurchase) {
  39. allSubscriptions.push({
  40. poolType: "pool",
  41. poolName: "超短精选池",
  42. planName: poolPurchase.plan === "daily" ? "日订阅" : "周套餐",
  43. amount: poolPurchase.plan === "daily" ? "18" : "98",
  44. purchaseTime: poolPurchase.purchaseTime,
  45. expireTime: poolPurchase.expireTime,
  46. isActive: now < poolPurchase.expireTime
  47. });
  48. }
  49. const strongPurchase = common_vendor.index.getStorageSync("strong_pool_purchase");
  50. if (strongPurchase) {
  51. allSubscriptions.push({
  52. poolType: "strong",
  53. poolName: "强势趋势池",
  54. planName: "年订阅",
  55. amount: "98",
  56. purchaseTime: strongPurchase.purchaseTime,
  57. expireTime: strongPurchase.expireTime,
  58. isActive: now < strongPurchase.expireTime
  59. });
  60. }
  61. subscriptions.value = allSubscriptions.sort((a, b) => b.purchaseTime - a.purchaseTime);
  62. } catch (e) {
  63. console.error("加载订阅记录失败:", e);
  64. subscriptions.value = [];
  65. }
  66. };
  67. common_vendor.onLoad(() => {
  68. checkLogin();
  69. });
  70. common_vendor.onMounted(() => {
  71. loadSubscriptions();
  72. });
  73. common_vendor.onShow(() => {
  74. checkLogin();
  75. loadSubscriptions();
  76. });
  77. return (_ctx, _cache) => {
  78. return common_vendor.e({
  79. a: common_vendor.o(handleBack),
  80. b: common_vendor.f(subscriptions.value, (item, index, i0) => {
  81. return {
  82. a: common_vendor.t(item.poolType === "pool" ? "⚡" : "📈"),
  83. b: common_vendor.t(item.poolName),
  84. c: common_vendor.t(item.isActive ? "生效中" : "已过期"),
  85. d: common_vendor.n(item.isActive ? "status-active" : "status-expired"),
  86. e: common_vendor.t(item.planName),
  87. f: common_vendor.t(item.amount),
  88. g: common_vendor.t(formatDateTime(item.purchaseTime)),
  89. h: common_vendor.t(formatDateTime(item.expireTime)),
  90. i: index
  91. };
  92. }),
  93. c: subscriptions.value.length === 0
  94. }, subscriptions.value.length === 0 ? {} : {});
  95. };
  96. }
  97. };
  98. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a901d1cb"], ["__file", "D:/program/gupiao-wx/src/pages/transaction/transaction.vue"]]);
  99. wx.createPage(MiniProgramPage);