activity.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. (_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. };
  31. const toInput = (e) => {
  32. if (searchInfo.value.name)
  33. searchInfo.value.name = e.detail.value;
  34. searchInfo.value = {};
  35. clearPage();
  36. search();
  37. };
  38. const toInfo = (item) => {
  39. common_vendor.index.navigateTo({
  40. url: `/pagesHome/activity/info?id=${item._id || item.id}&name=${item.name}`
  41. });
  42. };
  43. const toPage = () => {
  44. if (total.value > list.value.length) {
  45. common_vendor.index.showLoading({
  46. title: "加载中",
  47. mask: true
  48. });
  49. pageNum.value = pageNum.value + 1;
  50. pageSize.value = pageNum.value * 10;
  51. search();
  52. common_vendor.index.hideLoading();
  53. } else
  54. is_bottom.value = true;
  55. };
  56. const toScroll = (e) => {
  57. let up = scrollTop.value;
  58. scrollTop.value = e.detail.scrollTop;
  59. let num = Math.sign(up - e.detail.scrollTop);
  60. if (num == 1)
  61. is_bottom.value = false;
  62. };
  63. const clearPage = () => {
  64. list.value = [];
  65. pageNum.value = 1;
  66. pageSize.value = 10;
  67. };
  68. return (_ctx, _cache) => {
  69. return common_vendor.e({
  70. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  71. b: searchInfo.value.name,
  72. c: common_vendor.f(list.value, (item, index, i0) => {
  73. return {
  74. a: index
  75. };
  76. }),
  77. d: common_vendor.f(list.value, (item, index, i0) => {
  78. return {
  79. a: common_vendor.t(item.date || "暂无日期"),
  80. b: common_vendor.t(item.status_name || "暂无状态"),
  81. c: common_vendor.n(item.status == "0" ? "status0" : item.status == "1" ? "status1" : "status2"),
  82. d: common_vendor.t(item.name || "暂无活动名称"),
  83. e: common_vendor.t(item.red_name || "暂无红方名称"),
  84. f: item.red_logo || common_vendor.unref(config).logoUrl,
  85. g: common_vendor.t(item.red_score || 0),
  86. h: common_vendor.t(item.blue_score || 0),
  87. i: item.blue_logo || common_vendor.unref(config).logoUrl,
  88. j: common_vendor.t(item.blue_name || "暂无蓝方名称"),
  89. k: index,
  90. l: common_vendor.o(($event) => toInfo(item), index)
  91. };
  92. }),
  93. e: is_bottom.value
  94. }, is_bottom.value ? {
  95. f: common_vendor.t(common_vendor.unref(config).bottomTitle || "到底了!")
  96. } : {}, {
  97. g: common_vendor.o(toPage),
  98. h: common_vendor.o(toScroll)
  99. });
  100. };
  101. }
  102. });
  103. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8f22acf3"], ["__file", "D:/project/足球比赛/match_applet/pages/home/components/activity.vue"]]);
  104. wx.createComponent(Component);