From 8db7b22fd841e052f3984ee9e6bab11b04d1ee61 Mon Sep 17 00:00:00 2001 From: zhl Date: Wed, 21 Apr 2021 13:53:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BA=97=E9=93=BA=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/map.ts | 11 ++ src/components/RegionPicker/index.vue | 2 +- src/views/shop/edit.vue | 157 +++++++++++++++----------- 3 files changed, 103 insertions(+), 67 deletions(-) create mode 100644 src/api/map.ts diff --git a/src/api/map.ts b/src/api/map.ts new file mode 100644 index 0000000..1147615 --- /dev/null +++ b/src/api/map.ts @@ -0,0 +1,11 @@ +import request from '@/utils/request' + +export async function queryArea(str: string, region: string) { + let data = {keyword: str, region} + return request({ + url: '/area/query', + method: 'post', + data + }) + +} diff --git a/src/components/RegionPicker/index.vue b/src/components/RegionPicker/index.vue index 2f9c667..1487e82 100644 --- a/src/components/RegionPicker/index.vue +++ b/src/components/RegionPicker/index.vue @@ -4,7 +4,7 @@ v-model="areaSelect" filterable size="medium" - style="width: 300px" + style="width: 50%" v-on:change="valchange"> diff --git a/src/views/shop/edit.vue b/src/views/shop/edit.vue index 3a692d1..4a676d2 100644 --- a/src/views/shop/edit.vue +++ b/src/views/shop/edit.vue @@ -1,82 +1,65 @@ @@ -91,6 +74,7 @@ import UploadImage from '@/components/UploadImage/index.vue' import RegionPicker from '@/components/RegionPicker/index.vue' import { Form } from 'element-ui' import { defaultShopData, getShop, saveShop } from '@/api/shop' +import { queryArea } from '@/api/map' @Component({ name: 'ShopEditor', @@ -130,6 +114,7 @@ export default class extends Vue { } private tempTagView?: ITagView + private shopListOptions = [] get lang() { @@ -197,7 +182,15 @@ export default class extends Vue { return false } } - + private async onCancel() { + await this.$confirm('确认不保存当前店铺信息?', 'Warning', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + this.$store.dispatch("delView", this.$route) + this.$router.go(-1) + } private draftForm() { this.$message({ message: 'The draft saved successfully', @@ -212,6 +205,38 @@ export default class extends Vue { this.postForm.areaStr = val } + /** + * begin of tencent map + */ + private async queryShop(val: string) { + if (!val || val.length < 2) { + return + } + let { data } = await queryArea(val, '上海') + this.shopListOptions.length = 0 + for(let d of data.records) { + d.showStr = `${d.title}(${d.city}-${d.district})` + } + this.shopListOptions = data.records + } + private areaSelectChange(val: any) { + let result + for (let d of this.shopListOptions) { + if (d.title == val) { + result = d + break + } + } + console.log(result) + if (result) { + this.postForm.address = result.address + this.postForm.areaCode = result.adcode + } + } + + /** + * end of tencent map + */ }