transaction.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const utils_auth = require("../../utils/auth.js");
  4. const utils_api = require("../../utils/api.js");
  5. const _sfc_main = {
  6. __name: "transaction",
  7. setup(__props) {
  8. const subscriptions = common_vendor.ref([]);
  9. const loading = common_vendor.ref(false);
  10. const isLoggedIn = common_vendor.ref(false);
  11. const checkLogin = () => {
  12. isLoggedIn.value = utils_auth.isLoggedIn();
  13. };
  14. const handleBack = () => {
  15. const pages = getCurrentPages();
  16. pages.length > 1 ? common_vendor.index.navigateBack() : common_vendor.index.switchTab({ url: "/pages/mine/mine" });
  17. };
  18. const loadSubscriptions = async () => {
  19. if (!isLoggedIn.value)
  20. return;
  21. loading.value = true;
  22. try {
  23. const res = await utils_api.getUserSubscriptions();
  24. if (res.code === 200) {
  25. subscriptions.value = res.data || [];
  26. }
  27. } catch (e) {
  28. console.error("加载订阅记录失败:", e);
  29. } finally {
  30. loading.value = false;
  31. }
  32. };
  33. common_vendor.onLoad(() => checkLogin());
  34. common_vendor.onMounted(() => {
  35. if (isLoggedIn.value)
  36. loadSubscriptions();
  37. });
  38. common_vendor.onShow(() => {
  39. checkLogin();
  40. if (isLoggedIn.value)
  41. loadSubscriptions();
  42. });
  43. return (_ctx, _cache) => {
  44. return common_vendor.e({
  45. a: common_vendor.o(handleBack),
  46. b: loading.value
  47. }, loading.value ? {} : subscriptions.value.length === 0 ? {} : {
  48. d: common_vendor.f(subscriptions.value, (item, index, i0) => {
  49. return common_vendor.e({
  50. a: common_vendor.t(item.poolType === 1 ? "⚡" : "📈"),
  51. b: common_vendor.t(item.poolName),
  52. c: common_vendor.t(item.isActive ? "生效中" : "已过期"),
  53. d: common_vendor.n(item.isActive ? "active" : "expired"),
  54. e: common_vendor.t(item.amount),
  55. f: common_vendor.t(item.startTime),
  56. g: common_vendor.t(item.expireTime),
  57. h: item.isActive
  58. }, item.isActive ? {
  59. i: common_vendor.t(item.remainDays)
  60. } : {}, {
  61. j: index
  62. });
  63. })
  64. }, {
  65. c: subscriptions.value.length === 0
  66. });
  67. };
  68. }
  69. };
  70. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-a901d1cb"], ["__file", "D:/program/gupiao-wx/src/pages/transaction/transaction.vue"]]);
  71. wx.createPage(MiniProgramPage);