index.js 4.0 KB

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