Commit 0f64bc1c authored by 刘用法's avatar 刘用法

定位和推荐订单距离

parent b528f4ed
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<text>{{orderData.contactAddress }}</text> <text>{{orderData.contactAddress }}</text>
</view> </view>
<view v-if="showDistance"> <view v-if="showDistance">
{{getDistance(orderData.contactAddressLatitud,orderData.contactAddressLongitud)}}km {{orderDistance}}km
</view> </view>
</view> </view>
</view> </view>
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
return this.orderType == 5 return this.orderType == 5
}, },
showDistance() { showDistance() {
return this.orderType == 0 return this.orderType == 0 && this.orderData.contactAddressLatitud && this.orderData.contactAddressLongitud && this.location[0] && this.location[1]
}, },
types() { types() {
return { return {
...@@ -208,6 +208,9 @@ ...@@ -208,6 +208,9 @@
'exception': 5, // 异常单、 'exception': 5, // 异常单、
'finish': 6, //已完工 'finish': 6, //已完工
} }
},
orderDistance() {
return this.distance(this.orderData.contactAddressLatitud,this.orderData.contactAddressLongitud, this.location[0], this.location[1])
} }
}, },
created() { created() {
...@@ -265,9 +268,6 @@ ...@@ -265,9 +268,6 @@
}, 1000) }, 1000)
} }
}, },
getDistance(Latitud, Longitud) {
return this.distance(Latitud, Longitud, this.location[0], this.location[1])
},
/** /**
* echo distance(116.3896,39.91917,116.3940,39.91726); * echo distance(116.3896,39.91917,116.3940,39.91726);
* 计算两点之间直线距离 * 计算两点之间直线距离
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
data() { data() {
return { return {
status: 0, // 入驻状态:0=>'待提交',1=>'待审核',2=>'已通过',3=>'备选',4=>'已驳回',6=>'已签约',7=>'已支付保证金',8=>'已通过考试',9=>'待提交' status: 0, // 入驻状态:0=>'待提交',1=>'待审核',2=>'已通过',3=>'备选',4=>'已驳回',6=>'已签约',7=>'已支付保证金',8=>'已通过考试',9=>'待提交'
location: [116.3896, 39.91917], // 经纬度 location: [], // 经纬度
title: false, title: false,
title: "Hello", title: "Hello",
loaded: false, loaded: false,
...@@ -147,6 +147,7 @@ ...@@ -147,6 +147,7 @@
if (this.vuex_token) { if (this.vuex_token) {
this.initSettleInfo(); this.initSettleInfo();
} }
this.getLocation()
}, },
// onPullDownRefresh() { // onPullDownRefresh() {
// console.log('------下拉刷新------') // console.log('------下拉刷新------')
...@@ -365,6 +366,39 @@ ...@@ -365,6 +366,39 @@
} }
}); });
}, },
/**
* 获取当前位置的经纬度
*/
getLocation() {
let self = this
uni.getLocation({
type: 'gcj02',
success: function(res) {
self.location = [res.longitude, res.latitude]
},
complete: function(res) {
if (res.errMsg.indexOf('auth') != -1) {
uni.showModal({
title: '提示',
content: '获取权限失败,请到设置页面开启权限',
confirmText: '好的',
success(res) {
if (res.confirm) {
uni.openSetting({
success(res) {
console.log(res.authSetting)
}
});
}
}
})
}
},
fail: function(err) {
}
});
},
}, },
}; };
</script> </script>
......
...@@ -92,7 +92,7 @@ ...@@ -92,7 +92,7 @@
}, },
onLoad() { onLoad() {
this._freshing = false; this._freshing = false;
this.getLocation(); // this.getLocation(); // 不需要获取位置
// this.getOrderCount(); // this.getOrderCount();
// this.getOrderList(0); // this.getOrderList(0);
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment