123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- "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 searchInfo = 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 }]);
- 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 brandInfo = common_vendor.ref({});
- const moneyInfo = 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.ref([
- {
- title: "5万以下",
- type: "0"
- },
- {
- title: "5-10万",
- type: "1"
- },
- {
- title: "10-15万",
- type: "2"
- },
- {
- title: "更多条件",
- type: "3"
- }
- ]);
- common_vendor.ref([
- {
- title: "大众",
- type: "0"
- },
- {
- title: "宝马",
- type: "1"
- },
- {
- title: "本田",
- type: "2"
- },
- {
- title: "丰田",
- type: "3"
- },
- {
- title: "更多品牌",
- type: "4"
- }
- ]);
- common_vendor.onLoad(async () => {
- await searchConfig();
- await search();
- });
- common_vendor.onShow(() => {
- common_vendor.index.$on("toRoute", function(data) {
- brandInfo.value = data;
- });
- });
- const searchConfig = async () => {
- config.value = common_vendor.index.getStorageSync("config");
- };
- const search = async () => {
- const info = {
- skip: skip.value,
- limit: limit.value,
- status: "0"
- };
- const res = await $api("car", "GET", {
- ...info,
- ...searchInfo.value
- });
- 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 toClose = () => {
- is_show.value = false;
- searchList.value = searchList.value.map((item, index) => {
- item.is_open = false;
- return item;
- });
- };
- const toSelect = (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;
- });
- moneyInfo.value = data;
- }
- };
- const toDelete = (item, type2) => {
- if (type2 == "0")
- brandInfo.value = {};
- 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;
- });
- moneyInfo.value = {};
- } else
- moreList.value = moreList.value.filter((i, index) => i.type != item.type);
- };
- const toReset = () => {
- brandInfo.value = {};
- moneyInfo.value = {};
- moreList.value = [];
- toClear();
- };
- 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) => {
- common_vendor.index.makePhoneCall({
- phoneNumber: item.shop || "110",
- success: function() {
- console.log("拨打电话成功");
- },
- fail: function() {
- console.log("拨打电话失败");
- }
- });
- };
- 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;
- };
- return (_ctx, _cache) => {
- return common_vendor.e({
- a: common_vendor.p({
- shape: "square",
- ["show-action"]: false,
- placeholder: "请输入车辆的名称或品牌"
- }),
- b: 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: "#ffbc00",
- size: "10px",
- name: "arrow-up-fill"
- })
- }, {
- h: index,
- i: common_vendor.o(($event) => toSearch(item), index)
- });
- }),
- c: type.value == "0"
- }, type.value == "0" ? {
- d: 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" ? {
- f: 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)
- };
- })
- } : {}, {
- e: type.value == "2",
- g: is_show.value,
- h: common_vendor.o(toClose),
- i: Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || moreList.value.length > 0
- }, Object.keys(brandInfo.value).length > 0 || Object.keys(moneyInfo.value).length > 0 || moreList.value.length > 0 ? common_vendor.e({
- j: brandInfo.value && brandInfo.value.type
- }, brandInfo.value && brandInfo.value.type ? {
- k: common_vendor.t(brandInfo.value.title),
- l: common_vendor.p({
- color: "#000",
- size: "14px",
- name: "close"
- }),
- m: common_vendor.o(($event) => toDelete({}, "0"))
- } : {}, {
- n: moneyInfo.value && moneyInfo.value.type
- }, moneyInfo.value && moneyInfo.value.type ? {
- o: common_vendor.t(moneyInfo.value.title),
- p: common_vendor.p({
- color: "#000",
- size: "14px",
- name: "close"
- }),
- q: common_vendor.o(($event) => toDelete({}, "1"))
- } : {}, {
- r: moreList.value.length > 0
- }, moreList.value.length > 0 ? {
- s: 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)
- };
- }),
- t: common_vendor.p({
- color: "#000",
- size: "14px",
- name: "close"
- })
- } : {}, {
- v: common_vendor.o(toReset)
- }) : {}, {
- w: 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)
- });
- }),
- x: is_bottom.value
- }, is_bottom.value ? {
- y: common_vendor.t(config.value.bottom_title || "没有更多了!")
- } : {}, {
- z: common_vendor.o(toPage)
- });
- };
- }
- });
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-2519f642"], ["__file", "D:/project/二手车/car_applet/pagesHome/search/index.vue"]]);
- wx.createPage(MiniProgramPage);
|