"use strict"; const common_vendor = require("../../common/vendor.js"); if (!Array) { const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon"); const _easycom_u_line2 = common_vendor.resolveComponent("u-line"); const _easycom_u_button2 = common_vendor.resolveComponent("u-button"); (_easycom_u_icon2 + _easycom_u_line2 + _easycom_u_button2)(); } const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js"; const _easycom_u_line = () => "../../node-modules/uview-plus/components/u-line/u-line.js"; const _easycom_u_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js"; if (!Math) { (_easycom_u_icon + _easycom_u_line + _easycom_u_button)(); } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", setup(__props) { var _a; const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api; common_vendor.computed(() => { return common_vendor.index.getStorageSync("openid"); }); const config = common_vendor.ref({}); const id = common_vendor.ref(""); const shop = common_vendor.ref({}); const type = common_vendor.ref("0"); const is_show = common_vendor.ref(false); 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 }]); 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 }]); 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 }]); 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 }]); const searchInfo = common_vendor.ref({}); const moreList = common_vendor.ref([]); const list = common_vendor.ref([]); const total = common_vendor.ref(0); const skip = common_vendor.ref(0); const limit = common_vendor.ref(6); const page = common_vendor.ref(0); const is_bottom = common_vendor.ref(false); common_vendor.ref(0); common_vendor.onLoad(async (options) => { id.value = options && options.id; common_vendor.index.setNavigationBarTitle({ title: options && options.name || "车行详情" }); await searchConfig(); await search(); }); common_vendor.onShow(async () => { common_vendor.index.$on("toRoute", function(data) { if (data && data.name) searchInfo.value.brand = data.name; }); await clearPage(); await searchOther(); }); const searchConfig = async () => { config.value = common_vendor.index.getStorageSync("config"); }; const search = async () => { if (id.value) { const res = await $api(`shop/${id.value}`, "GET", {}); if (res.errcode === 0) { shop.value = res.data; } else { common_vendor.index.showToast({ title: res.errmsg || "", icon: "error" }); } } }; const searchOther = async () => { let res; const info = { skip: skip.value, limit: limit.value, status: "0", shop: id.value }; if (searchInfo.value.brand) info.brand = searchInfo.value.brand; if (searchInfo.value.money) info.money = searchInfo.value.money; if (searchInfo.value.year) info.year = searchInfo.value.year; res = await $api("car", "GET", { ...info }); if (res.errcode === 0) { list.value = list.value.concat(res.data); total.value = res.total; shop.value.sale = res.total; } else { common_vendor.index.showToast({ title: res.errmsg || "", icon: "error" }); } res = await $api("car", "GET", { skip: 0, limit: 1, status: "0", shop: id.value }); if (res.errcode === 0) shop.value.sold = res.total; }; const toSearch = (value) => { searchList.value = searchList.value.map((item, index) => { if (item.type == value.type && !item.is_open) item.is_open = true; else item.is_open = false; return item; }); type.value = value.type; if (value.type == "1") { toClose(); common_vendor.index.navigateTo({ url: `/pagesHome/brand/index` }); } else if (value.type == "4") { toClose(); common_vendor.index.navigateTo({ url: `/pagesHome/condition/index` }); } else is_show.value = searchList.value.some((item) => item.is_open == true); }; const toClose = () => { is_show.value = false; searchList.value = searchList.value.map((item, index) => { item.is_open = false; return item; }); }; const toSelect = async (data, type2) => { if (type2 == "0") { sortList.value = sortList.value.map((item, index) => { if (item.type == data.type) item.is_open = true; else item.is_open = false; return item; }); searchList.value = searchList.value.map((i, index) => { if (i.type == "0") i.title = data.title; return i; }); } else if (type2 == "2") { moneyList.value = moneyList.value.map((item, index) => { if (item.type == data.type) item.is_open = true; else item.is_open = false; return item; }); if (data.type != "0") searchInfo.value.money = data.title; else searchInfo.value.money = ""; } else { yearList.value = yearList.value.map((item, index) => { if (item.type == data.type) item.is_open = true; else item.is_open = false; return item; }); if (data.type != "0") searchInfo.value.year = data.title; else searchInfo.value.year = ""; } await clearPage(); await searchOther(); }; const toDelete = async (item, type2) => { if (type2 == "0") searchInfo.value.brand = ""; else if (type2 == "1") { moneyList.value = moneyList.value.map((item2, index) => { if (item2.type == "0") item2.is_open = true; else item2.is_open = false; return item2; }); searchInfo.value.money = ""; } else if (type2 == "2") { yearList.value = yearList.value.map((item2, index) => { if (item2.type == "0") item2.is_open = true; else item2.is_open = false; return item2; }); searchInfo.value.year = ""; } else moreList.value = moreList.value.filter((i, index) => i.type != item.type); await clearPage(); await searchOther(); }; const toReset = async () => { await toDelete({}, "0"); await toDelete({}, "1"); await toDelete({}, "2"); moreList.value = []; await toClear(); }; const toClear = () => { searchList.value = searchList.value.map((i, index) => { if (i.type == "0") i.title = "默认排序"; return i; }); sortList.value = sortList.value.map((item, index) => { if (item.type == "0") item.is_open = true; else item.is_open = false; return item; }); }; const toChat = () => { var _a2; common_vendor.index.makePhoneCall({ phoneNumber: (_a2 = shop.value) == null ? void 0 : _a2.tel, success: function() { console.log("拨打电话成功"); }, fail: function() { common_vendor.index.showToast({ title: "拨打电话失败", icon: "error" }); } }); }; const toView = (item) => { common_vendor.index.navigateTo({ url: `/pagesHome/car/index?id=${item.id || item._id}` }); }; const toImage = () => { var _a2; if (((_a2 = shop.value) == null ? void 0 : _a2.file.length) > 0) { common_vendor.index.previewImage({ urls: [shop.value.file[0].url], longPressActions: { itemList: ["发送给朋友", "保存图片", "收藏"], success: function(data) { console.log("选中了第" + (data.tapIndex + 1) + "个按钮,第" + (data.index + 1) + "张图片"); }, fail: function(err) { console.log(err.errMsg); } } }); } }; const toPage = () => { if (total.value > list.value.length) { common_vendor.index.showLoading({ title: "加载中", mask: true }); page.value = page.value + 1; skip.value = page.value * limit.value; search(); common_vendor.index.hideLoading(); } else is_bottom.value = true; }; const clearPage = () => { list.value = []; skip.value = 0; limit.value = 6; page.value = 0; }; return (_ctx, _cache) => { var _a2; return common_vendor.e({ 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", b: common_vendor.t(shop.value.name || "暂无"), c: common_vendor.t(shop.value.sale || "0"), d: common_vendor.t(shop.value.sold || "0"), e: common_vendor.t(shop.value.status == "0" ? "营业中" : "休息中"), f: common_vendor.t(shop.value.start_time || "8:00"), g: common_vendor.t(shop.value.end_time || "17:00"), h: common_vendor.p({ name: "file-text", size: "16" }), i: common_vendor.o(toImage), j: common_vendor.p({ direction: "col" }), k: common_vendor.t(shop.value.address || "暂无"), l: common_vendor.f(searchList.value, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t(item.title), b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"), c: item.is_open == false }, item.is_open == false ? { d: "88a3d2e5-2-" + i0, e: common_vendor.p({ color: "#000", size: "10px", name: "arrow-down-fill" }) } : { f: "88a3d2e5-3-" + i0, g: common_vendor.p({ color: "#2979ff", size: "10px", name: "arrow-up-fill" }) }, { h: index, i: common_vendor.o(($event) => toSearch(item), index) }); }), m: type.value == "0" }, type.value == "0" ? { n: common_vendor.f(sortList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"), c: index, d: common_vendor.o(($event) => toSelect(item, type.value), index) }; }) } : type.value == "2" ? { p: common_vendor.f(moneyList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"), c: index, d: common_vendor.o(($event) => toSelect(item, type.value), index) }; }) } : type.value == "3" ? { r: common_vendor.f(yearList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"), c: index, d: common_vendor.o(($event) => toSelect(item, type.value), index) }; }) } : { s: common_vendor.f(yearList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: common_vendor.n(item.is_open == false ? "title_1" : "title_2"), c: index, d: common_vendor.o(($event) => toSelect(item, type.value), index) }; }) }, { o: type.value == "2", q: type.value == "3", t: is_show.value, v: common_vendor.o(toClose), w: searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0 }, searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0 ? common_vendor.e({ x: searchInfo.value && searchInfo.value.brand }, searchInfo.value && searchInfo.value.brand ? { y: common_vendor.t(searchInfo.value.brand), z: common_vendor.p({ color: "#000", size: "14px", name: "close" }), A: common_vendor.o(($event) => toDelete({}, "0")) } : {}, { B: searchInfo.value && searchInfo.value.money }, searchInfo.value && searchInfo.value.money ? { C: common_vendor.t(searchInfo.value.money), D: common_vendor.p({ color: "#000", size: "14px", name: "close" }), E: common_vendor.o(($event) => toDelete({}, "1")) } : {}, { F: searchInfo.value && searchInfo.value.year }, searchInfo.value && searchInfo.value.year ? { G: common_vendor.t(searchInfo.value.year), H: common_vendor.p({ color: "#000", size: "14px", name: "close" }), I: common_vendor.o(($event) => toDelete({}, "2")) } : {}, { J: moreList.value.length > 0 }, moreList.value.length > 0 ? { K: common_vendor.f(moreList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: "88a3d2e5-7-" + i0, c: index, d: common_vendor.o(($event) => toDelete(item, "3"), index) }; }), L: common_vendor.p({ color: "#000", size: "14px", name: "close" }) } : {}, { M: common_vendor.o(toReset) }) : {}, { N: common_vendor.f(list.value, (item, index, i0) => { return common_vendor.e({ a: item.file && item.file.length > 0 ? item.file[0].url : "", b: common_vendor.t(item.series || "暂无"), c: common_vendor.t(item.year || "暂无"), d: common_vendor.t(item.style || "暂无"), e: item.year }, item.year ? { f: common_vendor.t(item.year || "暂无") } : {}, { g: item.mileage }, item.mileage ? { h: common_vendor.t(item.mileage || "暂无") } : {}, { i: item.place }, item.place ? { j: common_vendor.t(item.place || "暂无") } : {}, { k: common_vendor.t(item.total_money || "0"), l: index, m: common_vendor.o(($event) => toView(item), index) }); }), O: is_bottom.value }, is_bottom.value ? { P: common_vendor.t(config.value.bottom_title || "没有更多了!") } : {}, { Q: common_vendor.o(toPage), R: common_vendor.o(toChat), S: common_vendor.p({ icon: "phone", text: "电话联系", size: "normal", type: "info" }) }); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-88a3d2e5"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/shop/index.vue"]]); wx.createPage(MiniProgramPage);