diff --git a/.editorconfig b/.editorconfig
index 8a13ac4..bc23fc8 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,7 +12,7 @@ max_line_length = 150
[*.md]
trim_trailing_whitespace = false
-[*.{yml,yaml}]
+[*.{yml,yaml,js,html,css,scss}]
indent_size = 2
[docker-compose.yml]
diff --git a/public/static/testdrive.html b/public/static/testdrive.html
index c687a03..bf2da25 100644
--- a/public/static/testdrive.html
+++ b/public/static/testdrive.html
@@ -1,153 +1,155 @@
-
-
-
- 留资表单
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 我已经阅读并同意
- 隐私条款
-
-
-
- 提交
-
-
-
+
+
+
+
留资表单
+
+
+
+
+
+
+
+
+
+
+
-
-
+ },
+ methods: {
+ async init() {
+ this.vehicles = await http(`${api}/vehicle`);
+ },
+ async getProvince({ vehicle }) {
+ this.provinces = await http(`${api}/province?vehicle=${vehicle}`);
+ },
+ async getCity({ vehicle, province }) {
+ this.cities = await http(`${api}/city?vehicle=${vehicle}&province=${province}`);
+ },
+ async getDealer({ vehicle, province, city }) {
+ this.dealers = await http(`${api}/dealer?vehicle=${vehicle}&province=${province}&city=${city}`);
+ },
+ async vehicleFn() {
+ Object.assign(this.userdata, { province: "", city: "", dealer: "" });
+ this.provinces = [];
+ this.cities = [];
+ this.dealers = [];
+ await this.getProvince(this.userdata);
+ },
+ async provinceFn() {
+ Object.assign(this.userdata, { city: "", dealer: "" });
+ this.cities = [];
+ this.dealers = [];
+ await this.getCity(this.userdata);
+ },
+ async cityFn() {
+ Object.assign(this.userdata, { dealer: "" });
+ await this.getDealer(this.userdata);
+ },
+ async submitFn() {
+ if (this.isLoading) return;
+ if (!this.isAgree) {
+ this.$message({ message: "请先阅读并同意隐私条款", type: "info" });
+ return;
+ }
+ if (!this.userdata.name || !this.userdata.mobile) {
+ this.$message({ message: "请填写姓名和电话", type: "info" });
+ return;
+ }
+ this.isLoading = true;
+ const resp = await http(`${api}/testdrive`, "POST", { ...this.userdata }).catch((err) => null);
+ this.isLoading = false;
+ if (resp === null) {
+ this.$message({ message: "网络错误", type: "error" });
+ return;
+ }
+ const { code, message } = resp;
+ if (code === 0) {
+ this.userdata = { name: "", mobile: "", vehicle: "", province: "", city: "", dealer: "" };
+ this.$message({ message, type: "success" });
+ } else {
+ this.$message({ message, type: "warning" });
+ }
+ },
+ },
+ mounted() {
+ // this.init();
+ },
+ });
+