index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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. common_vendor.computed(() => {
  18. return common_vendor.index.getStorageSync("openid");
  19. });
  20. const searchInfo = common_vendor.ref({});
  21. const config = common_vendor.ref({ logoUrl: [] });
  22. const list = common_vendor.ref([]);
  23. const total = common_vendor.ref(0);
  24. const skip = common_vendor.ref(0);
  25. const limit = common_vendor.ref(6);
  26. const page = common_vendor.ref(0);
  27. const is_bottom = common_vendor.ref(false);
  28. common_vendor.ref(0);
  29. const statusList = common_vendor.ref([]);
  30. common_vendor.onLoad(async () => {
  31. await searchOther();
  32. await searchConfig();
  33. await search();
  34. });
  35. const searchOther = async () => {
  36. let res;
  37. res = await $api(`dictData`, "GET", { code: "valuation", is_use: "0" });
  38. if (res.errcode === 0)
  39. statusList.value = res.data;
  40. };
  41. const searchConfig = async () => {
  42. config.value = common_vendor.index.getStorageSync("config");
  43. };
  44. const search = async () => {
  45. const info = {
  46. skip: skip.value,
  47. limit: limit.value
  48. // openid: openid.value
  49. };
  50. const res = await $api("estimate", "GET", {
  51. ...info,
  52. ...searchInfo.value
  53. });
  54. if (res.errcode === 0) {
  55. list.value = list.value.concat(res.data);
  56. total.value = res.total;
  57. } else {
  58. common_vendor.index.showToast({
  59. title: res.errmsg || "",
  60. icon: "error"
  61. });
  62. }
  63. };
  64. const getDict = (data, model) => {
  65. let list2;
  66. switch (model) {
  67. case "status":
  68. list2 = statusList.value;
  69. break;
  70. }
  71. if (!list2)
  72. return;
  73. const res = list2.find((f) => f.value == data);
  74. return (res == null ? void 0 : res.label) || "暂无";
  75. };
  76. const toPage = () => {
  77. if (total.value > list.value.length) {
  78. common_vendor.index.showLoading({
  79. title: "加载中",
  80. mask: true
  81. });
  82. page.value = page.value + 1;
  83. skip.value = page.value * limit.value;
  84. search();
  85. common_vendor.index.hideLoading();
  86. } else
  87. is_bottom.value = true;
  88. };
  89. return (_ctx, _cache) => {
  90. return common_vendor.e({
  91. a: common_vendor.p({
  92. shape: "square",
  93. ["show-action"]: false,
  94. placeholder: "品牌/车系"
  95. }),
  96. b: common_vendor.f(list.value, (item, index, i0) => {
  97. return common_vendor.e({
  98. a: common_vendor.t(item.brand || "暂无"),
  99. b: common_vendor.t(item.bank || "暂无"),
  100. c: common_vendor.t(item.type || "暂无"),
  101. d: item.start
  102. }, item.start ? {
  103. e: common_vendor.t(item.start || "暂无")
  104. } : {}, {
  105. f: item.course
  106. }, item.course ? {
  107. g: common_vendor.t(item.course || "暂无")
  108. } : {}, {
  109. h: item.city
  110. }, item.city ? {
  111. i: common_vendor.t(item.city || "暂无")
  112. } : {}, {
  113. j: item.place
  114. }, item.place ? {
  115. k: common_vendor.t(item.place || "暂无")
  116. } : {}, {
  117. l: item.estimate
  118. }, item.estimate ? {
  119. m: common_vendor.t(item.estimate || "暂无")
  120. } : {}, {
  121. n: item.status
  122. }, item.status ? {
  123. o: common_vendor.t(getDict(item.status, "status"))
  124. } : {}, {
  125. p: index
  126. });
  127. }),
  128. c: is_bottom.value
  129. }, is_bottom.value ? {
  130. d: common_vendor.t(config.value.bottom_title || "没有更多了!")
  131. } : {}, {
  132. e: common_vendor.o(toPage)
  133. });
  134. };
  135. }
  136. });
  137. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-8e01b58b"], ["__file", "D:/project/二手车/car_applet/pagesMy/car/index.vue"]]);
  138. wx.createPage(MiniProgramPage);