list.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_up_list_item2 = common_vendor.resolveComponent("up-list-item");
  5. const _easycom_up_list2 = common_vendor.resolveComponent("up-list");
  6. (_easycom_up_list_item2 + _easycom_up_list2)();
  7. }
  8. const _easycom_up_list_item = () => "../../node-modules/uview-plus/components/u-list-item/u-list-item.js";
  9. const _easycom_up_list = () => "../../node-modules/uview-plus/components/u-list/u-list.js";
  10. if (!Math) {
  11. (_easycom_up_list_item + _easycom_up_list)();
  12. }
  13. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  14. __name: "list",
  15. setup(__props) {
  16. const $api = common_vendor.inject("$api");
  17. common_vendor.inject("$config");
  18. const config = common_vendor.ref({ logo: [], file: [] });
  19. const list = common_vendor.ref([]);
  20. const total = common_vendor.ref(0);
  21. const skip = common_vendor.ref(0);
  22. const limit = common_vendor.ref(5);
  23. const page = common_vendor.ref(0);
  24. const is_bottom = common_vendor.ref(false);
  25. const typeList = common_vendor.ref([]);
  26. const statusList = common_vendor.ref([]);
  27. const user = common_vendor.computed(() => {
  28. return common_vendor.index.getStorageSync("user");
  29. });
  30. common_vendor.onShow(async () => {
  31. await searchConfig();
  32. await searchOther();
  33. await search();
  34. });
  35. common_vendor.onPullDownRefresh(async () => {
  36. await clearPage();
  37. await search();
  38. common_vendor.index.stopPullDownRefresh();
  39. });
  40. const searchConfig = async () => {
  41. config.value = common_vendor.index.getStorageSync("config");
  42. };
  43. const searchOther = async () => {
  44. let res;
  45. res = await $api(`dictData`, "GET", { code: "opinionType", is_use: "0" });
  46. if (res.errcode === 0)
  47. typeList.value = res.data;
  48. res = await $api(`dictData`, "GET", { code: "opinionStatus", is_use: "0" });
  49. if (res.errcode === 0)
  50. statusList.value = res.data;
  51. };
  52. const search = async () => {
  53. const info = {
  54. skip: skip.value,
  55. limit: limit.value,
  56. user: user.value._id
  57. };
  58. const res = await $api("opinion", "GET", info);
  59. if (res.errcode === 0) {
  60. list.value = list.value.concat(res.data);
  61. total.value = res.total;
  62. } else {
  63. common_vendor.index.showToast({
  64. title: res.errmsg || "",
  65. icon: "error"
  66. });
  67. }
  68. };
  69. const getDict = (data, model) => {
  70. let res;
  71. if (model == "status")
  72. res = statusList.value.find((f) => f.value == data);
  73. else if (model == "type")
  74. res = typeList.value.find((f) => f.value == data);
  75. return res.label || "暂无";
  76. };
  77. const scrolltolower = () => {
  78. if (total.value > list.value.length) {
  79. common_vendor.index.showLoading({
  80. title: "加载中",
  81. mask: true
  82. });
  83. page.value = page.value + 1;
  84. skip.value = page.value * limit.value;
  85. search();
  86. common_vendor.index.hideLoading();
  87. } else
  88. is_bottom.value = true;
  89. };
  90. const clearPage = () => {
  91. list.value = [];
  92. skip.value = 0;
  93. limit.value = 6;
  94. page.value = 0;
  95. };
  96. return (_ctx, _cache) => {
  97. return common_vendor.e({
  98. a: common_vendor.f(list.value, (item, index, i0) => {
  99. return {
  100. a: common_vendor.t(getDict(item.type, "type")),
  101. b: common_vendor.t(item.brief || "暂无"),
  102. c: common_vendor.t(item.time || "暂无"),
  103. d: common_vendor.t(getDict(item.status, "status")),
  104. e: common_vendor.n(item.status == "0" ? "red" : ""),
  105. f: index,
  106. g: "c9b53715-1-" + i0 + ",c9b53715-0"
  107. };
  108. }),
  109. b: common_vendor.o(scrolltolower),
  110. c: is_bottom.value
  111. }, is_bottom.value ? {
  112. d: common_vendor.t(config.value.bottom_title || "没有更多了!")
  113. } : {});
  114. };
  115. }
  116. });
  117. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-c9b53715"], ["__file", "D:/project/学吧/learn_applet/pagesMy/opinion/list.vue"]]);
  118. wx.createPage(MiniProgramPage);