From c96f313ccfc3eee0fd9c29287c7bd5efec918c48 Mon Sep 17 00:00:00 2001 From: jiangyy Date: Thu, 18 Aug 2022 13:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E7=BB=8F=E7=BA=AC=E5=BA=A6?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../regionalParty/activitysForm.vue | 26 ++++++++++++------- .../regionalParty/unitsForm.vue | 26 ++++++++++++++----- .../modules/shequzhili/event/cpts/add.vue | 14 ++++++++-- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/src/views/modules/communityParty/regionalParty/activitysForm.vue b/src/views/modules/communityParty/regionalParty/activitysForm.vue index efd2c776a..94ce4234b 100644 --- a/src/views/modules/communityParty/regionalParty/activitysForm.vue +++ b/src/views/modules/communityParty/regionalParty/activitysForm.vue @@ -254,8 +254,8 @@ export default { peopleCount: 0,//服务人数 result: '', //活动结果 address: '', //详细地址 - longitude: 36.0722275, //经度 - latitude: 120.38945519 //纬度 + longitude: 120.38945519, //经度 + latitude: 36.0722275 //纬度 }, serviceList: [], // gridList: [], @@ -274,23 +274,31 @@ export default { async initForm (type, activityId) { this.startLoading() this.$refs.ref_form.resetFields(); - // const { user } = this.$store.state - // this.agencyId = user.agencyId - // await this.loadGrid() //获取服务事项 await this.loadService() + let { latitude, longitude } = this.$store.state.user; + if (!latitude || latitude == "" || latitude == "0") { + latitude = 39.9088810666821; + longitude = 116.39743841556731; + } + + this.formData.latitude = latitude + this.formData.longitude = longitude + this.formType = type if (activityId) { this.activityId = activityId this.formData.id = activityId await this.loadFormData() } else { - map.setCenter(new TMap.LatLng(36.0722275, 120.38945519)) - this.setMarker(36.0722275, 120.38945519) + } + + map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) + this.setMarker(this.formData.latitude, this.formData.longitude) this.endLoading() }, @@ -353,8 +361,8 @@ export default { } console.log(this.formData.content) - map.setCenter(new TMap.LatLng(parseFloat(this.formData.latitude), parseFloat(this.formData.longitude))) - this.setMarker(this.formData.latitude, this.formData.longitude) + // map.setCenter(new TMap.LatLng(parseFloat(this.formData.latitude), parseFloat(this.formData.longitude))) + // this.setMarker(this.formData.latitude, this.formData.longitude) } else { this.$message.error(msg) } diff --git a/src/views/modules/communityParty/regionalParty/unitsForm.vue b/src/views/modules/communityParty/regionalParty/unitsForm.vue index ac3965ea8..06b5eece2 100644 --- a/src/views/modules/communityParty/regionalParty/unitsForm.vue +++ b/src/views/modules/communityParty/regionalParty/unitsForm.vue @@ -189,8 +189,8 @@ export default { memberCount: 0, remark: '', //备注【最大500字】 address: '', //详细地址 - longitude: 36.0722275, //经度 - latitude: 120.38945519 //纬度 + longitude: 120.38945519, //经度 + latitude: 36.0722275//纬度 }, serviceList: [],//服务list @@ -198,6 +198,7 @@ export default { }, components: {}, mounted () { + this.initMap() }, @@ -210,16 +211,27 @@ export default { //获取服务事项 await this.loadService() + let { latitude, longitude } = this.$store.state.user; + if (!latitude || latitude == "" || latitude == "0") { + latitude = 39.9088810666821; + longitude = 116.39743841556731; + } + + this.formData.latitude = latitude + this.formData.longitude = longitude + this.formType = type if (unitId) { this.unitId = unitId this.formData.id = unitId await this.loadFormData() } else { - map.setCenter(new TMap.LatLng(36.0722275, 120.38945519)) - this.setMarker(36.0722275, 120.38945519) + } + map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) + this.setMarker(this.formData.latitude, this.formData.longitude) + this.endLoading() }, @@ -259,8 +271,8 @@ export default { } this.formData = { ...data } - map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) - this.setMarker(this.formData.latitude, this.formData.longitude) + // map.setCenter(new TMap.LatLng(this.formData.latitude, this.formData.longitude)) + // this.setMarker(this.formData.latitude, this.formData.longitude) } else { this.$message.error(msg) } @@ -329,7 +341,7 @@ export default { // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap () { // 定义地图中心点坐标 - var center = new window.TMap.LatLng(36.0722275, 120.38945519) + var center = new window.TMap.LatLng(this.formData.latitude, this.formData.longitude) // 定义map变量,调用 TMap.Map() 构造函数创建地图 map = new window.TMap.Map(document.getElementById('app'), { center: center, // 设置地图中心点坐标 diff --git a/src/views/modules/shequzhili/event/cpts/add.vue b/src/views/modules/shequzhili/event/cpts/add.vue index b53caf480..d3581582a 100644 --- a/src/views/modules/shequzhili/event/cpts/add.vue +++ b/src/views/modules/shequzhili/event/cpts/add.vue @@ -402,10 +402,20 @@ export default { async mounted () { const { user } = this.$store.state this.agencyId = user.agencyId + let { latitude, longitude } = this.$store.state.user; + if (!latitude || latitude == "" || latitude == "0") { + latitude = 39.9088810666821; + longitude = 116.39743841556731; + } + + this.formData.latitude = latitude + this.formData.longitude = longitude + + this.initMap() this.loadGrid(); this.getCategoryList() - this.initMap() + }, @@ -597,7 +607,7 @@ export default { // 地图初始化函数,本例取名为init,开发者可根据实际情况定义 initMap () { // 定义地图中心点坐标 - var center = new window.TMap.LatLng(36.0722275, 120.38945519) + var center = new window.TMap.LatLng(this.formData.latitude, this.formData.longitude) // 定义map变量,调用 TMap.Map() 构造函数创建地图 map = new window.TMap.Map(document.getElementById('app'), { center: center, // 设置地图中心点坐标