index.js 16 KB

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