activity.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "activity",
  5. props: {
  6. config: { type: Object, default: () => {
  7. } }
  8. },
  9. setup(__props) {
  10. var _a;
  11. const props = __props;
  12. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  13. const user = common_vendor.ref({});
  14. const searchInfo = common_vendor.ref({});
  15. const list = common_vendor.ref([{ id: 1, name: "测试球队" }, { id: 1, name: "肝帝集团队" }]);
  16. const pageNum = common_vendor.ref(1);
  17. const pageSize = common_vendor.ref(10);
  18. const total = common_vendor.ref(0);
  19. const scrollTop = common_vendor.ref(0);
  20. const is_bottom = common_vendor.ref(false);
  21. const { config } = common_vendor.toRefs(props);
  22. common_vendor.onShow(async () => {
  23. await searchUser();
  24. await search();
  25. });
  26. const searchUser = async () => {
  27. user.value = common_vendor.index.getStorageSync("user");
  28. };
  29. const search = async () => {
  30. const info = {
  31. pageNum: pageNum.value,
  32. pageSize: pageSize.value,
  33. userId: user.value.id
  34. };
  35. const res = await $api("activity/list", "GET", {
  36. ...info,
  37. ...searchInfo.value
  38. });
  39. if (res.code === 200) {
  40. list.value = res.rows;
  41. total.value = res.total;
  42. } else {
  43. common_vendor.index.showToast({
  44. title: res.msg || "",
  45. icon: "error"
  46. });
  47. }
  48. };
  49. const toInput = (e) => {
  50. if (searchInfo.value.name)
  51. searchInfo.value.name = e.detail.value;
  52. searchInfo.value = {};
  53. clearPage();
  54. search();
  55. };
  56. const toInfo = (item) => {
  57. common_vendor.index.navigateTo({
  58. url: `/pagesHome/activity/info?id=${item._id || item.id}&name=${item.name}`
  59. });
  60. };
  61. const toPage = () => {
  62. if (total.value > list.value.length) {
  63. common_vendor.index.showLoading({
  64. title: "加载中",
  65. mask: true
  66. });
  67. pageNum.value = pageNum.value + 1;
  68. pageSize.value = pageNum.value * 10;
  69. search();
  70. common_vendor.index.hideLoading();
  71. } else
  72. is_bottom.value = true;
  73. };
  74. const toScroll = (e) => {
  75. let up = scrollTop.value;
  76. scrollTop.value = e.detail.scrollTop;
  77. let num = Math.sign(up - e.detail.scrollTop);
  78. if (num == 1)
  79. is_bottom.value = false;
  80. };
  81. const clearPage = () => {
  82. list.value = [];
  83. pageNum.value = 1;
  84. pageSize.value = 10;
  85. page.value = 0;
  86. };
  87. return (_ctx, _cache) => {
  88. return common_vendor.e({
  89. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  90. b: searchInfo.value.name,
  91. c: common_vendor.f(list.value, (item, index, i0) => {
  92. return {
  93. a: index
  94. };
  95. }),
  96. d: common_vendor.f(list.value, (item, index, i0) => {
  97. return {
  98. a: common_vendor.t(item.date || "暂无日期"),
  99. b: common_vendor.t(item.status_name || "暂无状态"),
  100. c: common_vendor.n(item.status == "0" ? "status0" : item.status == "1" ? "status1" : "status2"),
  101. d: common_vendor.t(item.name || "暂无活动名称"),
  102. e: common_vendor.t(item.red_name || "暂无红方名称"),
  103. f: item.red_logo || common_vendor.unref(config).logoUrl,
  104. g: common_vendor.t(item.red_score || 0),
  105. h: common_vendor.t(item.blue_score || 0),
  106. i: item.blue_logo || common_vendor.unref(config).logoUrl,
  107. j: common_vendor.t(item.blue_name || "暂无蓝方名称"),
  108. k: index,
  109. l: common_vendor.o(($event) => toInfo(item), index)
  110. };
  111. }),
  112. e: is_bottom.value
  113. }, is_bottom.value ? {
  114. f: common_vendor.t(common_vendor.unref(config).bottomTitle || "到底了!")
  115. } : {}, {
  116. g: common_vendor.o(toPage),
  117. h: common_vendor.o(toScroll)
  118. });
  119. };
  120. }
  121. });
  122. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8f22acf3"], ["__file", "D:/project/足球比赛/match_applet/pages/home/components/activity.vue"]]);
  123. wx.createComponent(Component);