Commit e980dc851acf94a0d49619c8e41b577edc599030

Authored by wangfan
1 parent 123b70da

getpos

// components/userinfo/getpos.js
Component({
/**
* 组件的属性列表
*/
properties: {},
/**
* 组件的初始数据
*/
data: {},
attached(){
//this.getPos()
},
/**
* 组件的方法列表
*/
methods: {
getPos(){
this._getPos().then(res => {
console.log('wx.getLocation.then', res);
this.triggerEvent("pos",res);
}).catch((e) => {
console.log('wx.getLocation.catch', e);
if ('getLocation:fail auth deny' == e.errMsg
|| 'getLocation:fail:auth denied' == e.errMsg
|| 'getLocation:fail authorize no response' == e.errMsg) {
this.selectComponent('#showModal').options({
header: '定位失败',
body: '需要地理位置授权'
}).show();
} else {
setTimeout(() => {
this.getPos()
}, 500)
}
})
},
_getPos(){
return new Promise((success, fail) => {
wx.getLocation({
type: 'gcj02',
success: (res) => {
success(res)
},
fail: (res) => {
fail(res)
},
complete: (res) => {
console.log('wx.getLocation', res)
}
});
})
},
showModal(e){
wx.openSetting()
},
}
})
... ...
{
"component": true,
"usingComponents": {
"showModal":"/components/showModal/showModal"
}
}
\ No newline at end of file
... ...
<!--components/userinfo/getpos.wxml-->
<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal>
... ...
/* components/userinfo/getpos.wxss */
\ No newline at end of file
... ...
... ... @@ -62,7 +62,7 @@ Page({
this.setData({
sellers:[]
})
this.getPos()
this.selectComponent('#getpos').getPos();
}
},
... ... @@ -135,50 +135,14 @@ Page({
this.sellers=sellers
})
},
getPos(){
this._getPos().then(res => {
console.log('wx.getLocation.then', res);
this.location=res
this.GetCollectionSellerList();
}).catch((e) => {
console.log('wx.getLocation.catch', e);
if ('getLocation:fail auth deny' == e.errMsg
|| 'getLocation:fail:auth denied' == e.errMsg
|| 'getLocation:fail authorize no response' == e.errMsg) {
this.selectComponent('#showModal').options({
header: '定位失败',
body: '需要地理位置授权'
}).show();
} else {
setTimeout(() => {
this.getPos()
}, 500)
}
})
},
_getPos(){
return new Promise((success, fail) => {
wx.getLocation({
type: 'gcj02',
success: (res) => {
success(res)
},
fail: (res) => {
fail(res)
},
complete: (res) => {
console.log('wx.getLocation', res)
}
});
})
},
gotoDetail(e){
wx.navigateTo({
url:'/pages/reserve/detail?id='+util.attr(e,'sid')
})
},
showModal(e){
wx.openSetting()
onpos(e){
console.log(e);
this.location=e.detail
this.GetCollectionSellerList();
},
})
\ No newline at end of file
... ...
... ... @@ -4,7 +4,7 @@
"navigationBarTitleText":"一键订",
"usingComponents": {
"formids":"/components/formids/formids",
"showModal":"/components/showModal/showModal",
"getpos":"/components/userinfo/getpos",
"sb-tr":"/components/reserve/seller-box-transverse/seller-box",
"nav":"/components/nav/nav"
}
... ...
... ... @@ -13,4 +13,4 @@
<view class="seller flex-vc" wx:if="{{!hasMore}}">没有更多了</view>
</view>
</view>
<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal>
\ No newline at end of file
<getpos bindpos="onpos" id="getpos"></getpos>
\ No newline at end of file
... ...
... ... @@ -114,7 +114,9 @@ Page({
statusBarHeight: pt,
titleBarHeight:h,
})
this.getPos(systemInfo);
//this.getPos(systemInfo);
this.systemInfo=systemInfo
this.selectComponent('#getpos').getPos();
this.getMarkers();
},
... ... @@ -152,68 +154,30 @@ Page({
onShareAppMessage: function () {
},
getPos(systemInfo){
this._getPos().then(res => {
console.log('wx.getLocation.then', res);
this.hasGetLocation=true;
let map = this.data.map;
map.latitude = res.latitude;
map.longitude = res.longitude;
onpos(e){
let res=e.detail;
this.hasGetLocation=true;
let map = this.data.map;
map.latitude = res.latitude;
map.longitude = res.longitude;
this.user.latitude = res.latitude;
this.user.longitude = res.longitude;
console.log('onShow.getPos',systemInfo,getApp().system.windowHeight-this.transverseViewHeight)
map.height = systemInfo.windowHeight-this.transverseViewHeight
this.setData({
map: map,
})
this.user.latitude = res.latitude;
this.user.longitude = res.longitude;
map.height = this.systemInfo.windowHeight-this.transverseViewHeight
this.setData({
map: map,
})
if(this.mapCtx){
this.mapCtx.getRegion({
success:(res)=>{
console.log('regionchange.getRegion',res)
//if(res.southwest.latitude!=this.mapData.region.southwest.latitude) {
this.mapData.region = res
//this.getMarkers();
this.mapData.region = res
//this.getMarkers();
//}
},
})
}).catch((e) => {
this.hasGetLocation=false;
console.log('wx.getLocation.catch', e);
if ('getLocation:fail auth deny' == e.errMsg
|| 'getLocation:fail:auth denied' == e.errMsg
|| 'getLocation:fail authorize no response' == e.errMsg) {
this.selectComponent('#showModal').options({
header: '定位失败',
body: '需要地理位置授权'
}).show();
} else {
setTimeout(() => {
this.getPos(systemInfo)
}, 500)
}
})
},
_getPos(){
return new Promise((success, fail) => {
wx.getLocation({
type: 'gcj02',
success: (res) => {
success(res)
},
fail: (res) => {
fail(res)
},
complete: (res) => {
console.log('wx.getLocation', res)
}
});
})
},
showModal(e){
wx.openSetting()
}
},
regionchange(e){
console.log('regionchange', e)
... ...
... ... @@ -5,7 +5,7 @@
"usingComponents": {
"formids":"/components/formids/formids",
"nav":"/components/nav/nav",
"showModal":"/components/showModal/showModal",
"getpos":"/components/userinfo/getpos",
"sb-tr":"/components/reserve/seller-box-transverse/seller-box",
"a2l":"/components/tips/add-to-lite"
}
... ...
... ... @@ -64,7 +64,7 @@
<cover-view bindtap="moveToLocation" class="moveToLocation">
<cover-image src="http://qn.colorcun.com/custom/lite-yd/image/location.png"></cover-image>
</cover-view>
<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal>
<getpos bindpos="onpos" id="getpos"></getpos>
<seller-box id="seller-box" bindevent="sellerBoxEvent"></seller-box>
<cover-view class="tab-patch"></cover-view>
<a2l bindshow="a2lshow" bindhide="a2lhide"></a2l>
... ...