team.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. isUse: "Y"
  35. };
  36. const res = await $api("team/list", "GET", {
  37. ...info,
  38. ...searchInfo.value
  39. });
  40. if (res.code === 200) {
  41. list.value = res.rows;
  42. total.value = res.total;
  43. } else {
  44. common_vendor.index.showToast({
  45. title: res.msg || "",
  46. icon: "error"
  47. });
  48. }
  49. };
  50. const toInput = (e) => {
  51. if (searchInfo.value.name)
  52. searchInfo.value.name = e.detail.value;
  53. else
  54. searchInfo.value = {};
  55. clearPage();
  56. search();
  57. };
  58. const toInfo = (item) => {
  59. common_vendor.index.navigateTo({
  60. url: `/pagesHome/team/info?id=${item._id || item.id}`
  61. });
  62. };
  63. const toPage = () => {
  64. if (total.value > list.value.length) {
  65. common_vendor.index.showLoading({
  66. title: "加载中",
  67. mask: true
  68. });
  69. pageNum.value = pageNum.value + 1;
  70. pageSize.value = pageNum.value * 10;
  71. search();
  72. common_vendor.index.hideLoading();
  73. } else
  74. is_bottom.value = true;
  75. };
  76. const toScroll = (e) => {
  77. let up = scrollTop.value;
  78. scrollTop.value = e.detail.scrollTop;
  79. let num = Math.sign(up - e.detail.scrollTop);
  80. if (num == 1)
  81. is_bottom.value = false;
  82. };
  83. const clearPage = () => {
  84. list.value = [];
  85. pageNum.value = 1;
  86. pageSize.value = 10;
  87. page.value = 0;
  88. };
  89. return (_ctx, _cache) => {
  90. return common_vendor.e({
  91. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  92. b: searchInfo.value.name,
  93. c: common_vendor.f(list.value, (item, index, i0) => {
  94. return {
  95. a: item.logo || common_vendor.unref(config).logoUrl,
  96. b: common_vendor.t(item.name || "暂无名称"),
  97. c: common_vendor.t(item.userId == user.value.id ? "队长" : "队员"),
  98. d: common_vendor.n(item.userId == user.value.id ? "label_1" : "label_2"),
  99. e: common_vendor.t(item.activity || "暂无活动"),
  100. f: index,
  101. g: common_vendor.o(($event) => toInfo(item), index)
  102. };
  103. }),
  104. d: is_bottom.value
  105. }, is_bottom.value ? {
  106. e: common_vendor.t(common_vendor.unref(config).bottomTitle || "到底了!")
  107. } : {}, {
  108. f: common_vendor.o(toPage),
  109. g: common_vendor.o(toScroll)
  110. });
  111. };
  112. }
  113. });
  114. const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-47929ca4"], ["__file", "D:/project/足球比赛/match_applet/pages/home/components/team.vue"]]);
  115. wx.createComponent(Component);