zs 1 éve
szülő
commit
f13f31397f

+ 71 - 18
pagesHome/car/index.vue

@@ -60,10 +60,21 @@
 							<view class="thr_1">
 								<text>档案</text>
 								<view class="info">
-									<view class="list" v-for="(item, index) in files" :key="index"
-										@tap="toCommon(item)">
-										<view class="info_1">{{item.content}}</view>
-										<view class="info_2">{{item.name}}</view>
+									<view class="list">
+										<view class="info_1">{{moment(info.f_time).format('MM-DD')||'暂无日期'}}</view>
+										<view class="info_2">上牌时间</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{info.mileage||'暂无'}}万公里</view>
+										<view class="info_2">表显里程</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{getDict(info.emission,'emission')}}</view>
+										<view class="info_2">排放标准</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{info.place||'暂无'}}</view>
+										<view class="info_2">车源地</view>
 									</view>
 									<u-icon name="arrow-right" size="16" @tap="toRecord"></u-icon>
 								</view>
@@ -71,10 +82,21 @@
 							<view class="thr_1">
 								<text>参数</text>
 								<view class="info">
-									<view class="list" v-for="(item, index) in parameter" :key="index"
-										@tap="toCommon(item)">
-										<view class="info_1">{{item.content}}</view>
-										<view class="info_2">{{item.name}}</view>
+									<view class="list">
+										<view class="info_1">{{getDict(info.displacement,'displacement')}}</view>
+										<view class="info_2">发动机</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{info.wheelbase}}</view>
+										<view class="info_2">轴距</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{getDict(info.type,'type')}}</view>
+										<view class="info_2">变速箱</view>
+									</view>
+									<view class="list">
+										<view class="info_1">{{info.oil}}L</view>
+										<view class="info_2">百公里油耗</view>
 									</view>
 								</view>
 							</view>
@@ -185,6 +207,7 @@
 </template>
 
 <script setup lang="ts">
+	import moment from 'moment';
 	import { getCurrentInstance, computed, ref } from 'vue';
 	//该依赖已内置不需要单独安装
 	import { onLoad } from "@dcloudio/uni-app";
@@ -200,16 +223,16 @@
 	const id = ref('');
 	// 轮播图
 	const currentNum = ref(1);
-	// 档案
-	const files = ref([{ name: '上牌时间', content: '2013-10' }, { name: '表显里程', content: '8.0万公里' }, { name: '排放标准', content: '国六' }, { name: '车源地', content: '长春' }]);
-	// 参数
-	const parameter = ref([{ name: '发动机', content: '1.8L' }, { name: '轴距', content: '2700mm' }, { name: '变速箱', content: '自动' }, { name: '最大功率', content: '103kW' }]);
 	// 详情
-	const info = ref({ url: [{ url: 'https://cdn.uviewui.com/uview/album/1.jpg' }, { url: 'https://cdn.uviewui.com/uview/album/2.jpg' }, { url: 'https://cdn.uviewui.com/uview/album/3.jpg' }, { url: 'https://cdn.uviewui.com/uview/album/4.jpg' }, { url: 'https://cdn.uviewui.com/uview/album/5.jpg' }], payment: '2.7', rankNum: '11', rank: '全国紧凑型SUV销售榜', type: '夏朗', name: '夏朗 2013款 1.8TSI 标配型 欧IV', money: '7.80', price: '29.06' });
+	const info = ref({});
 	// 店铺
 	const shop = ref({});
 	// 列表
 	const list = ref([]);
