team.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "team",
  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: 2, 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("team/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. else
  53. searchInfo.value = {};
  54. clearPage();
  55. search();
  56. };
  57. const toInfo = (item) => {
  58. common_vendor.index.navigateTo({
  59. url: `/pagesHome/team/info?id=${item._id || item.id}`
  60. });
  61. };
  62. const toPage = () => {
  63. if (total.value > list.value.length) {
  64. common_vendor.index.showLoading({
  65. title: "加载中",
  66. mask: true
  67. });
  68. pageNum.value = pageNum.value + 1;
  69. pageSize.value = pageNum.value * 10;
  70. search();
  71. common_vendor.index.hideLoading();
  72. } else
  73. is_bottom.value = true;
  74. };
  75. const toScroll = (e) => {
  76. let up = scrollTop.value;
  77. scrollTop.value = e.detail.scrollTop;
  78. let num = Math.sign(up - e.detail.scrollTop);
  79. if (num == 1)
  80. is_bottom.value = false;
  81. };
  82. const clearPage = () => {
  83. list.value = [];
  84. pageNum.value = 1;
  85. pageSize.value = 10;
  86. page.value = 0;
  87. };
  88. return (_ctx, _cache) => {
  89. return common_vendor.e({
  90. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  91. b: searchInfo.value.name,
  92. c: common_vendor.f(list.value, (item, index, i0) => {
  93. return {
  94. a: item.logo || common_vendor.unref(config).logoUrl,
  95. b: common_vendor.t(item.name || "暂无名称"),
  96. c: common_vendor.t(item.label || "队长"),
  97. d: common_vendor.n(item.user_type == "0" ? "label_1" : "label_2"),
  98. e: common_vendor.t(item.activity || "暂无活动"),
  99. f: index,
  100. g: common_vendor.o(($event) => toInfo(item), index)
  101. };
  102. }),
  103. d: is_bottom.value
  104. }, is_bottom.value ? {
  105. e: common_vendor.t(common_vendor.unref(config).bottomTitle || "到底了!")
  106. } : {}, {
  107. f: common_vendor.o(toPage),
  108. g: common_vendor.o(toScroll)
  109. });
  110. };
  111. }
  112. });
  113. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-47929ca4"], ["__file", "D:/project/足球比赛/match_applet/pages/home/components/team.vue"]]);
  114. wx.createComponent(Component);