zs 1 year ago
parent
commit
b03fcfed41

+ 5 - 14
pagesHome/city/index.vue

@@ -28,25 +28,15 @@
 	// 请求接口
 	const $api = getCurrentInstance()?.appContext.config.globalProperties.$api;
 	const $config = getCurrentInstance()?.appContext.config.globalProperties.$config;
-	// 基本信息
-	const config = ref({ logoUrl: [] });
+	// 字段
+	const field = ref('');
 	const CityName = ref('');
 	const LatterName = ref(['全', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']);
 	const CityList = ref($config.china);
 	const LetterId = ref('');
-	onLoad(async () => {
-		await searchConfig();
-		await search();
+	onLoad(async (options) => {
+		field.value = options && options.field || ''
 	})
-	// config信息
-	const searchConfig = async () => {
-		config.value = uni.getStorageSync('config');
-	};
-
-	// 查询
-	const search = async () => {
-
-	};
 	// 获取定位点
 	const getLetter = (name) => {
 		LetterId.value = name
@@ -58,6 +48,7 @@
 	};
 	// 存储城市缓存(点击城市)
 	const getStorage = (item) => {
+		item.field = field.value
 		uni.$emit('toCity', item)
 		// 4. 返回上一页面
 		uni.navigateBack({

+ 55 - 19
pagesHome/sell/index.vue

@@ -59,7 +59,7 @@
 								</template>
 							</u-form-item>
 							<u-form-item label="估值地区" prop="place">
-								<text class="picker" @tap="toCity">{{form.place?.name||'请选择'}}</text>
+								<text class="picker" @tap="toPlace">{{form.place?.name||'请选择'}}</text>
 								<template #right>
 									<u-icon name="arrow-right"></u-icon>
 								</template>
@@ -92,7 +92,7 @@
 </template>
 
 <script setup lang="ts">
-	import { getCurrentInstance, ref } from 'vue';
+	import { getCurrentInstance, reactive, ref } from 'vue';
 	//该依赖已内置不需要单独安装
 	import { onLoad, onShow } from "@dcloudio/uni-app";
 	// 请求接口
@@ -104,16 +104,52 @@
 	const agree = ref(false);
 	// 用户信息
 	const user = ref({});
-	const form = ref({ phone: "" });
-	const rules = ref({
-		phone: [
-			{
-				required: true,
-				message: '请输入手机号',
-				trigger: ['blur', 'change']
-			}
-		]
-	});
+	const form = reactive({ bank: '', type: '', start: '', course: '', place: '', city: '', tel: '' });
+	const rules = {
+		'bank': {
+			type: 'string',
+			required: true,
+			message: '请输入车辆车系',
+			trigger: ['blur', 'change'],
+		},
+		'type': {
+			type: 'string',
+			required: true,
+			message: '请输入车辆车型',
+			trigger: ['blur', 'change'],
+		},
+		'start': {
+			type: 'string',
+			required: true,
+			message: '请选择上牌日期',
+			trigger: ['blur', 'change'],
+		},
+		'course': {
+			type: 'string',
+			required: true,
+			message: '请选择行驶里程',
+			trigger: ['blur', 'change'],
+		},
+		'place': {
+			type: 'string',
+			required: true,
+			message: '请选择估值地区',
+			trigger: ['blur', 'change'],
+		},
+		'city': {
+			type: 'string',
+			required: true,
+			message: '请选择上牌城市',
+			trigger: ['blur', 'change'],
+		},
+		'tel': {
+			type: 'string',
+			required: true,
+			message: '请输入手机号',
+			trigger: ['blur', 'change'],
+		}
+	}
+	const uForm = ref(null);
 	// 字典表
 	const courseList = ref([{ value: '1', label: '1万公里' }, { value: '2', label: '2万公里' }, { value: '3', label: '3万公里' }, { value: '4', label: '4万公里' }, { value: '5', label: '5万公里' }]);
 	onLoad(async () => {
@@ -124,7 +160,7 @@
 			form.value.brand = data
 		})
 		uni.$on('toCity', function (data) {
-			form.value.city = data
+			form.value[data.field] = data
 		})
 	})
 	// config信息
@@ -143,13 +179,13 @@
 	// 选择上牌城市
 	const toCity = () => {
 		uni.navigateTo({
-			url: `/pagesHome/city/index`,
+			url: `/pagesHome/city/index?field=${'city'}`,
 		})
 	};
 	// 选择估值城市
 	const toPlace = () => {
 		uni.navigateTo({
-			url: `/pagesHome/city/index`,
+			url: `/pagesHome/city/index?field=${'place'}`,
 		})
 	};
 	// 选择品牌
@@ -161,10 +197,10 @@
 	// 估价
 	const toEvaluate = async () => {
 		if (agree.value) {
-			$refs.form.validate().then(res => {
-				uni.$u.toast('校验通过')
-			}).catch(errors => {
-				uni.$u.toast('校验失败')
+			uForm.value.validate().then(res => {
+				console.log(res, '成功');
+			}).catch(err => {
+				console.log(err, '校验失败');
 			})
 		} else {
 			uni.showToast({

+ 1 - 0
unpackage/dist/dev/mp-weixin/common/vendor.js

@@ -16805,6 +16805,7 @@ exports.props$6 = props$g;
 exports.props$7 = props$f;
 exports.props$8 = props$e;
 exports.props$9 = props$d;
+exports.reactive = reactive;
 exports.ref = ref;
 exports.resolveComponent = resolveComponent;
 exports.s = s;

+ 4 - 9
unpackage/dist/dev/mp-weixin/pagesHome/city/index.js

@@ -6,20 +6,14 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     var _a, _b;
     (_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 field = common_vendor.ref("");
     common_vendor.ref("");
     const LatterName = common_vendor.ref(["全", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]);
     const CityList = common_vendor.ref($config.china);
     const LetterId = common_vendor.ref("");
-    common_vendor.onLoad(async () => {
-      await searchConfig();
-      await search();
+    common_vendor.onLoad(async (options) => {
+      field.value = options && options.field || "";
     });
-    const searchConfig = async () => {
-      config.value = common_vendor.index.getStorageSync("config");
-    };
-    const search = async () => {
-    };
     const getLetter = (name) => {
       LetterId.value = name;
       common_vendor.index.pageScrollTo({
@@ -28,6 +22,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
       });
     };
     const getStorage = (item) => {
+      item.field = field.value;
       common_vendor.index.$emit("toCity", item);
       common_vendor.index.navigateBack({
         delta: 1

+ 79 - 36
unpackage/dist/dev/mp-weixin/pagesHome/sell/index.js

@@ -21,16 +21,52 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     const config = common_vendor.ref({});
     const agree = common_vendor.ref(false);
     common_vendor.ref({});
-    const form = common_vendor.ref({ phone: "" });
-    const rules = common_vendor.ref({
-      phone: [
-        {
-          required: true,
-          message: "请输入手机号",
-          trigger: ["blur", "change"]
-        }
-      ]
-    });
+    const form = common_vendor.reactive({ bank: "", type: "", start: "", course: "", place: "", city: "", tel: "" });
+    const rules = {
+      "bank": {
+        type: "string",
+        required: true,
+        message: "请输入车辆车系",
+        trigger: ["blur", "change"]
+      },
+      "type": {
+        type: "string",
+        required: true,
+        message: "请输入车辆车型",
+        trigger: ["blur", "change"]
+      },
+      "start": {
+        type: "string",
+        required: true,
+        message: "请选择上牌日期",
+        trigger: ["blur", "change"]
+      },
+      "course": {
+        type: "string",
+        required: true,
+        message: "请选择行驶里程",
+        trigger: ["blur", "change"]
+      },
+      "place": {
+        type: "string",
+        required: true,
+        message: "请选择估值地区",
+        trigger: ["blur", "change"]
+      },
+      "city": {
+        type: "string",
+        required: true,
+        message: "请选择上牌城市",
+        trigger: ["blur", "change"]
+      },
+      "tel": {
+        type: "string",
+        required: true,
+        message: "请输入手机号",
+        trigger: ["blur", "change"]
+      }
+    };
+    const uForm = common_vendor.ref(null);
     const courseList = common_vendor.ref([{ value: "1", label: "1万公里" }, { value: "2", label: "2万公里" }, { value: "3", label: "3万公里" }, { value: "4", label: "4万公里" }, { value: "5", label: "5万公里" }]);
     common_vendor.onLoad(async () => {
       await searchConfig();
@@ -40,7 +76,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         form.value.brand = data;
       });
       common_vendor.index.$on("toCity", function(data) {
-        form.value.city = data;
+        form.value[data.field] = data;
       });
     });
     const searchConfig = async () => {
@@ -56,7 +92,12 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     };
     const toCity = () => {
       common_vendor.index.navigateTo({
-        url: `/pagesHome/city/index`
+        url: `/pagesHome/city/index?field=${"city"}`
+      });
+    };
+    const toPlace = () => {
+      common_vendor.index.navigateTo({
+        url: `/pagesHome/city/index?field=${"place"}`
       });
     };
     const toSelect = () => {
@@ -66,10 +107,10 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     };
     const toEvaluate = async () => {
       if (agree.value) {
-        $refs.form.validate().then((res) => {
-          common_vendor.index.$u.toast("校验通过");
-        }).catch((errors) => {
-          common_vendor.index.$u.toast("校验失败");
+        uForm.value.validate().then((res) => {
+          console.log(res, "成功");
+        }).catch((err) => {
+          console.log(err, "校验失败");
         });
       } else {
         common_vendor.index.showToast({
@@ -89,8 +130,8 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
     return (_ctx, _cache) => {
       var _a2, _b2, _c, _d, _e, _f, _g, _h;
       return common_vendor.e({
-        a: !form.value.brand && !((_a2 = form.value.brand) == null ? void 0 : _a2.title)
-      }, !form.value.brand && !((_b2 = form.value.brand) == null ? void 0 : _b2.title) ? {
+        a: !form.brand && !((_a2 = form.brand) == null ? void 0 : _a2.title)
+      }, !form.brand && !((_b2 = form.brand) == null ? void 0 : _b2.title) ? {
         b: common_vendor.p({
           name: "plus-circle-fill",
           size: "20",
@@ -98,15 +139,15 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
         }),
         c: common_vendor.o(toSelect)
       } : {
-        d: ((_c = form.value.brand) == null ? void 0 : _c.url) && ((_d = form.value.brand) == null ? void 0 : _d.url.length) > 0 ? (_e = form.value.brand) == null ? void 0 : _e.url[0].url : "/static/logo.png",
-        e: common_vendor.t((_f = form.value.brand) == null ? void 0 : _f.title),
+        d: ((_c = form.brand) == null ? void 0 : _c.url) && ((_d = form.brand) == null ? void 0 : _d.url.length) > 0 ? (_e = form.brand) == null ? void 0 : _e.url[0].url : "/static/logo.png",
+        e: common_vendor.t((_f = form.brand) == null ? void 0 : _f.title),
         f: common_vendor.p({
           name: "arrow-right"
         }),
         g: common_vendor.o(toSelect)
       }, {
-        h: form.value.bank,
-        i: common_vendor.o(($event) => form.value.bank = $event.detail.value),
+        h: form.bank,
+        i: common_vendor.o(($event) => form.bank = $event.detail.value),
         j: common_vendor.p({
           name: "arrow-right"
         }),
@@ -114,8 +155,8 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "车辆车系",
           prop: "bank"
         }),
-        l: form.value.type,
-        m: common_vendor.o(($event) => form.value.type = $event.detail.value),
+        l: form.type,
+        m: common_vendor.o(($event) => form.type = $event.detail.value),
         n: common_vendor.p({
           name: "arrow-right"
         }),
@@ -123,7 +164,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "车辆车型",
           prop: "type"
         }),
-        p: common_vendor.t(form.value.start || "请选择"),
+        p: common_vendor.t(form.start || "请选择"),
         q: common_vendor.o(dateChange),
         r: common_vendor.p({
           name: "arrow-right"
@@ -132,7 +173,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "上牌日期",
           prop: "start"
         }),
-        t: common_vendor.t(form.value.course || "请选择"),
+        t: common_vendor.t(form.course || "请选择"),
         v: common_vendor.o(courseChange),
         w: _ctx.index,
         x: courseList.value,
@@ -143,7 +184,7 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "行驶里程",
           prop: "course"
         }),
-        A: common_vendor.t(((_g = form.value.city) == null ? void 0 : _g.name) || "请选择"),
+        A: common_vendor.t(((_g = form.city) == null ? void 0 : _g.name) || "请选择"),
         B: common_vendor.o(toCity),
         C: common_vendor.p({
           name: "arrow-right"
@@ -152,8 +193,8 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "上牌城市",
           prop: "city"
         }),
-        E: common_vendor.t(((_h = form.value.place) == null ? void 0 : _h.name) || "请选择"),
-        F: common_vendor.o(toCity),
+        E: common_vendor.t(((_h = form.place) == null ? void 0 : _h.name) || "请选择"),
+        F: common_vendor.o(toPlace),
         G: common_vendor.p({
           name: "arrow-right"
         }),
@@ -161,22 +202,24 @@ const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
           label: "估值地区",
           prop: "place"
         }),
-        I: form.value.contacts,
-        J: common_vendor.o(($event) => form.value.contacts = $event.detail.value),
+        I: form.contacts,
+        J: common_vendor.o(($event) => form.contacts = $event.detail.value),
         K: common_vendor.p({
           label: "联系人",
           prop: "contacts"
         }),
-        L: form.value.tel,
-        M: common_vendor.o(($event) => form.value.tel = $event.detail.value),
+        L: form.tel,
+        M: common_vendor.o(($event) => form.tel = $event.detail.value),
         N: common_vendor.p({
           label: "联系电话",
           prop: "tel"
         }),
-        O: common_vendor.sr("uForm", "1d378803-2"),
+        O: common_vendor.sr(uForm, "1d378803-2", {
+          "k": "uForm"
+        }),
         P: common_vendor.p({
-          model: form.value,
-          rules: rules.value,
+          model: form,
+          rules,
           labelWidth: "65",
           ["border-bottom"]: true
         }),