123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- const pagesHome_condition_common_classify = require("./common/classify.js");
- if (!Array) {
- const _easycom_u_button2 = common_vendor.resolveComponent("u-button");
- _easycom_u_button2();
- }
- const _easycom_u_button = () => "../../node-modules/uview-plus/components/u-button/u-button.js";
- if (!Math) {
- (_easycom_u_button + SliderRange)();
- }
- const SliderRange = () => "../../components/slider-range/index.js";
- 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 total = common_vendor.ref(0);
- const scrollTop = common_vendor.ref(0);
- const current = common_vendor.ref(0);
- const itemId = common_vendor.ref("");
- const tabbar = common_vendor.ref([]);
- const scrollRightTop = common_vendor.ref(0);
- common_vendor.ref({});
- const searchList = common_vendor.ref([]);
- const searchInfo = common_vendor.ref({});
- const boxTypeList = common_vendor.ref([]);
- const structureList = common_vendor.ref([]);
- const emissionList = common_vendor.ref([]);
- const energyList = common_vendor.ref([]);
- const displacementList = common_vendor.ref([]);
- const setList = common_vendor.ref([]);
- common_vendor.onLoad(async (options) => {
- id.value = options && options.id;
- await searchOther();
- await searchCar();
- await searchConfig();
- await search();
- });
- common_vendor.onShow(async () => {
- common_vendor.index.$on("toRoute", function(data) {
- searchInfo.value.brand = data.name;
- tabbar.value = tabbar.value.map((item, index) => {
- if (item.type == "1" && item.value == "0")
- item.text = data.name;
- return item;
- });
- });
- common_vendor.index.$on("toCity", function(data) {
- searchInfo.value.place = data.name;
- tabbar.value = tabbar.value.map((item, index) => {
- if (item.type == "1" && item.value == "1")
- item.text = data.name;
- return item;
- });
- });
- await searchCar();
- });
- const searchOther = async () => {
- let res;
- res = await $api(`dictData`, "GET", { code: "boxType", is_use: "0" });
- if (res.errcode === 0)
- boxTypeList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "structure", is_use: "0" });
- if (res.errcode === 0)
- structureList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "emission", is_use: "0" });
- if (res.errcode === 0)
- emissionList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "energy", is_use: "0" });
- if (res.errcode === 0)
- energyList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "displacement", is_use: "0" });
- if (res.errcode === 0)
- displacementList.value = res.data;
- res = await $api(`dictData`, "GET", { code: "set", is_use: "0" });
- if (res.errcode === 0)
- setList.value = res.data;
- };
- const searchConfig = async () => {
- config.value = common_vendor.index.getStorageSync("config");
- };
- const searchCar = async () => {
- const info = {
- skip: 0,
- limit: 1,
- status: "0"
- };
- for (let val of searchList.value) {
- if (val.code == "displacement")
- info[val.code] = val.label;
- else
- info[val.code] = val.value;
- }
- const res = await $api("car", "GET", {
- ...info,
- ...searchInfo.value
- });
- if (res.errcode === 0) {
- total.value = res.total;
- } else {
- common_vendor.index.showToast({
- title: res.errmsg || "",
- icon: "error"
- });
- }
- };
- const search = async () => {
- const data = pagesHome_condition_common_classify.classifyData.map((item, index) => {
- if (item.type == "boxType") {
- boxTypeList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = boxTypeList.value;
- } else if (item.type == "structure") {
- structureList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = structureList.value;
- } else if (item.type == "emission") {
- emissionList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = emissionList.value;
- } else if (item.type == "energy") {
- energyList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = energyList.value;
- } else if (item.type == "displacement") {
- displacementList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = displacementList.value;
- } else if (item.type == "set") {
- setList.value.forEach((v) => {
- v["is_open"] = false;
- });
- item.foods = setList.value;
- }
- return item;
- });
- tabbar.value = data;
- };
- const swichMenu = (index) => {
- if (index == current.value)
- return;
- current.value = index;
- itemId.value = `item${index}`;
- };
- const rightScroll = async (e) => {
- scrollTop.value = e.scrollTop;
- };
- const toCommon = (type) => {
- if (type == "0") {
- common_vendor.index.navigateTo({
- url: `/pagesHome/brand/index`
- });
- } else {
- common_vendor.index.navigateTo({
- url: `/pagesHome/city/index`
- });
- }
- };
- const changeSliderValue = async (e, data) => {
- tabbar.value = tabbar.value.map((item, index) => {
- if (item.name == data.name) {
- if (e.firstValue == 0)
- item.content = `${e.secondValue}${item.unit}以下`;
- else
- item.content = `${e.firstValue}-${e.secondValue}${item.unit}`;
- item.value = e.values;
- }
- return item;
- });
- if (data.name == "价格")
- searchInfo.value.money = data.content;
- else if (data.name == "车龄")
- searchInfo.value.year = data.content;
- else
- searchInfo.value.mileage = data.content;
- await searchCar();
- };
- const toSelect = async (arr, data) => {
- searchList.value.push(data);
- tabbar.value = tabbar.value.map((item, index) => {
- if (item.type == arr.type) {
- item.foods = item.foods.map((item1, index1) => {
- if (item1.value == data.value)
- item1.is_open = !item1.is_open;
- return item1;
- });
- }
- return item;
- });
- await searchCar();
- };
- const toSearch = () => {
- common_vendor.index.navigateTo({
- url: `/pagesHome/search/index`
- });
- };
- const toReset = async () => {
- searchInfo.value = {};
- searchList.value = [];
- await search();
- await searchCar();
- };
- return (_ctx, _cache) => {
- return {
- a: common_vendor.f(tabbar.value, (item, index, i0) => {
- return {
- a: common_vendor.t(item.name),
- b: index,
- c: "item" + index,
- d: common_vendor.n(current.value == index ? "u-tab-item-active" : ""),
- e: common_vendor.o(($event) => swichMenu(index), index)
- };
- }),
- b: scrollTop.value,
- c: common_vendor.f(tabbar.value, (item, index, i0) => {
- return common_vendor.e({
- a: item.type != "2"
- }, item.type != "2" ? {
- b: common_vendor.t(item.name)
- } : {
- c: common_vendor.t(item.name),
- d: common_vendor.t(item.unit),
- e: common_vendor.t(item.content || "不限")
- }, {
- f: item.type == "1"
- }, item.type == "1" ? {
- g: common_vendor.o(($event) => toCommon(item.value), index),
- h: "4b99813d-0-" + i0,
- i: common_vendor.p({
- text: item.text,
- size: "normal",
- type: "info"
- })
- } : item.type == "2" ? {
- k: common_vendor.o((event) => changeSliderValue(event, item), index),
- l: "4b99813d-1-" + i0,
- m: common_vendor.p({
- value: item.value,
- min: item.min,
- max: item.max,
- step: item.step,
- scale: {
- show: true
- }
- })
- } : {
- n: common_vendor.f(item.foods, (item1, index1, i1) => {
- return {
- a: common_vendor.t(item1.label),
- b: common_vendor.n((item1 == null ? void 0 : item1.is_open) == false ? "title_1" : "title_2"),
- c: index1,
- d: common_vendor.o(($event) => toSelect(item, item1), index1)
- };
- })
- }, {
- j: item.type == "2",
- o: "item" + index,
- p: index
- });
- }),
- d: scrollRightTop.value,
- e: itemId.value,
- f: common_vendor.o(rightScroll),
- g: common_vendor.o(toReset),
- h: common_vendor.t(total.value),
- i: common_vendor.o(toSearch)
- };
- };
- }
- });
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4b99813d"], ["__file", "D:/project/赋强公证/notarization_applet/pagesHome/condition/index.vue"]]);
- wx.createPage(MiniProgramPage);
|