index.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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. const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon");
  6. (_easycom_u_search2 + _easycom_u_icon2)();
  7. }
  8. const _easycom_u_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js";
  9. const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js";
  10. if (!Math) {
  11. (_easycom_u_search + _easycom_u_icon)();
  12. }
  13. const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  14. __name: "index",
  15. setup(__props) {
  16. var _a, _b;
  17. (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api;
  18. (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
  19. const config = common_vendor.ref({ logoUrl: [] });
  20. const type = common_vendor.ref("0");
  21. const is_show = common_vendor.ref(false);
  22. const searchList = common_vendor.ref([{ title: "默认排序", type: "0", is_open: false }, { title: "品牌", type: "1", is_open: false }, { title: "价格", type: "2", is_open: false }, { title: "更多筛选", type: "3", is_open: false }]);
  23. const sortList = common_vendor.ref([{ title: "默认排序", type: "0", is_open: true }, { title: "最新上架", type: "1", is_open: false }, { title: "车龄最短", type: "2", is_open: false }, { title: "里程最少", type: "3", is_open: false }, { title: "价格最高", type: "4", is_open: false }, { title: "价格最低", type: "5", is_open: false }]);
  24. const moneyList = common_vendor.ref([{ title: "不限价格", type: "0", is_open: true }, { title: "10万以下", type: "1", is_open: false }, { title: "10-15万", type: "2", is_open: false }, { title: "15-20万", type: "3", is_open: false }, { title: "20-25万", type: "4", is_open: false }, { title: "25-30万", type: "5", is_open: false }, { title: "30-50万", type: "6", is_open: false }, { title: "50万以上", type: "7", is_open: false }]);
  25. const brandInfo = common_vendor.ref({});
  26. const moneyInfo = common_vendor.ref({});
  27. const moreList = common_vendor.ref([]);
  28. const list = common_vendor.ref([
  29. {
  30. id: "1",
  31. file: [{ url: "https://cdn.uviewui.com/uview/album/1.jpg" }],
  32. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  33. year: "2014年 ",
  34. city: "丹东",
  35. kilometer: "8万公里",
  36. money: "7.80"
  37. },
  38. {
  39. id: "1",
  40. file: [{ url: "https://cdn.uviewui.com/uview/album/2.jpg" }],
  41. name: "捷豹XEL 2020款 2.0T 200PS S进取优雅版",
  42. year: "2014年 ",
  43. city: "丹东",
  44. kilometer: "8万公里",
  45. money: "7.80"
  46. },
  47. {
  48. id: "1",
  49. file: [{ url: "https://cdn.uviewui.com/uview/album/3.jpg" }],
  50. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  51. year: "2014年 ",
  52. city: "丹东",
  53. kilometer: "8万公里",
  54. money: "7.80"
  55. },
  56. {
  57. id: "1",
  58. file: [{ url: "https://cdn.uviewui.com/uview/album/4.jpg" }],
  59. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  60. year: "2014年 ",
  61. city: "丹东",
  62. kilometer: "8万公里",
  63. money: "7.80"
  64. },
  65. {
  66. id: "1",
  67. file: [{ url: "https://cdn.uviewui.com/uview/album/5.jpg" }],
  68. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  69. year: "2014年 ",
  70. city: "丹东",
  71. kilometer: "8万公里",
  72. money: "7.80"
  73. },
  74. {
  75. id: "1",
  76. file: [{ url: "https://cdn.uviewui.com/uview/album/6.jpg" }],
  77. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  78. year: "2014年 ",
  79. city: "丹东",
  80. kilometer: "8万公里",
  81. money: "7.80"
  82. },
  83. {
  84. id: "1",
  85. file: [{ url: "https://cdn.uviewui.com/uview/album/7.jpg" }],
  86. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  87. year: "2014年 ",
  88. city: "丹东",
  89. kilometer: "8万公里",
  90. money: "7.80"
  91. },
  92. {
  93. id: "1",
  94. file: [{ url: "https://cdn.uviewui.com/uview/album/8.jpg" }],
  95. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  96. year: "2014年 ",
  97. city: "丹东",
  98. kilometer: "8万公里",
  99. money: "7.80"
  100. },
  101. {
  102. id: "1",
  103. file: [{ url: "https://cdn.uviewui.com/uview/album/9.jpg" }],
  104. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  105. year: "2014年 ",
  106. city: "丹东",
  107. kilometer: "8万公里",
  108. money: "7.80"
  109. },
  110. {
  111. id: "1",
  112. file: [{ url: "https://cdn.uviewui.com/uview/album/10.jpg" }],
  113. name: "夏朗 2013款 1.8TSI 标配型 欧IV",
  114. year: "2014年 ",
  115. city: "丹东",
  116. kilometer: "8万公里",
  117. money: "7.80"
  118. }
  119. ]);
  120. const total = common_vendor.ref(0);
  121. const skip = common_vendor.ref(0);
  122. const limit = common_vendor.ref(6);
  123. const page = common_vendor.ref(0);
  124. const is_bottom = common_vendor.ref(false);
  125. common_vendor.ref(0);
  126. common_vendor.ref([
  127. {
  128. title: "5万以下",
  129. type: "0"
  130. },
  131. {
  132. title: "5-10万",
  133. type: "1"
  134. },
  135. {
  136. title: "10-15万",
  137. type: "2"
  138. },
  139. {
  140. title: "更多条件",
  141. type: "3"
  142. }
  143. ]);
  144. common_vendor.ref([
  145. {
  146. title: "大众",
  147. type: "0"
  148. },
  149. {
  150. title: "宝马",
  151. type: "1"
  152. },
  153. {
  154. title: "本田",
  155. type: "2"
  156. },
  157. {
  158. title: "丰田",
  159. type: "3"
  160. },
  161. {
  162. title: "更多品牌",
  163. type: "4"
  164. }
  165. ]);
  166. common_vendor.onLoad(async () => {
  167. await searchConfig();
  168. await search();
  169. });
  170. common_vendor.onShow(() => {
  171. common_vendor.index.$on("toRoute", function(data) {
  172. brandInfo.value = data;
  173. });
  174. });
  175. const searchConfig = async () => {
  176. config.value = common_vendor.index.getStorageSync("config");
  177. };
  178. const search = async () => {
  179. };
  180. const toSearch = (value) => {
  181. searchList.value = searchList.value.map((item, index) => {
  182. if (item.type == value.type && !item.is_open)
  183. item.is_open = true;
  184. else
  185. item.is_open = false;
  186. return item;
  187. });
  188. type.value = value.type;
  189. if (value.type == "1") {
  190. toClose();
  191. common_vendor.index.navigateTo({
  192. url: `/pagesHome/brand/index`
  193. });
  194. } else if (value.type == "3") {
  195. toClose();
  196. common_vendor.index.navigateTo({
  197. url: `/pagesHome/condition/index`
  198. });
  199. } else
  200. is_show.value = searchList.value.some((item) => item.is_open == true);
  201. };
  202. const toClose = () => {
  203. is_show.value = false;
  204. searchList.value = searchList.value.map((item, index) => {
  205. item.is_open = false;
  206. return item;
  207. });
  208. };
  209. const toSelect = (data, type2) => {
  210. if (type2 == "0") {
  211. sortList.value = sortList.value.map((item, index) => {
  212. if (item.type == data.type)
  213. item.is_open = true;
  214. else
  215. item.is_open = false;
  216. return item;
  217. });
  218. searchList.value = searchList.value.map((i, index) => {
  219. if (i.type == "0")
  220. i.title = data.title;
  221. return i;
  222. });
  223. } else {
  224. moneyList.value = moneyList.value.map((item, index) => {
  225. if (item.type == data.type)
  226. item.is_open = true;
  227. else
  228. item.is_open = false;
  229. return item;
  230. });
  231. moneyInfo.value = data;
  232. }
  233. };
  234. const toDelete = (item, type2) => {
  235. if (type2 == "0")
  236. brandInfo.value = {};
  237. else if (type2 == "1") {
  238. moneyList.value = moneyList.value.map((item2, index) => {
  239. if (item2.type == "0")
  240. item2.is_open = true;
  241. else
  242. item2.is_open = false;
  243. return item2;
  244. });
  245. moneyInfo.value = {};
  246. } else
  247. moreList.value = moreList.value.filter((i, index) => i.type != item.type);
  248. };
  249. const toReset = () => {
  250. brandInfo.value = {};
  251. moneyInfo.value = {};
  252. moreList.value = [];
  253. toClear();
  254. };
  255. const toClear = () => {
  256. searchList.value = searchList.value.map((i, index) => {
  257. if (i.type == "0")
  258. i.title = "默认排序";
  259. return i;
  260. });
  261. moneyList.value = moneyList.value.map((item, index) => {
  262. if (item.type == "0")
  263. item.is_open = true;
  264. else
  265. item.is_open = false;
  266. return item;
  267. });
  268. sortList.value = sortList.value.map((item, index) => {
  269. if (item.type == "0")
  270. item.is_open = true;
  271. else
  272. item.is_open = false;
  273. return item;
  274. });
  275. };
  276. const toChat = (item) => {
  277. common_vendor.index.makePhoneCall({
  278. phoneNumber: item.shop || "110",
  279. success: function() {
  280. console.log("拨打电话成功");
  281. },
  282. fail: function() {
  283. console.log("拨打电话失败");
  284. }
  285. });
  286. };
  287. const toView = (item) => {
  288. common_vendor.index.navigateTo({
  289. url: `/pagesHome/car/index?id=${item.id || item._id}`
  290. });
  291. };
  292. const toPage = () => {
  293. if (total.value > list.value.length) {
  294. common_vendor.index.showLoading({
  295. title: "加载中",
  296. mask: true
  297. });
  298. page.value = page.value + 1;
  299. skip.value = page.value * limit.value;
  300. search();
  301. common_vendor.index.hideLoading();
  302. } else
  303. is_bottom.value = true;
  304. };
  305. return (_ctx, _cache) => {
  306. return common_vendor.e({
  307. a: common_vendor.p({
  308. shape: "square",
  309. ["show-action"]: false,
  310. placeholder: "请输入车辆的名称或品牌"
  311. }),
  312. b: common_vendor.f(searchList.value, (item, index, i0) => {
  313. return common_vendor.e({
  314. a: common_vendor.t(item.title),
  315. b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"),
  316. c: item.is_open == false
  317. }, item.is_open == false ? {
  318. d: "2519f642-1-" + i0,
  319. e: common_vendor.p({
  320. color: "#000",
  321. size: "10px",
  322. name: "arrow-down-fill"
  323. })
  324. } : {
  325. f: "2519f642-2-" + i0,
  326. g: common_vendor.p({
  327. color: "#ffbc00",
  328. size: "10px",
  329. name: "arrow-up-fill"
  330. })
  331. }, {
  332. h: index,
  333. i: common_vendor.o(($event) => toSearch(item), index)
  334. });
  335. }),
  336. c: type.value == "0"
  337. }, type.value == "0" ? {
  338. d: common_vendor.f(sortList.value, (item, index, i0) => {
  339. return {
  340. a: common_vendor.t(item.title),
  341. b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"),
  342. c: index,
  343. d: common_vendor.o(($event) => toSelect(item, type.value), index)
  344. };
  345. })
  346. } : type.value == "2" ? {
  347. f: common_vendor.f(moneyList.value, (item, index, i0) => {
  348. return {
  349. a: common_vendor.t(item.title),
  350. b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"),
  351. c: index,
  352. d: common_vendor.o(($event) => toSelect(item, type.value), index)
  353. };
  354. })
  355. } : {}, {
  356. e: type.value == "2",
  357. g: is_show.value,
  358. h: common_vendor.o(toClose),
  359. i: Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || moreList.value.length > 0
  360. }, Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || moreList.value.length > 0 ? common_vendor.e({
  361. j: brandInfo.value && brandInfo.value.type
  362. }, brandInfo.value && brandInfo.value.type ? {
  363. k: common_vendor.t(brandInfo.value.title),
  364. l: common_vendor.p({
  365. color: "#000",
  366. size: "14px",
  367. name: "close"
  368. }),
  369. m: common_vendor.o(($event) => toDelete({}, "0"))
  370. } : {}, {
  371. n: moneyInfo.value && moneyInfo.value.type
  372. }, moneyInfo.value && moneyInfo.value.type ? {
  373. o: common_vendor.t(moneyInfo.value.title),
  374. p: common_vendor.p({
  375. color: "#000",
  376. size: "14px",
  377. name: "close"
  378. }),
  379. q: common_vendor.o(($event) => toDelete({}, "1"))
  380. } : {}, {
  381. r: moreList.value.length > 0
  382. }, moreList.value.length > 0 ? {
  383. s: common_vendor.f(moreList.value, (item, index, i0) => {
  384. return {
  385. a: common_vendor.t(item.title),
  386. b: "2519f642-5-" + i0,
  387. c: index,
  388. d: common_vendor.o(($event) => toDelete(item, "2"), index)
  389. };
  390. }),
  391. t: common_vendor.p({
  392. color: "#000",
  393. size: "14px",
  394. name: "close"
  395. })
  396. } : {}, {
  397. v: common_vendor.o(toReset)
  398. }) : {}, {
  399. w: common_vendor.f(list.value, (item, index, i0) => {
  400. return common_vendor.e({
  401. a: item.file && item.file.length > 0 ? item.file[0].url : "",
  402. b: common_vendor.t(item.name || "暂无"),
  403. c: item.year
  404. }, item.year ? {
  405. d: common_vendor.t(item.year || "暂无")
  406. } : {}, {
  407. e: item.kilometer
  408. }, item.kilometer ? {
  409. f: common_vendor.t(item.kilometer || "暂无")
  410. } : {}, {
  411. g: item.city
  412. }, item.city ? {
  413. h: common_vendor.t(item.city || "暂无")
  414. } : {}, {
  415. i: common_vendor.t(item.money || "0"),
  416. j: common_vendor.o(($event) => toChat(item), index),
  417. k: index,
  418. l: common_vendor.o(($event) => toView(item), index)
  419. });
  420. }),
  421. x: is_bottom.value
  422. }, is_bottom.value ? {
  423. y: common_vendor.t(config.value.bottom_title || "没有更多了!")
  424. } : {}, {
  425. z: common_vendor.o(toPage)
  426. });
  427. };
  428. }
  429. });
  430. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2519f642"], ["__file", "D:/project/二手车/car_applet/pagesHome/search/index.vue"]]);
  431. wx.createPage(MiniProgramPage);