activity.js 3.6 KB

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