+	// 字典表
+	const emissionList = ref([]);
+	const boxTypeList = ref([]);
+	const displacementList = ref([]);
 	onLoad(async (options) => {
 		id.value = options && options.id
 		await searchConfig();
@@ -256,18 +279,48 @@
 			status: '0',
 			shop: shop.value._id
 		}
-		const res = await $api('car', 'GET', {
+		const arr = await $api('car', 'GET', {
 			...info,
 		});
-		if (res.errcode === 0) {
-			list.value = res.data
-			shop.value.num = res.total
+		if (arr.errcode === 0) {
+			list.value = arr.data
+			shop.value.num = arr.total
 		} else {
 			uni.showToast({
-				title: res.errmsg || '',
+				title: arr.errmsg || '',
 				icon: 'error',
 			});
 		}
+		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: 'emission', is_use: '0' });
+		if (res.errcode === 0) emissionList.value = res.data;
+		// 排量
+		res = await $api(`dictData`, 'GET', { code: 'displacement', is_use: '0' });
+		if (res.errcode === 0) displacementList.value = res.data;
+	};
+	// 数据处理
+	const getDict = (data, model) => {
+		let list;
+		switch (model) {
+			case 'type':
+				list = boxTypeList.value;
+				break;
+			case 'emission':
+				list = emissionList.value;
+				break;
+			case 'displacement':
+				list = displacementList.value;
+				break;
+			default:
+				break;
+		}
+		if (!list) return;
+		const res = list.find((f) => f.value == data);
+		return res?.label || '暂无';
 	};
 	// 获取手机号
 	const PhoneNumber = (e) => {

+ 68 - 47
unpackage/dist/dev/mp-weixin/pagesHome/car/index.js

@@ -23,11 +23,12 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     const config = common_vendor.ref({});
     const id = common_vendor.ref("");
     const currentNum = common_vendor.ref(1);
-    const files = common_vendor.ref([{ name: "上牌时间", content: "2013-10" }, { name: "表显里程", content: "8.0万公里" }, { name: "排放标准", content: "国六" }, { name: "车源地", content: "长春" }]);
-    const parameter = common_vendor.ref([{ name: "发动机", content: "1.8L" }, { name: "轴距", content: "2700mm" }, { name: "变速箱", content: "自动" }, { name: "最大功率", content: "103kW" }]);
-    const info = common_vendor.ref({ url: [{ url: "https://cdn.uviewui.com/uview/album/1.jpg" }, { url: "https://cdn.uviewui.com/uview/album/2.jpg" }, { url: "https://cdn.uviewui.com/uview/album/3.jpg" }, { url: "https://cdn.uviewui.com/uview/album/4.jpg" }, { url: "https://cdn.uviewui.com/uview/album/5.jpg" }], payment: "2.7", rankNum: "11", rank: "全国紧凑型SUV销售榜", type: "夏朗", name: "夏朗 2013款 1.8TSI 标配型 欧IV", money: "7.80", price: "29.06" });
+    const info = common_vendor.ref({});
     const shop = common_vendor.ref({});
     const list = common_vendor.ref([]);
+    const emissionList = common_vendor.ref([]);
+    const boxTypeList = common_vendor.ref([]);
+    const displacementList = common_vendor.ref([]);
     common_vendor.onLoad(async (options) => {
       id.value = options && options.id;
       await searchConfig();
@@ -72,18 +73,46 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         status: "0",
         shop: shop.value._id
       };
-      const res = await $api("car", "GET", {
+      const arr = await $api("car", "GET", {
         ...info2
       });
-      if (res.errcode === 0) {
-        list.value = res.data;
-        shop.value.num = res.total;
+      if (arr.errcode === 0) {
+        list.value = arr.data;
+        shop.value.num = arr.total;
       } else {
         common_vendor.index.showToast({
-          title: res.errmsg || "",
+          title: arr.errmsg || "",
           icon: "error"
         });
       }
+      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: "emission", is_use: "0" });
+      if (res.errcode === 0)
+        emissionList.value = res.data;
+      res = await $api(`dictData`, "GET", { code: "displacement", is_use: "0" });
+      if (res.errcode === 0)
+        displacementList.value = res.data;
+    };
+    const getDict = (data, model) => {
+      let list2;
+      switch (model) {
+        case "type":
+          list2 = boxTypeList.value;
+          break;
+        case "emission":
+          list2 = emissionList.value;
+          break;
+        case "displacement":
+          list2 = displacementList.value;
+          break;
+      }
+      if (!list2)
+        return;
+      const res = list2.find((f) => f.value == data);
+      return (res == null ? void 0 : res.label) || "暂无";
     };
     const PhoneNumber = (e) => {
       console.log(e);
@@ -159,56 +188,48 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           name: "arrow-right",
           size: "16"
         }),
-        r: common_vendor.f(files.value, (item, index, i0) => {
-          return {
-            a: common_vendor.t(item.content),
-            b: common_vendor.t(item.name),
-            c: index,
-            d: common_vendor.o(($event) => _ctx.toCommon(item), index)
-          };
-        }),
-        s: common_vendor.o(toRecord),
-        t: common_vendor.p({
+        r: common_vendor.t(common_vendor.unref(common_vendor.hooks)(info.value.f_time).format("MM-DD") || "暂无日期"),
+        s: common_vendor.t(info.value.mileage || "暂无"),
+        t: common_vendor.t(getDict(info.value.emission, "emission")),
+        v: common_vendor.t(info.value.place || "暂无"),
+        w: common_vendor.o(toRecord),
+        x: common_vendor.p({
           name: "arrow-right",
           size: "16"
         }),
-        v: common_vendor.f(parameter.value, (item, index, i0) => {
-          return {
-            a: common_vendor.t(item.content),
-            b: common_vendor.t(item.name),
-            c: index,
-            d: common_vendor.o(($event) => _ctx.toCommon(item), index)
-          };
-        }),
-        w: shop.value.logo && ((_b = shop.value.logo) == null ? void 0 : _b.length) > 0 ? shop.value.logo[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
-        x: common_vendor.t(shop.value.name || "暂无"),
-        y: common_vendor.p({
+        y: common_vendor.t(getDict(info.value.displacement, "displacement")),
+        z: common_vendor.t(info.value.wheelbase),
+        A: common_vendor.t(getDict(info.value.type, "type")),
+        B: common_vendor.t(info.value.oil),
+        C: shop.value.logo && ((_b = shop.value.logo) == null ? void 0 : _b.length) > 0 ? shop.value.logo[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
+        D: common_vendor.t(shop.value.name || "暂无"),
+        E: common_vendor.p({
           bold: true,
           color: "#000",
           name: "arrow-right",
           size: "16"
         }),
-        z: common_vendor.o(toShop),
-        A: common_vendor.t(shop.value.num || 0),
-        B: common_vendor.o(toChat),
-        C: common_vendor.p({
+        F: common_vendor.o(toShop),
+        G: common_vendor.t(shop.value.num || 0),
+        H: common_vendor.o(toChat),
+        I: common_vendor.p({
           icon: "phone",
           text: "咨询卖家车况",
           size: "normal",
           type: "info"
         }),
-        D: info.value.file && ((_c = info.value.file) == null ? void 0 : _c.length) > 0 ? info.value.file[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
-        E: info.value.file && ((_d = info.value.file) == null ? void 0 : _d.length) > 1 ? info.value.file[1].url : "https://cdn.uviewui.com/uview/album/5.jpg",
-        F: info.value.file && ((_e = info.value.file) == null ? void 0 : _e.length) > 2 ? info.value.file[2].url : "https://cdn.uviewui.com/uview/album/2.jpg",
-        G: info.value.file && ((_f = info.value.file) == null ? void 0 : _f.length) > 3 ? info.value.file[3].url : "https://cdn.uviewui.com/uview/album/3.jpg",
-        H: info.value.file && ((_g = info.value.file) == null ? void 0 : _g.length) > 4 ? info.value.file[4].url : "https://cdn.uviewui.com/uview/album/4.jpg",
-        I: common_vendor.o(toMore),
-        J: common_vendor.p({
+        J: info.value.file && ((_c = info.value.file) == null ? void 0 : _c.length) > 0 ? info.value.file[0].url : "https://cdn.uviewui.com/uview/album/1.jpg",
+        K: info.value.file && ((_d = info.value.file) == null ? void 0 : _d.length) > 1 ? info.value.file[1].url : "https://cdn.uviewui.com/uview/album/5.jpg",
+        L: info.value.file && ((_e = info.value.file) == null ? void 0 : _e.length) > 2 ? info.value.file[2].url : "https://cdn.uviewui.com/uview/album/2.jpg",
+        M: info.value.file && ((_f = info.value.file) == null ? void 0 : _f.length) > 3 ? info.value.file[3].url : "https://cdn.uviewui.com/uview/album/3.jpg",
+        N: info.value.file && ((_g = info.value.file) == null ? void 0 : _g.length) > 4 ? info.value.file[4].url : "https://cdn.uviewui.com/uview/album/4.jpg",
+        O: common_vendor.o(toMore),
+        P: common_vendor.p({
           text: "查看更多图片",
           size: "normal",
           type: "info"
         }),
-        K: common_vendor.f(list.value, (item, index, i0) => {
+        Q: 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 || "暂无"),
@@ -231,20 +252,20 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
             m: common_vendor.o(($event) => toView(item), index)
           });
         }),
-        L: common_vendor.p({
+        R: common_vendor.p({
           color: "#000",
           name: "red-packet",
           size: "20"
         }),
-        M: common_vendor.o(toChat),
-        N: common_vendor.p({
+        S: common_vendor.o(toChat),
+        T: common_vendor.p({
           color: "#000",
           name: "heart",
           size: "20"
         }),
-        O: common_vendor.o(toCollect),
-        P: common_vendor.o(toChat),
-        Q: common_vendor.o(toChat)
+        U: common_vendor.o(toCollect),
+        V: common_vendor.o(toChat),
+        W: common_vendor.o(toChat)
       };
     };
   }

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 1 - 1
unpackage/dist/dev/mp-weixin/pagesHome/car/index.wxml