list.js 4.5 KB

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