123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- "use strict";
- const common_vendor = require("../../common/vendor.js");
- if (!Array) {
- const _easycom_u_search2 = common_vendor.resolveComponent("u-search");
- _easycom_u_search2();
- }
- const _easycom_u_search = () => "../../node-modules/uview-plus/components/u-search/u-search.js";
- if (!Math) {
- _easycom_u_search();
- }
- 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;
- const $config = (_b = common_vendor.getCurrentInstance()) == null ? void 0 : _b.appContext.config.globalProperties.$config;
- const config = common_vendor.ref({ logoUrl: [] });
- const searchInfo = 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);
- const typeList = common_vendor.ref([
- {
- title: "5万以下",
- type: "0"
- },
- {
- title: "5-10万",
- type: "1"
- },
- {
- title: "10-15万",
- type: "2"
- },
- {
- title: "更多条件",
- type: "3"
- }
- ]);
- const carList = common_vendor.ref([]);
- common_vendor.onShow(async () => {
- await searchOther();
- await searchConfig();
- await clearPage();
- await search();
- });
- common_vendor.onPullDownRefresh(async () => {
- await clearPage();
- await searchOther();
- await search();
- common_vendor.index.stopPullDownRefresh();
- });
- const searchOther = async () => {
- let res;
- res = await $api(`brand`, "GET", { skip: 0, limit: 4, is_use: "0" });
- if (res.errcode === 0)
- carList.value = res.data;
- carList.value.push({
- name: "更多品牌",
- type: "4"
- });
- };
- 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 toRoute = (item) => {
- common_vendor.index.navigateTo({
- url: `/${item.route}`
- });
- };
- const toCommon = (item, type) => {
- console.log(item);
- if (type == "0" && item.type == "4") {
- common_vendor.index.navigateTo({
- url: `/pagesHome/brand/index?type=${item.type || ""}`
- });
- } else {
- common_vendor.index.navigateTo({
- url: `/pagesHome/search/index?type=${item.type || ""}`
- });
- }
- };
- 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.p({
- shape: "square",
- ["show-action"]: false,
- placeholder: "品牌/车系"
- }),
- b: common_vendor.f(common_vendor.unref($config).searchList, (item, index, i0) => {
- return {
- a: common_vendor.n(item.icon),
- b: common_vendor.t(item.title || "暂无"),
- c: index,
- d: common_vendor.o(($event) => toRoute(item), index)
- };
- }),
- c: common_vendor.f(carList.value, (item, index, i0) => {
- return {
- a: item.logo && item.logo.length > 0 ? item.logo[0].url : "/static/logo.png",
- b: common_vendor.t(item.name),
- c: index,
- d: common_vendor.o(($event) => toCommon(item, "0"), index)
- };
- }),
- d: common_vendor.f(typeList.value, (item, index, i0) => {
- return {
- a: common_vendor.t(item.title || "暂无"),
- b: index,
- c: common_vendor.o(($event) => toCommon(item, "1"), index)
- };
- }),
- e: 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)
- });
- }),
- f: is_bottom.value
- }, is_bottom.value ? {
- g: common_vendor.t(config.value.bottom_title || "没有更多了!")
- } : {}, {
- h: common_vendor.o(toPage)
- });
- };
- }
- });
- const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-4723889f"], ["__file", "D:/project/二手车/car_applet/pages/select/index.vue"]]);
- wx.createPage(MiniProgramPage);
|