index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. "use strict";
  2. const common_vendor = require("../../common/vendor.js");
  3. if (!Array) {
  4. const _easycom_u_subsection2 = common_vendor.resolveComponent("u-subsection");
  5. _easycom_u_subsection2();
  6. }
  7. const _easycom_u_subsection = () => "../../node-modules/uview-plus/components/u-subsection/u-subsection.js";
  8. if (!Math) {
  9. _easycom_u_subsection();
  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 tabList = common_vendor.ref(["销量榜", "保值榜", "店铺规模榜"]);
  18. const curNow = common_vendor.ref(0);
  19. const config = common_vendor.ref({ logoUrl: [] });
  20. const list = common_vendor.ref([]);
  21. const total = common_vendor.ref(0);
  22. const skip = common_vendor.ref(0);
  23. const limit = common_vendor.ref(6);
  24. const page = common_vendor.ref(0);
  25. const is_bottom = common_vendor.ref(false);
  26. common_vendor.ref(0);
  27. common_vendor.onLoad(async () => {
  28. await searchConfig();
  29. await search();
  30. });
  31. const searchConfig = async () => {
  32. config.value = common_vendor.index.getStorageSync("config");
  33. };
  34. const search = async () => {
  35. const info = {
  36. skip: skip.value,
  37. limit: limit.value,
  38. status: "0"
  39. };
  40. const res = await $api("car", "GET", info);
  41. if (res.errcode === 0) {
  42. list.value = list.value.concat(res.data);
  43. total.value = res.total;
  44. } else {
  45. common_vendor.index.showToast({
  46. title: res.errmsg || "",
  47. icon: "error"
  48. });
  49. }
  50. };
  51. const sectionChange = (index) => {
  52. curNow.value = index;
  53. };
  54. const toView = (item) => {
  55. common_vendor.index.navigateTo({
  56. url: `/pagesHome/car/index?id=${item.id || item._id}`
  57. });
  58. };
  59. const toPage = () => {
  60. if (total.value > list.value.length) {
  61. common_vendor.index.showLoading({
  62. title: "加载中",
  63. mask: true
  64. });
  65. page.value = page.value + 1;
  66. skip.value = page.value * limit.value;
  67. search();
  68. common_vendor.index.hideLoading();
  69. } else
  70. is_bottom.value = true;
  71. };
  72. return (_ctx, _cache) => {
  73. return common_vendor.e({
  74. a: common_vendor.o(sectionChange),
  75. b: common_vendor.p({
  76. mode: "subsection",
  77. activeColor: "#2979ff",
  78. list: tabList.value,
  79. current: curNow.value
  80. }),
  81. c: common_vendor.f(list.value, (item, index, i0) => {
  82. return common_vendor.e({
  83. a: common_vendor.t(index + 1),
  84. b: common_vendor.n(`rank${index + 1}`),
  85. c: item.file && item.file.length > 0 ? item.file[0].url : "",
  86. d: common_vendor.t(item.series || "暂无"),
  87. e: common_vendor.t(item.year || "暂无"),
  88. f: common_vendor.t(item.style || "暂无"),
  89. g: item.year
  90. }, item.year ? {
  91. h: common_vendor.t(item.year || "暂无")
  92. } : {}, {
  93. i: item.mileage
  94. }, item.mileage ? {
  95. j: common_vendor.t(item.mileage || "暂无")
  96. } : {}, {
  97. k: item.place
  98. }, item.place ? {
  99. l: common_vendor.t(item.place || "暂无")
  100. } : {}, {
  101. m: common_vendor.t(item.total_money || "0"),
  102. n: index,
  103. o: common_vendor.o(($event) => toView(item), index)
  104. });
  105. }),
  106. d: is_bottom.value
  107. }, is_bottom.value ? {
  108. e: common_vendor.t(config.value.bottom_title || "没有更多了!")
  109. } : {}, {
  110. f: common_vendor.o(toPage)
  111. });
  112. };
  113. }
  114. });
  115. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-581af8d0"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/rank/index.vue"]]);
  116. wx.createPage(MiniProgramPage);