index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_u_search2 = common_vendor.resolveComponent("u-search");
  5. _easycom_u_search2();
  6. }
  7. const _easycom_u_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js";
  8. if (!Math) {
  9. _easycom_u_search();
  10. }
  11. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  12. __name: "index",
  13. setup(__props) {
  14. var _a, _b;
  15. const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  16. (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
  17. const config = common_vendor.ref({ logoUrl: [] });
  18. const list = common_vendor.ref([]);
  19. const total = common_vendor.ref(0);
  20. const skip = common_vendor.ref(0);
  21. const limit = common_vendor.ref(6);
  22. const page = common_vendor.ref(0);
  23. const is_bottom = common_vendor.ref(false);
  24. common_vendor.ref(0);
  25. common_vendor.onShow(async () => {
  26. await searchConfig();
  27. await clearPage();
  28. await search();
  29. });
  30. common_vendor.onPullDownRefresh(async () => {
  31. await clearPage();
  32. await search();
  33. common_vendor.index.stopPullDownRefresh();
  34. });
  35. const searchConfig = async () => {
  36. config.value = common_vendor.index.getStorageSync("config");
  37. };
  38. const search = async () => {
  39. const info = {
  40. skip: skip.value,
  41. limit: limit.value,
  42. status: "0"
  43. };
  44. const res = await $api("car", "GET", info);
  45. if (res.errcode === 0) {
  46. list.value = list.value.concat(res.data);
  47. total.value = res.total;
  48. } else {
  49. common_vendor.index.showToast({
  50. title: res.errmsg || "",
  51. icon: "error"
  52. });
  53. }
  54. };
  55. const toChange = () => {
  56. common_vendor.index.navigateTo({
  57. url: `/pagesHome/type/index`
  58. });
  59. };
  60. const toView = (item) => {
  61. common_vendor.index.navigateTo({
  62. url: `/pagesHome/car/index?id=${item.id || item._id}`
  63. });
  64. };
  65. const toPage = () => {
  66. if (total.value > list.value.length) {
  67. common_vendor.index.showLoading({
  68. title: "加载中",
  69. mask: true
  70. });
  71. page.value = page.value + 1;
  72. skip.value = page.value * limit.value;
  73. search();
  74. common_vendor.index.hideLoading();
  75. } else
  76. is_bottom.value = true;
  77. };
  78. const clearPage = () => {
  79. list.value = [];
  80. skip.value = 0;
  81. limit.value = 6;
  82. page.value = 0;
  83. };
  84. return (_ctx, _cache) => {
  85. return common_vendor.e({
  86. a: common_vendor.o(toChange),
  87. b: common_vendor.p({
  88. shape: "square",
  89. ["show-action"]: false,
  90. placeholder: "品牌/车系"
  91. }),
  92. c: common_vendor.f(list.value, (item, index, i0) => {
  93. return {
  94. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  95. b: common_vendor.t(item.series || "暂无"),
  96. c: common_vendor.t(item.year || "暂无"),
  97. d: common_vendor.t(item.style || "暂无"),
  98. e: common_vendor.t(item.total_money || "0"),
  99. f: index,
  100. g: common_vendor.o(($event) => toView(item), index)
  101. };
  102. }),
  103. d: is_bottom.value
  104. }, is_bottom.value ? {
  105. e: common_vendor.t(config.value.bottom_title || "没有更多了!")
  106. } : {}, {
  107. f: common_vendor.o(toPage)
  108. });
  109. };
  110. }
  111. });
  112. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4978fed5"], ["__file", "D:/project/赋强公证/notarization_applet/pages/home/index.vue"]]);
  113. wx.createPage(MiniProgramPage);