transaction.js 3.7 KB

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