index.js 16 KB

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