Commit 491c9d48a50148b04cce7542db6338faab837132

Authored by wangfan
1 parent 6b43e9a2

C端调整

... ... @@ -5,9 +5,13 @@ Component({
* 组件的属性列表
*/
properties: {
hasAllowFail:{
hasAllowFail:{//强制获取定位
type:Boolean,
value:false,
},
hasAllowaAuthDeny:{//是否允许用户拒绝
type:Boolean,
value:true,
}
},
... ... @@ -22,7 +26,7 @@ Component({
* 组件的方法列表
*/
methods: {
getPos(){
getPos(fouce=false){
this._getPos().then(res => {
console.log('wx.getLocation.then', res);
failCount=0;
... ... @@ -45,8 +49,10 @@ Component({
success:()=>{
console.log('wx.showModal::success,给默认坐标');
this.triggerEvent("pos",{
latitude: 39.6846701,
longitude: 118.1763001,
//latitude: 39.6846701,
//longitude: 118.1763001,
latitude:'',
longitude:'',
});
},
})
... ... @@ -55,11 +61,18 @@ Component({
if ('getLocation:fail auth deny' == e.errMsg
|| 'getLocation:fail:auth denied' == e.errMsg
|| 'getLocation:fail authorize no response' == e.errMsg) {
failCount=0;
if(this.data.hasAllowaAuthDeny && !fouce){
this.triggerEvent("pos",{
latitude: '',
longitude: '',
});
return;
}
this.selectComponent('#showModal').options({
header: '定位失败',
body: '需要地理位置授权'
}).show();
failCount=0;
} else {
failCount=failCount+1;
setTimeout(() => {
... ... @@ -71,9 +84,14 @@ Component({
_getPos(){
return new Promise((success, fail) => {
let rex={latitude:'',longitude:''};
wx.showLoading({
title: '包间查找中',
})
let hasSuccess=false;
wx.getLocation({
type: 'gcj02',
success: (res) => {
hasSuccess=true;
rex=res;
success(res)
},
... ... @@ -81,11 +99,15 @@ Component({
fail(res)
},
complete: (res) => {
wx.hideLoading()
console.log('wx.getLocation', res)
}
});
setTimeout(()=>{
success(rex)
if(!hasSuccess){
success(rex)
wx.hideLoading()
}
},2000)
})
},
... ...
... ... @@ -178,6 +178,7 @@ Page({
onpos(e){
let res=e.detail;
this.hasGetLocation=true;
if(!res.latitude) return;
let map = this.data.map;
map.latitude = res.latitude;
map.longitude = res.longitude;
... ... @@ -365,8 +366,8 @@ Page({
}
let markers = [];
let param={
lat: this.user.latitude==39.6846701?'':this.user.latitude,
lng: this.user.longitude==118.1763001?'':this.user.longitude,
lat: this.user.latitude==def_latitude?'':this.user.latitude,
lng: this.user.longitude==def_longitude?'':this.user.longitude,
offset: 0,
rows: 50,
distance: 100000,
... ... @@ -484,8 +485,12 @@ Page({
wx.showTabBar();
},
moveToLocation(){
if(this.user.latitude==def_latitude){
this.selectComponent('#getpos').getPos(true);
return;
}
let map=this.data.map;
console.log(this.user.latitude,this.mapData.latitude);
console.log(this.user.latitude,this.mapData.latitude,def_latitude);
if(this.user.latitude==this.mapData.latitude && this.user.longitude==this.mapData.longitude) return;
map.latitude=this.user.latitude
map.longitude=this.user.longitude
... ...