diff --git a/components/lf-nav/lf-nav.vue b/components/lf-nav/lf-nav.vue index 24bd4fa..a0d19f0 100644 --- a/components/lf-nav/lf-nav.vue +++ b/components/lf-nav/lf-nav.vue @@ -10,7 +10,7 @@ - + 地图 diff --git a/pages/search/search.vue b/pages/search/search.vue index a5e0e3a..0ffef11 100644 --- a/pages/search/search.vue +++ b/pages/search/search.vue @@ -95,6 +95,8 @@ uni.navigateTo({ url: '/pages/search/searchList?start_place=' + this.start_place+'&target_place='+this.target_place }) + this.start_place = ''; + this.target_place = ''; }, tabChange(index){ this.current = index; diff --git a/pages/shopmap/index.vue b/pages/shopmap/index.vue index b90a3b8..e5862b1 100644 --- a/pages/shopmap/index.vue +++ b/pages/shopmap/index.vue @@ -42,23 +42,23 @@ --> - + - + - {{item.title}} - + {{item.title}} + - - 瑞希开发 + + {{item.address}} | {{item.distance_m | kmUnit}} - + @@ -86,17 +86,7 @@ tab_list_father: [], current_father: 0, windowHeight: 0, - markers_list: [ - { - id: 0, - name: '时尚', - address: '杭州市', - latitude: 30.353351, - longitude: 120.231010, - width: 50, - height: 50 - } - ], + markers_list: [], self_latitude: '', self_longitude: '', //排序 @@ -149,7 +139,32 @@ this.windowHeight = getApp().globalData.windowHeight; this.getShopDistance(); }, + filters: { + kmUnit(m){ + var v; + if(typeof m === 'number' && !isNaN(m)){ + if (m >= 1000) { + v = (m / 1000).toFixed(2) + 'km' + } else { + v = m + 'm' + } + }else{ + v = '0m' + } + return v; + } + }, methods: { + // 打开地图 + openMap(address, lat, lng) { + // let { address, lat, lng } = this.goods_detail?.store || {}; + uni.openLocation({ + longitude: Number(lng), + latitude: Number(lat), + scale: 20, + name: address + }); + }, //获取当前位置 计算商店距离 getShopDistance() { let that = this; @@ -206,10 +221,7 @@ list.push(item) } }) - console.log(list) this.tab_list_father = list; - - console.log(this.tab_list_father) this.getActivityList() }).catch(err => { @@ -259,11 +271,12 @@ } }, getActivityList(){ - let tab_item = this.tab_list_father[this.current_father]; + let tab_item1 = this.tab_list_father[this.current_father]; + let tab_item = this.tab_list[this.current]; let sort_type = this.tab_list[this.current].type; console.log('页数',tab_item.id) if(this.$shared.isValueType(tab_item) == 'undefined') return; - this.$http(this.API.API_ADVICELIST,{page: tab_item.page,category_id: tab_item.id,type: sort_type,by: this.sort}).then(res => { + this.$http(this.API.API_ADVICELIST,{lat: this.self_latitude,lng: this.self_longitude,page: tab_item.page,category_id: tab_item1.id,type: sort_type,by: this.sort}).then(res => { let isPage = res.data.next_page_url == null?false:true; tab_item.isPage = isPage; if(!isPage){ @@ -278,6 +291,20 @@ }else{ tab_item.list.push(...res.data.data); } + + let res_list = res.data.data || []; + let markers_self = res_list.map(item => { + return { + id: item.id, + name: item.title, + address: item.address, + latitude: item.latitude, + longitude: item.logitude, + width: 30, + height: 30 + } + }); + this.markers_list = markers_self }).catch(err => { })