思路:1. 通过获取地理位置 uni.getLocation({ success(res) {
// 把这个获取地理位置成功回调里面的 当前经纬度数据保存到this.position
that.position = res }
})
2. 把后端接口返回的经纬度数据通过实参保存到enhance方法:
that.enhance(res.data);//把数据传给enhance获取经纬度的方法
3. 定义的enhance方法调用封装经纬度的方法
that.getDistance(d.latitude, d.longitude, address.latitude, address.longitude)
把 uni.getLocation的经纬度和后端传过来的经纬度数据赋值给 d.distance字段 ,
stores.vue:
<!-- 查询出来的数据 -->
<block v-for="(item,index) in QueryList" :key="index"><navigator :url="'/filepage/storesdetails/storesdetails?cid=' + item.id + '&name=' + item.name">
<view class="query">
<view style="