Showing
10 changed files
with
97 additions
and
100 deletions
components/userinfo/getpos.js
0 → 100644
| 1 | +// components/userinfo/getpos.js | ||
| 2 | +Component({ | ||
| 3 | + /** | ||
| 4 | + * 组件的属性列表 | ||
| 5 | + */ | ||
| 6 | + properties: {}, | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * 组件的初始数据 | ||
| 10 | + */ | ||
| 11 | + data: {}, | ||
| 12 | + attached(){ | ||
| 13 | + //this.getPos() | ||
| 14 | + }, | ||
| 15 | + /** | ||
| 16 | + * 组件的方法列表 | ||
| 17 | + */ | ||
| 18 | + methods: { | ||
| 19 | + getPos(){ | ||
| 20 | + this._getPos().then(res => { | ||
| 21 | + console.log('wx.getLocation.then', res); | ||
| 22 | + this.triggerEvent("pos",res); | ||
| 23 | + }).catch((e) => { | ||
| 24 | + console.log('wx.getLocation.catch', e); | ||
| 25 | + if ('getLocation:fail auth deny' == e.errMsg | ||
| 26 | + || 'getLocation:fail:auth denied' == e.errMsg | ||
| 27 | + || 'getLocation:fail authorize no response' == e.errMsg) { | ||
| 28 | + this.selectComponent('#showModal').options({ | ||
| 29 | + header: '定位失败', | ||
| 30 | + body: '需要地理位置授权' | ||
| 31 | + }).show(); | ||
| 32 | + } else { | ||
| 33 | + setTimeout(() => { | ||
| 34 | + this.getPos() | ||
| 35 | + }, 500) | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + }) | ||
| 39 | + }, | ||
| 40 | + _getPos(){ | ||
| 41 | + return new Promise((success, fail) => { | ||
| 42 | + wx.getLocation({ | ||
| 43 | + type: 'gcj02', | ||
| 44 | + success: (res) => { | ||
| 45 | + success(res) | ||
| 46 | + }, | ||
| 47 | + fail: (res) => { | ||
| 48 | + fail(res) | ||
| 49 | + }, | ||
| 50 | + complete: (res) => { | ||
| 51 | + console.log('wx.getLocation', res) | ||
| 52 | + } | ||
| 53 | + }); | ||
| 54 | + }) | ||
| 55 | + }, | ||
| 56 | + showModal(e){ | ||
| 57 | + wx.openSetting() | ||
| 58 | + }, | ||
| 59 | + } | ||
| 60 | +}) |
components/userinfo/getpos.json
0 → 100644
components/userinfo/getpos.wxml
0 → 100644
components/userinfo/getpos.wxss
0 → 100644
| 1 | +/* components/userinfo/getpos.wxss */ |
| @@ -62,7 +62,7 @@ Page({ | @@ -62,7 +62,7 @@ Page({ | ||
| 62 | this.setData({ | 62 | this.setData({ |
| 63 | sellers:[] | 63 | sellers:[] |
| 64 | }) | 64 | }) |
| 65 | - this.getPos() | 65 | + this.selectComponent('#getpos').getPos(); |
| 66 | } | 66 | } |
| 67 | }, | 67 | }, |
| 68 | 68 | ||
| @@ -135,50 +135,14 @@ Page({ | @@ -135,50 +135,14 @@ Page({ | ||
| 135 | this.sellers=sellers | 135 | this.sellers=sellers |
| 136 | }) | 136 | }) |
| 137 | }, | 137 | }, |
| 138 | - getPos(){ | ||
| 139 | - this._getPos().then(res => { | ||
| 140 | - console.log('wx.getLocation.then', res); | ||
| 141 | - this.location=res | ||
| 142 | - this.GetCollectionSellerList(); | ||
| 143 | - }).catch((e) => { | ||
| 144 | - console.log('wx.getLocation.catch', e); | ||
| 145 | - if ('getLocation:fail auth deny' == e.errMsg | ||
| 146 | - || 'getLocation:fail:auth denied' == e.errMsg | ||
| 147 | - || 'getLocation:fail authorize no response' == e.errMsg) { | ||
| 148 | - this.selectComponent('#showModal').options({ | ||
| 149 | - header: '定位失败', | ||
| 150 | - body: '需要地理位置授权' | ||
| 151 | - }).show(); | ||
| 152 | - } else { | ||
| 153 | - setTimeout(() => { | ||
| 154 | - this.getPos() | ||
| 155 | - }, 500) | ||
| 156 | - } | ||
| 157 | - | ||
| 158 | - }) | ||
| 159 | - }, | ||
| 160 | - _getPos(){ | ||
| 161 | - return new Promise((success, fail) => { | ||
| 162 | - wx.getLocation({ | ||
| 163 | - type: 'gcj02', | ||
| 164 | - success: (res) => { | ||
| 165 | - success(res) | ||
| 166 | - }, | ||
| 167 | - fail: (res) => { | ||
| 168 | - fail(res) | ||
| 169 | - }, | ||
| 170 | - complete: (res) => { | ||
| 171 | - console.log('wx.getLocation', res) | ||
| 172 | - } | ||
| 173 | - }); | ||
| 174 | - }) | ||
| 175 | - }, | ||
| 176 | gotoDetail(e){ | 138 | gotoDetail(e){ |
| 177 | wx.navigateTo({ | 139 | wx.navigateTo({ |
| 178 | url:'/pages/reserve/detail?id='+util.attr(e,'sid') | 140 | url:'/pages/reserve/detail?id='+util.attr(e,'sid') |
| 179 | }) | 141 | }) |
| 180 | }, | 142 | }, |
| 181 | - showModal(e){ | ||
| 182 | - wx.openSetting() | 143 | + onpos(e){ |
| 144 | + console.log(e); | ||
| 145 | + this.location=e.detail | ||
| 146 | + this.GetCollectionSellerList(); | ||
| 183 | }, | 147 | }, |
| 184 | }) | 148 | }) |
| @@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
| 4 | "navigationBarTitleText":"一键订", | 4 | "navigationBarTitleText":"一键订", |
| 5 | "usingComponents": { | 5 | "usingComponents": { |
| 6 | "formids":"/components/formids/formids", | 6 | "formids":"/components/formids/formids", |
| 7 | - "showModal":"/components/showModal/showModal", | 7 | + "getpos":"/components/userinfo/getpos", |
| 8 | "sb-tr":"/components/reserve/seller-box-transverse/seller-box", | 8 | "sb-tr":"/components/reserve/seller-box-transverse/seller-box", |
| 9 | "nav":"/components/nav/nav" | 9 | "nav":"/components/nav/nav" |
| 10 | } | 10 | } |
| @@ -13,4 +13,4 @@ | @@ -13,4 +13,4 @@ | ||
| 13 | <view class="seller flex-vc" wx:if="{{!hasMore}}">没有更多了</view> | 13 | <view class="seller flex-vc" wx:if="{{!hasMore}}">没有更多了</view> |
| 14 | </view> | 14 | </view> |
| 15 | </view> | 15 | </view> |
| 16 | -<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal> | ||
| 16 | +<getpos bindpos="onpos" id="getpos"></getpos> |
| @@ -114,7 +114,9 @@ Page({ | @@ -114,7 +114,9 @@ Page({ | ||
| 114 | statusBarHeight: pt, | 114 | statusBarHeight: pt, |
| 115 | titleBarHeight:h, | 115 | titleBarHeight:h, |
| 116 | }) | 116 | }) |
| 117 | - this.getPos(systemInfo); | 117 | + //this.getPos(systemInfo); |
| 118 | + this.systemInfo=systemInfo | ||
| 119 | + this.selectComponent('#getpos').getPos(); | ||
| 118 | this.getMarkers(); | 120 | this.getMarkers(); |
| 119 | }, | 121 | }, |
| 120 | 122 | ||
| @@ -152,68 +154,30 @@ Page({ | @@ -152,68 +154,30 @@ Page({ | ||
| 152 | onShareAppMessage: function () { | 154 | onShareAppMessage: function () { |
| 153 | 155 | ||
| 154 | }, | 156 | }, |
| 155 | - getPos(systemInfo){ | ||
| 156 | - this._getPos().then(res => { | ||
| 157 | - console.log('wx.getLocation.then', res); | ||
| 158 | - this.hasGetLocation=true; | ||
| 159 | - let map = this.data.map; | ||
| 160 | - map.latitude = res.latitude; | ||
| 161 | - map.longitude = res.longitude; | 157 | + onpos(e){ |
| 158 | + let res=e.detail; | ||
| 159 | + this.hasGetLocation=true; | ||
| 160 | + let map = this.data.map; | ||
| 161 | + map.latitude = res.latitude; | ||
| 162 | + map.longitude = res.longitude; | ||
| 162 | 163 | ||
| 163 | - this.user.latitude = res.latitude; | ||
| 164 | - this.user.longitude = res.longitude; | ||
| 165 | - | ||
| 166 | - console.log('onShow.getPos',systemInfo,getApp().system.windowHeight-this.transverseViewHeight) | ||
| 167 | - map.height = systemInfo.windowHeight-this.transverseViewHeight | ||
| 168 | - this.setData({ | ||
| 169 | - map: map, | ||
| 170 | - }) | 164 | + this.user.latitude = res.latitude; |
| 165 | + this.user.longitude = res.longitude; | ||
| 166 | + map.height = this.systemInfo.windowHeight-this.transverseViewHeight | ||
| 167 | + this.setData({ | ||
| 168 | + map: map, | ||
| 169 | + }) | ||
| 170 | + if(this.mapCtx){ | ||
| 171 | this.mapCtx.getRegion({ | 171 | this.mapCtx.getRegion({ |
| 172 | success:(res)=>{ | 172 | success:(res)=>{ |
| 173 | console.log('regionchange.getRegion',res) | 173 | console.log('regionchange.getRegion',res) |
| 174 | //if(res.southwest.latitude!=this.mapData.region.southwest.latitude) { | 174 | //if(res.southwest.latitude!=this.mapData.region.southwest.latitude) { |
| 175 | - this.mapData.region = res | ||
| 176 | - //this.getMarkers(); | 175 | + this.mapData.region = res |
| 176 | + //this.getMarkers(); | ||
| 177 | //} | 177 | //} |
| 178 | }, | 178 | }, |
| 179 | }) | 179 | }) |
| 180 | - }).catch((e) => { | ||
| 181 | - this.hasGetLocation=false; | ||
| 182 | - console.log('wx.getLocation.catch', e); | ||
| 183 | - if ('getLocation:fail auth deny' == e.errMsg | ||
| 184 | - || 'getLocation:fail:auth denied' == e.errMsg | ||
| 185 | - || 'getLocation:fail authorize no response' == e.errMsg) { | ||
| 186 | - this.selectComponent('#showModal').options({ | ||
| 187 | - header: '定位失败', | ||
| 188 | - body: '需要地理位置授权' | ||
| 189 | - }).show(); | ||
| 190 | - } else { | ||
| 191 | - setTimeout(() => { | ||
| 192 | - this.getPos(systemInfo) | ||
| 193 | - }, 500) | ||
| 194 | - } | ||
| 195 | - | ||
| 196 | - }) | ||
| 197 | - }, | ||
| 198 | - _getPos(){ | ||
| 199 | - return new Promise((success, fail) => { | ||
| 200 | - wx.getLocation({ | ||
| 201 | - type: 'gcj02', | ||
| 202 | - success: (res) => { | ||
| 203 | - success(res) | ||
| 204 | - }, | ||
| 205 | - fail: (res) => { | ||
| 206 | - fail(res) | ||
| 207 | - }, | ||
| 208 | - complete: (res) => { | ||
| 209 | - console.log('wx.getLocation', res) | ||
| 210 | - } | ||
| 211 | - }); | ||
| 212 | - }) | ||
| 213 | - }, | ||
| 214 | - | ||
| 215 | - showModal(e){ | ||
| 216 | - wx.openSetting() | 180 | + } |
| 217 | }, | 181 | }, |
| 218 | regionchange(e){ | 182 | regionchange(e){ |
| 219 | console.log('regionchange', e) | 183 | console.log('regionchange', e) |
| @@ -5,7 +5,7 @@ | @@ -5,7 +5,7 @@ | ||
| 5 | "usingComponents": { | 5 | "usingComponents": { |
| 6 | "formids":"/components/formids/formids", | 6 | "formids":"/components/formids/formids", |
| 7 | "nav":"/components/nav/nav", | 7 | "nav":"/components/nav/nav", |
| 8 | - "showModal":"/components/showModal/showModal", | 8 | + "getpos":"/components/userinfo/getpos", |
| 9 | "sb-tr":"/components/reserve/seller-box-transverse/seller-box", | 9 | "sb-tr":"/components/reserve/seller-box-transverse/seller-box", |
| 10 | "a2l":"/components/tips/add-to-lite" | 10 | "a2l":"/components/tips/add-to-lite" |
| 11 | } | 11 | } |
| @@ -64,7 +64,7 @@ | @@ -64,7 +64,7 @@ | ||
| 64 | <cover-view bindtap="moveToLocation" class="moveToLocation"> | 64 | <cover-view bindtap="moveToLocation" class="moveToLocation"> |
| 65 | <cover-image src="http://qn.colorcun.com/custom/lite-yd/image/location.png"></cover-image> | 65 | <cover-image src="http://qn.colorcun.com/custom/lite-yd/image/location.png"></cover-image> |
| 66 | </cover-view> | 66 | </cover-view> |
| 67 | -<showModal id="showModal" confirmText="去授权" bindshowModal="showModal"></showModal> | 67 | +<getpos bindpos="onpos" id="getpos"></getpos> |
| 68 | <seller-box id="seller-box" bindevent="sellerBoxEvent"></seller-box> | 68 | <seller-box id="seller-box" bindevent="sellerBoxEvent"></seller-box> |
| 69 | <cover-view class="tab-patch"></cover-view> | 69 | <cover-view class="tab-patch"></cover-view> |
| 70 | <a2l bindshow="a2lshow" bindhide="a2lhide"></a2l> | 70 | <a2l bindshow="a2lshow" bindhide="a2lhide"></a2l> |
-
Please register or login to post a comment