person.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  4. __name: "person",
  5. setup(__props) {
  6. var _a;
  7. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  8. const user = common_vendor.ref({});
  9. const searchInfo = common_vendor.ref({});
  10. const list = common_vendor.ref([{ id: 1, name: "成都容城" }, { id: 1, name: "YYDS|脏三疯" }]);
  11. const pageNum = common_vendor.ref(1);
  12. const pageSize = common_vendor.ref(10);
  13. const total = common_vendor.ref(0);
  14. const config = common_vendor.ref({});
  15. const scrollTop = common_vendor.ref(0);
  16. const is_bottom = common_vendor.ref(false);
  17. common_vendor.onShow(async () => {
  18. await searchConfig();
  19. await searchUser();
  20. await search();
  21. });
  22. const searchConfig = async () => {
  23. config.value = common_vendor.index.getStorageSync("config");
  24. };
  25. const searchUser = async () => {
  26. user.value = common_vendor.index.getStorageSync("user");
  27. };
  28. const search = async () => {
  29. const info = {
  30. pageNum: pageNum.value,
  31. pageSize: pageSize.value,
  32. userId: user.value.id
  33. };
  34. const res = await $api("team/list", "GET", {
  35. ...info
  36. });
  37. if (res.code === 200) {
  38. list.value = res.rows;
  39. total.value = res.total;
  40. } else {
  41. common_vendor.index.showToast({
  42. title: res.msg || "",
  43. icon: "error"
  44. });
  45. }
  46. };
  47. const searchTeam = async () => {
  48. const info = {
  49. pageNum: pageNum.value,
  50. pageSize: pageSize.value
  51. };
  52. const res = await $api("team/list", "GET", {
  53. ...info,
  54. ...searchInfo
  55. });
  56. if (res.code === 200) {
  57. list.value = res.rows;
  58. total.value = res.total;
  59. } else {
  60. common_vendor.index.showToast({
  61. title: res.msg || "",
  62. icon: "error"
  63. });
  64. }
  65. };
  66. const toInput = (e) => {
  67. if (searchInfo.value.name)
  68. searchInfo.value.name = e.detail.value;
  69. searchInfo.value = {};
  70. clearPage();
  71. searchTeam();
  72. };
  73. const toSelect = (item) => {
  74. common_vendor.index.$emit("opponentInfo", item);
  75. common_vendor.index.navigateBack({
  76. delta: 1
  77. });
  78. };
  79. const toPage = () => {
  80. if (total.value > list.value.length) {
  81. common_vendor.index.showLoading({
  82. title: "加载中",
  83. mask: true
  84. });
  85. pageNum.value = pageNum.value + 1;
  86. pageSize.value = pageNum.value * 10;
  87. search();
  88. common_vendor.index.hideLoading();
  89. } else
  90. is_bottom.value = true;
  91. };
  92. const toScroll = (e) => {
  93. let up = scrollTop.value;
  94. scrollTop.value = e.detail.scrollTop;
  95. let num = Math.sign(up - e.detail.scrollTop);
  96. if (num == 1)
  97. is_bottom.value = false;
  98. };
  99. const clearPage = () => {
  100. list.value = [];
  101. pageNum.value = 1;
  102. pageSize.value = 10;
  103. };
  104. return (_ctx, _cache) => {
  105. return common_vendor.e({
  106. a: common_vendor.o([($event) => searchInfo.value.name = $event.detail.value, toInput]),
  107. b: searchInfo.value.name,
  108. c: common_vendor.f(list.value, (item, index, i0) => {
  109. return {
  110. a: item.logo || config.value.logoUrl,
  111. b: common_vendor.t(item.name || "暂无名称"),
  112. c: common_vendor.t(item.city || "未入驻"),
  113. d: common_vendor.t(item.win || 0),
  114. e: common_vendor.t(item.flat || 0),
  115. f: common_vendor.t(item.burden || 0),
  116. g: index,
  117. h: common_vendor.o(($event) => toSelect(item), index)
  118. };
  119. }),
  120. d: is_bottom.value
  121. }, is_bottom.value ? {
  122. e: common_vendor.t(config.value.bottomTitle || "到底了!")
  123. } : {}, {
  124. f: common_vendor.o(toPage),
  125. g: common_vendor.o(toScroll)
  126. });
  127. };
  128. }
  129. });
  130. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-3a2dd265"], ["__file", "D:/project/足球比赛/match_applet/pagesHome/create/person.vue"]]);
  131. wx.createPage(MiniProgramPage);