activity.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 statusList = common_vendor.ref([]);
  20. const scrollTop = common_vendor.ref(0);
  21. const is_bottom = common_vendor.ref(false);
  22. const { config } = common_vendor.toRefs(props);
  23. common_vendor.onShow(async () => {
  24. await searchUser();
  25. await search();
  26. });
  27. const searchUser = async () => {
  28. user.value = common_vendor.index.getStorageSync("user");
  29. let res;
  30. res = await $api(`dict/data/list`, "GET", { dictType: "sys_game_status", status: "0" });
  31. if (res.code === 200 && res.total > 0)
  32. statusList.value = res.rows;
  33. };
  34. const search = async () => {
  35. const info = {
  36. pageNum: pageNum.value,
  37. pageSize: pageSize.value,
  38. userId: user.value.id
  39. };
  40. const res = await $api("game/list", "GET", {
  41. ...info,
  42. ...searchInfo.value
  43. });
  44. if (res.code === 200) {
  45. list.value = res.rows;
  46. total.value = res.total;
  47. } else {
  48. common_vendor.index.showToast({
  49. title: res.msg || "",
  50. icon: "error"
  51. });
  52. }
  53. };
  54. const toInput = (e) => {
  55. if (searchInfo.value.name)
  56. searchInfo.value.name = e.detail.value;
  57. searchInfo.value = {};
  58. clearPage();
  59. search();
  60. };
  61. const toInfo = (item) => {
  62. common_vendor.index.navigateTo({
  63. url: `/pagesHome/activity/info?id=${item._id || item.id}&name=${item.name || ""}`
  64. });
  65. };
  66. const getDayOfWeek = (dateString) => {
  67. if (dateString) {
  68. const date = new Date(dateString);
  69. const dayOfWeek = date.getDay();
  70. const weekdays = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
  71. return weekdays[dayOfWeek];
  72. } else
  73. return "暂无日期";
  74. };
  75. const getStatus = (value) => {
  76. if (value) {
  77. const data = statusList.value.find((i) => i.dictValue == value);
  78. if (data)
  79. return data.dictLabel;
  80. } else
  81. return "暂无状态";
  82. };
  83. const toPage = () => {
  84. if (total.value > list.value.length) {
  85. common_vendor.index.showLoading({
  86. title: "加载中",
  87. mask: true
  88. });
  89. pageNum.value = pageNum.value + 1;
  90. pageSize.value = pageNum.value * 10;
  91. search();
  92. common_vendor.index.hideLoading();
  93. } else
  94. is_bottom.value = true;
  95. };
  96. const toScroll = (e) => {
  97. let up = scrollTop.value;
  98. scrollTop.value = e.detail.scrollTop;
  99. let num = Math.sign(up - e.detail.scrollTop);
  100. if (num == 1)
  101. is_bottom.value = false;
  102. };
  103. const clearPage = () => {
  104. list.value = [];
  105. pageNum.value = 1;
  106. pageSize.value = 10;
  107. };
  108. return (_ctx, _cache) => {
  109. return common_vendor.e({
  110. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  111. b: searchInfo.value.name,
  112. c: common_vendor.f(list.value, (item, index, i0) => {
  113. return {
  114. a: index
  115. };
  116. }),
  117. d: common_vendor.f(list.value, (item, index, i0) => {
  118. var _a2, _b, _c, _d, _e, _f;
  119. return common_vendor.e({
  120. a: common_vendor.t(common_vendor.unref(common_vendor.hooks)(item.startTime).format("MM-DD") || "暂无日期"),
  121. b: common_vendor.t(getDayOfWeek(item.startTime)),
  122. c: common_vendor.t(getStatus(item.status)),
  123. d: common_vendor.n(item.status == "0" ? "status0" : item.status == "1" ? "status1" : item.status == "2" ? "status2" : "status3"),
  124. e: item.type == "0"
  125. }, item.type == "0" ? {
  126. f: common_vendor.t(((_a2 = item == null ? void 0 : item.matchInfo) == null ? void 0 : _a2.title) || "友谊赛")
  127. } : {
  128. g: common_vendor.t(((_b = item == null ? void 0 : item.leagueInfo) == null ? void 0 : _b.title) || "联赛")
  129. }, {
  130. h: common_vendor.t(((_c = item == null ? void 0 : item.redInfo) == null ? void 0 : _c.name) || "暂无红方名称"),
  131. i: ((_d = item == null ? void 0 : item.redInfo) == null ? void 0 : _d.logo) || common_vendor.unref(config).logoUrl,
  132. j: common_vendor.t(item.redScore || 0),
  133. k: common_vendor.t(item.blueScore || 0),
  134. l: ((_e = item == null ? void 0 : item.blueInfo) == null ? void 0 : _e.logo) || common_vendor.unref(config).logoUrl,
  135. m: common_vendor.t(((_f = item == null ? void 0 : item.blueInfo) == null ? void 0 : _f.name) || "暂无蓝方名称"),
  136. n: index,
  137. o: common_vendor.o(($event) => toInfo(item), index)
  138. });
  139. }),
  140. e: is_bottom.value
  141. }, is_bottom.value ? {
  142. f: common_vendor.t(common_vendor.unref(config).bottomTitle || "到底了!")
  143. } : {}, {
  144. g: common_vendor.o(toPage),
  145. h: common_vendor.o(toScroll)
  146. });
  147. };
  148. }
  149. });
  150. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8f22acf3"], ["__file", "D:/project/足球比赛/match_applet/pages/home/components/activity.vue"]]);
  151. wx.createComponent(Component);