Showing
3 changed files
with
29 additions
and
8 deletions
| @@ -4,7 +4,10 @@ Component({ | @@ -4,7 +4,10 @@ Component({ | ||
| 4 | * 组件的属性列表 | 4 | * 组件的属性列表 |
| 5 | */ | 5 | */ |
| 6 | properties: { | 6 | properties: { |
| 7 | - | 7 | + hasFailPop:{//授权失败是否弹框 |
| 8 | + type:Boolean, | ||
| 9 | + value:false, | ||
| 10 | + }, | ||
| 8 | }, | 11 | }, |
| 9 | 12 | ||
| 10 | /** | 13 | /** |
| @@ -18,6 +21,7 @@ Component({ | @@ -18,6 +21,7 @@ Component({ | ||
| 18 | */ | 21 | */ |
| 19 | methods: { | 22 | methods: { |
| 20 | getPosDo(timeout=3000){ | 23 | getPosDo(timeout=3000){ |
| 24 | + //timeout=0 | ||
| 21 | return new Promise(function(success,fail){ | 25 | return new Promise(function(success,fail){ |
| 22 | let timer1=setTimeout(()=>{ | 26 | let timer1=setTimeout(()=>{ |
| 23 | fail('timeout') | 27 | fail('timeout') |
| @@ -25,14 +29,14 @@ Component({ | @@ -25,14 +29,14 @@ Component({ | ||
| 25 | wx.getLocation({ | 29 | wx.getLocation({ |
| 26 | type: 'gcj02', | 30 | type: 'gcj02', |
| 27 | success: (res) => { | 31 | success: (res) => { |
| 28 | - getApp().location=res | 32 | + getApp().location = res |
| 29 | success(res) | 33 | success(res) |
| 30 | }, | 34 | }, |
| 31 | fail: (res) => { | 35 | fail: (res) => { |
| 32 | fail(res) | 36 | fail(res) |
| 33 | }, | 37 | }, |
| 34 | - complete:()=>{ | ||
| 35 | - if(timer1) clearTimeout(timer1) | 38 | + complete: () => { |
| 39 | + if (timer1) clearTimeout(timer1) | ||
| 36 | } | 40 | } |
| 37 | }); | 41 | }); |
| 38 | }) | 42 | }) |
| @@ -46,7 +50,7 @@ Component({ | @@ -46,7 +50,7 @@ Component({ | ||
| 46 | timeout=86400; | 50 | timeout=86400; |
| 47 | } | 51 | } |
| 48 | if(res.authSetting['scope.userLocation']===false){ | 52 | if(res.authSetting['scope.userLocation']===false){ |
| 49 | - if(fouce){ | 53 | + if(fouce || this.data.hasFailPop){ |
| 50 | this.selectComponent('#confirm').options({ | 54 | this.selectComponent('#confirm').options({ |
| 51 | header: '定位失败', | 55 | header: '定位失败', |
| 52 | body: '请开启定位,为您查询附近餐厅。' | 56 | body: '请开启定位,为您查询附近餐厅。' |
| @@ -73,6 +77,16 @@ Component({ | @@ -73,6 +77,16 @@ Component({ | ||
| 73 | }); | 77 | }); |
| 74 | }).catch(res=>{ | 78 | }).catch(res=>{ |
| 75 | console.log('getPos.catch',res) | 79 | console.log('getPos.catch',res) |
| 80 | + if(this.data.hasFailPop){ | ||
| 81 | + if ('getLocation:fail auth deny' == res.errMsg | ||
| 82 | + || 'getLocation:fail:auth denied' == res.errMsg | ||
| 83 | + || 'getLocation:fail authorize no response' == res.errMsg) { | ||
| 84 | + this.selectComponent('#confirm').options({ | ||
| 85 | + header: '定位失败', | ||
| 86 | + body: '请开启定位,为您查询附近餐厅。' | ||
| 87 | + }).show(); | ||
| 88 | + } | ||
| 89 | + } | ||
| 76 | this.triggerEvent("pos",{ | 90 | this.triggerEvent("pos",{ |
| 77 | latitude: '', | 91 | latitude: '', |
| 78 | longitude: '', | 92 | longitude: '', |
| @@ -14,10 +14,12 @@ | @@ -14,10 +14,12 @@ | ||
| 14 | subkey="SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ" | 14 | subkey="SDEBZ-I74W4-QLGUX-XXYXU-HIR23-3QFBJ" |
| 15 | layer-style="2" | 15 | layer-style="2" |
| 16 | style="width: 100%; height: 30vh;position: relative;"> | 16 | style="width: 100%; height: 30vh;position: relative;"> |
| 17 | +</map> | ||
| 18 | +<view class="moveToLocationView"> | ||
| 17 | <view bindtap="moveToLocation" class="view moveToLocation flex align-center justify-center"> | 19 | <view bindtap="moveToLocation" class="view moveToLocation flex align-center justify-center"> |
| 18 | <image class="moveToLocation-image" src="http://nosqn.colorcun.com/2.0/home%20%2811%29.png"></image> | 20 | <image class="moveToLocation-image" src="http://nosqn.colorcun.com/2.0/home%20%2811%29.png"></image> |
| 19 | </view> | 21 | </view> |
| 20 | -</map> | 22 | +</view> |
| 21 | <view class="view content padding-top-xs" style="height: 70vh;"> | 23 | <view class="view content padding-top-xs" style="height: 70vh;"> |
| 22 | <filter-group height="{{height}}" | 24 | <filter-group height="{{height}}" |
| 23 | id="filter-group" | 25 | id="filter-group" |
| @@ -76,7 +78,7 @@ | @@ -76,7 +78,7 @@ | ||
| 76 | </block> | 78 | </block> |
| 77 | 79 | ||
| 78 | </view> | 80 | </view> |
| 79 | -<getpos bindpos="onpos" id="getpos" hasAllowLoading="{{false}}"></getpos> | 81 | +<getpos bindpos="onpos" id="getpos" hasFailPop></getpos> |
| 80 | <navigator url="/pages/me/index" hover-class="navigator-hover"> | 82 | <navigator url="/pages/me/index" hover-class="navigator-hover"> |
| 81 | <view style="top:{{meTop}}px;" | 83 | <view style="top:{{meTop}}px;" |
| 82 | class="me view flex flex-direction align-center justify-center bg-white round"> | 84 | class="me view flex flex-direction align-center justify-center bg-white round"> |
| @@ -4,12 +4,17 @@ page{ | @@ -4,12 +4,17 @@ page{ | ||
| 4 | background-color: #efefef; | 4 | background-color: #efefef; |
| 5 | /*--barHeight: calc(98rpx + env(safe-area-inset-bottom));*/ | 5 | /*--barHeight: calc(98rpx + env(safe-area-inset-bottom));*/ |
| 6 | } | 6 | } |
| 7 | +.moveToLocationView{ | ||
| 8 | + width: 100%; | ||
| 9 | + height: 0; | ||
| 10 | + position: relative; | ||
| 11 | +} | ||
| 7 | .moveToLocation{ | 12 | .moveToLocation{ |
| 8 | position: absolute; | 13 | position: absolute; |
| 9 | width: 80rpx; | 14 | width: 80rpx; |
| 10 | height: 80rpx; | 15 | height: 80rpx; |
| 11 | right:0rpx; | 16 | right:0rpx; |
| 12 | - bottom:0; | 17 | + top:-80rpx; |
| 13 | } | 18 | } |
| 14 | .moveToLocation-image{ | 19 | .moveToLocation-image{ |
| 15 | width: 40rpx; | 20 | width: 40rpx; |
-
Please register or login to post a comment