Browse Source

Change 前端复用传入的地理位置信息,不做重复查询

microapp 3 years ago
parent
commit
35e74ebbd0

+ 2 - 1
flash-waimai-api/src/main/java/cn/enilu/flash/api/controller/business/ShopController.java

@@ -127,9 +127,10 @@ public class ShopController extends BaseController {
                 List list = Lists.newArrayList();
                 for (int i = 0; i < geoResultList.size(); i++) {
                     Map map = geoResultList.get(i).getContent();
+
                     Distance distance = new Distance(Double.valueOf(longitude), Double.valueOf(latitude),
                             Double.valueOf(map.get("longitude").toString()), Double.valueOf(map.get("latitude").toString()));
-                    map.put("distance", distance.getDistance());
+                    map.put("distance", distance.getDistance().intValue());
 
                     map.put("order_lead_time", "30分钟");
                     list.add(map);

+ 5 - 3
flash-waimai-mobile/src/page/city/city.vue

@@ -13,7 +13,7 @@
     </form>
     <header v-if="historytitle" class="pois_search_history">搜索历史</header>
     <ul class="getpois_ul">
-      <li v-for="(item, index) in placelist" @click='nextpage(index, item.location)' :key="index">
+      <li v-for="(item, index) in placelist" @click='nextpage(index, item)' :key="index">
         <h4 class="pois_name ellipsis">{{item.name}}</h4>
         <p class="pois_address ellipsis">{{item.address}}</p>
       </li>
@@ -80,7 +80,9 @@
        * 点击搜索结果进入下一页面时进行判断是否已经有一样的历史记录
        * 如果没有则新增,如果有则不做重复储存,判断完成后进入下一页
        */
-      nextpage(index, geohash) {
+      nextpage(index, item) {
+        console.log('item',item)
+        const geohash = item.location
         let history = getStore('placeHistory');
         let choosePlace = this.placelist[index];
         if (history) {
@@ -98,7 +100,7 @@
           this.placeHistory.push(choosePlace)
         }
         setStore('placeHistory', this.placeHistory)
-        this.$router.push({path: '/msite', query: {'geohash': geohash.lat + ',' + geohash.lng}})
+        this.$router.push({path: '/msite', query: {'geohash': geohash.lat + ',' + geohash.lng,'address':item.address}})
       },
       clearAll() {
         removeStore('placeHistory');

+ 7 - 3
flash-waimai-mobile/src/page/msite/index.js

@@ -17,19 +17,23 @@ export default {
     }
   },
   async beforeMount() {
+    let address = ''
     if (!this.$route.query.geohash) {
       const address = await cityGuess();
       this.geohash = address.latitude + ',' + address.longitude;
     } else {
       this.geohash = this.$route.query.geohash
+      address = this.$route.query.address
     }
+    console.log('geohash',this.geohash)
     //保存geohash 到vuex
     this.SAVE_GEOHASH(this.geohash);
     //获取位置信息
-    let res = await msiteAddress(this.geohash);
-    this.msiteTitle = res.name;
+    // let res = await msiteAddress(this.geohash);
+    this.msiteTitle =address;
     // 记录当前经度纬度
-    this.RECORD_ADDRESS(res);
+    const latAndLng = this.geohash.split(',')
+    this.RECORD_ADDRESS({latitude:latAndLng[0],longitude:latAndLng[1]});
 
     this.hasGetData = true;
   },

+ 1 - 2
flash-waimai-mobile/src/store/mutations.js

@@ -163,13 +163,12 @@ export default {
 	},
 	//选择搜索的地址
 	[CHOOSE_SEARCH_ADDRESS](state, place) {
-	  console.log('place',place);
 		state.searchAddress = place;
 	},
 	//保存geohash
 	[SAVE_GEOHASH](state, geohash) {
 		state.geohash = geohash;
-		
+
 	},
 	//确认订单页添加新的的地址
 	[CONFIRM_ADDRESS](state, newAddress) {