Commit 9d445368 authored by Mac's avatar Mac

1

parent bf713b32
...@@ -267,15 +267,7 @@ ...@@ -267,15 +267,7 @@
this.amapPlugin.getRegeo({ this.amapPlugin.getRegeo({
success: (data) => { success: (data) => {
console.log(data,'获取当前位置')
this.address =data[0].name
this.Pickcar = data[0].regeocodeData.addressComponent.city; this.Pickcar = data[0].regeocodeData.addressComponent.city;
this.latitude = data[0].latitude;
this.longitude = data[0].longitude;
let parseResult = AddressParse(this.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
this.getDestination(nameList);
uni.hideLoading();
} }
}); });
} , } ,
...@@ -449,38 +441,27 @@ ...@@ -449,38 +441,27 @@
scope: 'scope.userLocation', scope: 'scope.userLocation',
success() { success() {
// console.log('前用户发起授权请求') // console.log('前用户发起授权请求')
uni.chooseLocation({ if(that.latitude!='' && that.longitude!=''){
latitude:that.latitude, that.getYLocation()
longitude:that.longitude, }else{
success: function (res) { that.getNLocation()
that.latitude = res.latitude;
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
} }
});
}, },
fail() { fail() {
// 用户点击不允许引导重新获取授权 // 用户点击不允许引导重新获取授权
console.log('111')
that.fetchAgainLocation() that.fetchAgainLocation()
} }
}) })
} else { } else {
// 已经授权了就会直接进入地图 // 已经授权了就会直接进入地图
uni.chooseLocation({
latitude:that.latitude, if(that.latitude!='' && that.longitude!=''){
longitude:that.longitude, that.getYLocation()
success: function (res) { }else{
that.latitude = res.latitude; that.getNLocation()
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
} }
});
} }
} }
}) })
...@@ -492,7 +473,7 @@ ...@@ -492,7 +473,7 @@
let that = this let that = this
wx.getSetting({ wx.getSetting({
success: (res) => { success: (res) => {
console.log() console.log(res)
var statu = res.authSetting; var statu = res.authSetting;
if (!statu['scope.userLocation']) { if (!statu['scope.userLocation']) {
wx.showModal({ wx.showModal({
...@@ -508,18 +489,11 @@ ...@@ -508,18 +489,11 @@
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
uni.chooseLocation({ if(that.latitude!='' && that.longitude!=''){
latitude:this.latitude, that.getYLocation()
longitude:this.longitude, }else{
success: function (res) { that.getNLocation()
that.latitude = res.latitude;
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
} }
});
} else { } else {
wx.showToast({ wx.showToast({
title: '授权失败', title: '授权失败',
...@@ -540,6 +514,36 @@ ...@@ -540,6 +514,36 @@
complete: ()=>{} complete: ()=>{}
}) })
}, },
getYLocation(){
console.log('you')
let that = this
uni.chooseLocation({
longitude:that.longitude,
latitude:that.latitude,
success: function (res) {
that.latitude = res.latitude;
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}
});
},
getNLocation(){
console.log('no')
let that = this
uni.chooseLocation({
success: function (res) {
that.latitude = res.latitude;
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}
});
},
getDestination(nameList) { getDestination(nameList) {
this.request2( this.request2(
{ {
......
...@@ -531,22 +531,12 @@ ...@@ -531,22 +531,12 @@
scope: 'scope.userLocation', scope: 'scope.userLocation',
success() { success() {
// console.log('前用户发起授权请求') // console.log('前用户发起授权请求')
uni.chooseLocation({ if(that.latitude!='' && that.longitude!=''){
latitude: that.latitude, that.getYLocation()
longitude: that.longitude,
success: function(res) {
if(that.isShowStart==1){
that.latitude = res.latitude;
that.longitude = res.longitude;
that.msg.ShoppingAddress = res.address
let parseResult = AddressParse(that.msg.ShoppingAddress, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}else{ }else{
that.orderMsg.DestinationAddress = res.address; that.getNLocation()
} }
}
});
}, },
fail() { fail() {
// 用户点击不允许引导重新获取授权 // 用户点击不允许引导重新获取授权
...@@ -555,23 +545,12 @@ ...@@ -555,23 +545,12 @@
}) })
} else { } else {
// 已经授权了就会直接进入地图 // 已经授权了就会直接进入地图
uni.chooseLocation({ if(that.latitude!='' && that.longitude!=''){
latitude: that.latitude, that.getYLocation()
longitude: that.longitude,
success: function(res) {
if(that.isShowStart==1){
that.latitude = res.latitude;
that.longitude = res.longitude;
that.msg.ShoppingAddress = res.address
let parseResult = AddressParse(that.msg.ShoppingAddress, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}else{ }else{
that.orderMsg.DestinationAddress = res.address; that.getNLocation()
} }
} }
});
}
} }
}) })
...@@ -597,18 +576,12 @@ ...@@ -597,18 +576,12 @@
icon: 'success', icon: 'success',
duration: 1000 duration: 1000
}) })
uni.chooseLocation({ if(that.latitude!='' && that.longitude!=''){
latitude:that.latitude, that.getYLocation()
longitude:that.longitude, }else{
success: function (res) { that.getNLocation()
that.latitude = res.latitude;
that.longitude = res.longitude;
that.address = res.address
let parseResult = AddressParse(that.address, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
} }
});
} else { } else {
wx.showToast({ wx.showToast({
title: '授权失败', title: '授权失败',
...@@ -629,6 +602,44 @@ ...@@ -629,6 +602,44 @@
complete: ()=>{} complete: ()=>{}
}) })
}, },
getYLocation(){
console.log('you')
let that = this
uni.chooseLocation({
latitude: that.latitude,
longitude: that.longitude,
success: function(res) {
if(that.isShowStart==1){
that.latitude = res.latitude;
that.longitude = res.longitude;
that.msg.ShoppingAddress = res.address
let parseResult = AddressParse(that.msg.ShoppingAddress, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}else{
that.orderMsg.DestinationAddress = res.address;
}
}
});
},
getNLocation(){
console.log('no')
let that = this
uni.chooseLocation({
success: function(res) {
if(that.isShowStart==1){
that.latitude = res.latitude;
that.longitude = res.longitude;
that.msg.ShoppingAddress = res.address
let parseResult = AddressParse(that.msg.ShoppingAddress, 0)
let nameList = [parseResult.province, parseResult.city, parseResult.area];
that.getDestination(nameList);
}else{
that.orderMsg.DestinationAddress = res.address;
}
}
});
},
//获取数据 //获取数据
getData() { getData() {
this.request2({ this.request2({
......
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