index.js 15 KB

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