"use strict"; const common_vendor = require("../../common/vendor.js"); if (!Array) { const _easycom_u_search2 = common_vendor.resolveComponent("u-search"); const _easycom_u_icon2 = common_vendor.resolveComponent("u-icon"); (_easycom_u_search2 + _easycom_u_icon2)(); } const _easycom_u_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js"; const _easycom_u_icon = () => "../../node-modules/uview-plus/components/u-icon/u-icon.js"; if (!Math) { (_easycom_u_search + _easycom_u_icon)(); } const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({ __name: "index", setup(__props) { var _a, _b; const $api = (_a = common_vendor.getCurrentInstance()) == null ? void 0 : _a.appContext.config.globalProperties.$api; (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config; const config = common_vendor.ref({ logoUrl: [] }); 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 }]); 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 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) => { if (options && options.type != "3") { searchInfo.value.brand = options && options.brand || ""; searchInfo.value.money = options && options.money || ""; } await searchConfig(); }); common_vendor.onShow(async () => { common_vendor.index.$on("toRoute", function(data) { if (data && data.name) searchInfo.value.brand = data.name; }); await clearPage(); await search(); }); const searchConfig = async () => { config.value = common_vendor.index.getStorageSync("config"); }; const search = async () => { const info = { skip: skip.value, limit: limit.value, status: "0" }; if (searchInfo.value.brand) info.brand = searchInfo.value.brand; if (searchInfo.value.money) info.money = searchInfo.value.money; const res = await $api("car", "GET", { ...info }); if (res.errcode === 0) { list.value = list.value.concat(res.data); total.value = res.total; } else { common_vendor.index.showToast({ title: res.errmsg || "", icon: "error" }); } }; 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 == "3") { toClose(); common_vendor.index.navigateTo({ url: `/pagesHome/condition/index` }); } else is_show.value = searchList.value.some((item) => item.is_open == true); }; const toChange = () => { common_vendor.index.navigateTo({ url: `/pagesHome/type/index` }); }; 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 { 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 = ""; } await clearPage(); await search(); }; 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 moreList.value = moreList.value.filter((i, index) => i.type != item.type); await clearPage(); await search(); }; const toReset = async () => { searchInfo.value.brand = ""; searchInfo.value.money = ""; moreList.value = []; toClear(); await clearPage(); await search(); }; const toClear = () => { searchList.value = searchList.value.map((i, index) => { if (i.type == "0") i.title = "默认排序"; return i; }); moneyList.value = moneyList.value.map((item, index) => { if (item.type == "0") item.is_open = true; else item.is_open = false; return item; }); sortList.value = sortList.value.map((item, index) => { if (item.type == "0") item.is_open = true; else item.is_open = false; return item; }); }; const toChat = (item) => { var _a2; common_vendor.index.makePhoneCall({ phoneNumber: (_a2 = item.shop) == 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 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) => { return common_vendor.e({ a: common_vendor.o(toChange), b: common_vendor.p({ shape: "square", ["show-action"]: false, placeholder: "请输入车辆的名称或品牌" }), c: 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: "2519f642-1-" + i0, e: common_vendor.p({ color: "#000", size: "10px", name: "arrow-down-fill" }) } : { f: "2519f642-2-" + i0, g: common_vendor.p({ color: "#2979ff", size: "10px", name: "arrow-up-fill" }) }, { h: index, i: common_vendor.o(($event) => toSearch(item), index) }); }), d: type.value == "0" }, type.value == "0" ? { e: 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" ? { g: 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) }; }) } : {}, { f: type.value == "2", h: is_show.value, i: common_vendor.o(toClose), j: searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0 }, searchInfo.value.brand || searchInfo.value.money || moreList.value.length > 0 ? common_vendor.e({ k: searchInfo.value && searchInfo.value.brand }, searchInfo.value && searchInfo.value.brand ? { l: common_vendor.t(searchInfo.value.brand), m: common_vendor.p({ color: "#000", size: "14px", name: "close" }), n: common_vendor.o(($event) => toDelete({}, "0")) } : {}, { o: searchInfo.value && searchInfo.value.money }, searchInfo.value && searchInfo.value.money ? { p: common_vendor.t(searchInfo.value.money), q: common_vendor.p({ color: "#000", size: "14px", name: "close" }), r: common_vendor.o(($event) => toDelete({}, "1")) } : {}, { s: moreList.value.length > 0 }, moreList.value.length > 0 ? { t: common_vendor.f(moreList.value, (item, index, i0) => { return { a: common_vendor.t(item.title), b: "2519f642-5-" + i0, c: index, d: common_vendor.o(($event) => toDelete(item, "2"), index) }; }), v: common_vendor.p({ color: "#000", size: "14px", name: "close" }) } : {}, { w: common_vendor.o(toReset) }) : {}, { x: 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: common_vendor.o(($event) => toChat(item), index), m: index, n: common_vendor.o(($event) => toView(item), index) }); }), y: is_bottom.value }, is_bottom.value ? { z: common_vendor.t(config.value.bottom_title || "没有更多了!") } : {}, { A: common_vendor.o(toPage) }); }; } }); const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2519f642"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/search/index.vue"]]); wx.createPage(MiniProgramPage);