index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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. const $config = (_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. const typeList = common_vendor.ref([
  26. {
  27. title: "5万以下",
  28. type: "0"
  29. },
  30. {
  31. title: "5-10万",
  32. type: "1"
  33. },
  34. {
  35. title: "10-15万",
  36. type: "2"
  37. },
  38. {
  39. title: "更多条件",
  40. type: "3"
  41. }
  42. ]);
  43. const carList = common_vendor.ref([]);
  44. common_vendor.onShow(async () => {
  45. await searchOther();
  46. await searchConfig();
  47. await clearPage();
  48. await search();
  49. });
  50. common_vendor.onPullDownRefresh(async () => {
  51. await clearPage();
  52. await searchOther();
  53. await search();
  54. common_vendor.index.stopPullDownRefresh();
  55. });
  56. const searchOther = async () => {
  57. let res;
  58. res = await $api(`brand`, "GET", { skip: 0, limit: 4, is_use: "0" });
  59. if (res.errcode === 0)
  60. carList.value = res.data;
  61. carList.value.push({
  62. name: "更多品牌",
  63. type: "4"
  64. });
  65. };
  66. const searchConfig = async () => {
  67. config.value = common_vendor.index.getStorageSync("config");
  68. };
  69. const search = async () => {
  70. const info = {
  71. skip: skip.value,
  72. limit: limit.value,
  73. status: "0"
  74. };
  75. const res = await $api("car", "GET", info);
  76. if (res.errcode === 0) {
  77. list.value = list.value.concat(res.data);
  78. total.value = res.total;
  79. } else {
  80. common_vendor.index.showToast({
  81. title: res.errmsg || "",
  82. icon: "error"
  83. });
  84. }
  85. };
  86. const toChange = () => {
  87. common_vendor.index.navigateTo({
  88. url: `/pagesHome/type/index`
  89. });
  90. };
  91. const toRoute = (item) => {
  92. common_vendor.index.navigateTo({
  93. url: `/${item.route}`
  94. });
  95. };
  96. const toCommon = (item, type) => {
  97. if (type == "0") {
  98. if (item.type == "4") {
  99. common_vendor.index.navigateTo({
  100. url: `/pagesHome/brand/index?type=${item.type}`
  101. });
  102. } else {
  103. common_vendor.index.navigateTo({
  104. url: `/pagesHome/search/index?brand=${item.name}`
  105. });
  106. }
  107. } else {
  108. if (item.type == "3") {
  109. common_vendor.index.navigateTo({
  110. url: `/pagesHome/search/index?type=${item.type}`
  111. });
  112. } else {
  113. common_vendor.index.navigateTo({
  114. url: `/pagesHome/search/index?money=${item.title}`
  115. });
  116. }
  117. }
  118. };
  119. const toView = (item) => {
  120. common_vendor.index.navigateTo({
  121. url: `/pagesHome/car/index?id=${item.id || item._id}`
  122. });
  123. };
  124. const toPage = () => {
  125. if (total.value > list.value.length) {
  126. common_vendor.index.showLoading({
  127. title: "加载中",
  128. mask: true
  129. });
  130. page.value = page.value + 1;
  131. skip.value = page.value * limit.value;
  132. search();
  133. common_vendor.index.hideLoading();
  134. } else
  135. is_bottom.value = true;
  136. };
  137. const clearPage = () => {
  138. list.value = [];
  139. skip.value = 0;
  140. limit.value = 6;
  141. page.value = 0;
  142. };
  143. return (_ctx, _cache) => {
  144. return common_vendor.e({
  145. a: common_vendor.o(toChange),
  146. b: common_vendor.p({
  147. shape: "square",
  148. ["show-action"]: false,
  149. placeholder: "品牌/车系"
  150. }),
  151. c: common_vendor.f(common_vendor.unref($config).searchList, (item, index, i0) => {
  152. return {
  153. a: common_vendor.n(item.icon),
  154. b: common_vendor.t(item.title || "暂无"),
  155. c: index,
  156. d: common_vendor.o(($event) => toRoute(item), index)
  157. };
  158. }),
  159. d: common_vendor.f(carList.value, (item, index, i0) => {
  160. return {
  161. a: item.logo && item.logo.length > 0 ? item.logo[0].url : "/static/logo.png",
  162. b: common_vendor.t(item.name),
  163. c: index,
  164. d: common_vendor.o(($event) => toCommon(item, "0"), index)
  165. };
  166. }),
  167. e: common_vendor.f(typeList.value, (item, index, i0) => {
  168. return {
  169. a: common_vendor.t(item.title || "暂无"),
  170. b: index,
  171. c: common_vendor.o(($event) => toCommon(item, "1"), index)
  172. };
  173. }),
  174. f: common_vendor.f(list.value, (item, index, i0) => {
  175. return common_vendor.e({
  176. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  177. b: common_vendor.t(item.series || "暂无"),
  178. c: common_vendor.t(item.year || "暂无"),
  179. d: common_vendor.t(item.style || "暂无"),
  180. e: item.year
  181. }, item.year ? {
  182. f: common_vendor.t(item.year || "暂无")
  183. } : {}, {
  184. g: item.mileage
  185. }, item.mileage ? {
  186. h: common_vendor.t(item.mileage || "暂无")
  187. } : {}, {
  188. i: item.place
  189. }, item.place ? {
  190. j: common_vendor.t(item.place || "暂无")
  191. } : {}, {
  192. k: common_vendor.t(item.total_money || "0"),
  193. l: index,
  194. m: common_vendor.o(($event) => toView(item), index)
  195. });
  196. }),
  197. g: is_bottom.value
  198. }, is_bottom.value ? {
  199. h: common_vendor.t(config.value.bottom_title || "没有更多了!")
  200. } : {}, {
  201. i: common_vendor.o(toPage)
  202. });
  203. };
  204. }
  205. });
  206. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4723889f"], ["__file", "D:/project/赋强公证/notarization_applet/pages/select/index.vue"]]);
  207. wx.createPage(MiniProgramPage);