Showing
7 changed files
with
102 additions
and
4 deletions
components/2.0/userinfo/getpos.js
0 → 100644
| 1 | +// components/userinfo/getpos.js | ||
| 2 | +Component({ | ||
| 3 | + /** | ||
| 4 | + * 组件的属性列表 | ||
| 5 | + */ | ||
| 6 | + properties: { | ||
| 7 | + | ||
| 8 | + }, | ||
| 9 | + | ||
| 10 | + /** | ||
| 11 | + * 组件的初始数据 | ||
| 12 | + */ | ||
| 13 | + data: {}, | ||
| 14 | + attached(){ | ||
| 15 | + }, | ||
| 16 | + /** | ||
| 17 | + * 组件的方法列表 | ||
| 18 | + */ | ||
| 19 | + methods: { | ||
| 20 | + getPosDo(timeout=3000){ | ||
| 21 | + return new Promise(function(success,fail){ | ||
| 22 | + let timer1=setTimeout(()=>{ | ||
| 23 | + fail('timeout') | ||
| 24 | + },timeout) | ||
| 25 | + wx.getLocation({ | ||
| 26 | + type: 'gcj02', | ||
| 27 | + success: (res) => { | ||
| 28 | + success(res) | ||
| 29 | + }, | ||
| 30 | + fail: (res) => { | ||
| 31 | + fail(res) | ||
| 32 | + }, | ||
| 33 | + complete:()=>{ | ||
| 34 | + if(timer1) clearTimeout(timer1) | ||
| 35 | + } | ||
| 36 | + }); | ||
| 37 | + }) | ||
| 38 | + }, | ||
| 39 | + getPos(fouce=false){ | ||
| 40 | + wx.getSetting({ | ||
| 41 | + success: res => { | ||
| 42 | + console.log('getPos.scope.userLocation',res.authSetting) | ||
| 43 | + let timeout=3000; | ||
| 44 | + if(typeof res.authSetting['scope.userLocation']=='undefined'){ | ||
| 45 | + timeout=86400; | ||
| 46 | + } | ||
| 47 | + if(res.authSetting['scope.userLocation']===false){ | ||
| 48 | + if(fouce){ | ||
| 49 | + this.selectComponent('#confirm').options({ | ||
| 50 | + header: '定位失败', | ||
| 51 | + body: '请开启定位,为您查询附近餐厅。' | ||
| 52 | + }).show(); | ||
| 53 | + }else{ | ||
| 54 | + this.triggerEvent("pos",{ | ||
| 55 | + latitude: '', | ||
| 56 | + longitude: '', | ||
| 57 | + }); | ||
| 58 | + } | ||
| 59 | + }else{// | ||
| 60 | + this.getPosDo(timeout).then(res=>{ | ||
| 61 | + console.log('getPos.then',res) | ||
| 62 | + this.triggerEvent("pos",{ | ||
| 63 | + latitude: res.latitude, | ||
| 64 | + longitude: res.longitude, | ||
| 65 | + }); | ||
| 66 | + }).catch(res=>{ | ||
| 67 | + console.log('getPos.catch',res) | ||
| 68 | + this.triggerEvent("pos",{ | ||
| 69 | + latitude: '', | ||
| 70 | + longitude: '', | ||
| 71 | + }); | ||
| 72 | + }) | ||
| 73 | + } | ||
| 74 | + } | ||
| 75 | + }) | ||
| 76 | + }, | ||
| 77 | + confirmEvent(e){ | ||
| 78 | + wx.openSetting({ | ||
| 79 | + success:res=>{ | ||
| 80 | + console.log('getPos.openSetting',res) | ||
| 81 | + this.getPos(); | ||
| 82 | + } | ||
| 83 | + }) | ||
| 84 | + }, | ||
| 85 | + } | ||
| 86 | +}) |
components/2.0/userinfo/getpos.json
0 → 100644
components/2.0/userinfo/getpos.wxml
0 → 100644
components/2.0/userinfo/getpos.wxss
0 → 100644
| 1 | +/* components/userinfo/getpos.wxss */ |
| @@ -309,8 +309,6 @@ Page({ | @@ -309,8 +309,6 @@ Page({ | ||
| 309 | let ms=(e.detail.scrollTop%162)>100?1:0; | 309 | let ms=(e.detail.scrollTop%162)>100?1:0; |
| 310 | idx+=ms; | 310 | idx+=ms; |
| 311 | } | 311 | } |
| 312 | - //console.log('scrollEvent',e,e.detail.scrollTop,idx) | ||
| 313 | - //console.log('scrollEvent',this.sellers[idx].sellername) | ||
| 314 | this.debounce(()=>{ | 312 | this.debounce(()=>{ |
| 315 | this.scrollEventActive(idx) | 313 | this.scrollEventActive(idx) |
| 316 | },300) | 314 | },300) |
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | "navigationBarTextStyle": "black", | 3 | "navigationBarTextStyle": "black", |
| 4 | "navigationBarTitleText":"周到安排", | 4 | "navigationBarTitleText":"周到安排", |
| 5 | "usingComponents": { | 5 | "usingComponents": { |
| 6 | - "getpos":"/components/userinfo/getpos", | 6 | + "getpos":"/components/2.0/userinfo/getpos", |
| 7 | "a2l":"/components/tips/add-to-lite", | 7 | "a2l":"/components/tips/add-to-lite", |
| 8 | "filter-group":"/components/2.0/filter/filter-group", | 8 | "filter-group":"/components/2.0/filter/filter-group", |
| 9 | "seller-card":"/components/2.0/seller/card", | 9 | "seller-card":"/components/2.0/seller/card", |
| 1 | <!--pages/reservr/index.wxml--> | 1 | <!--pages/reservr/index.wxml--> |
| 2 | <map id="map" scale="{{map.scale}}" | 2 | <map id="map" scale="{{map.scale}}" |
| 3 | - longitude="{{map.longitude}}" latitude="{{map.latitude}}" | 3 | + longitude="{{map.longitude||118.170300}}" latitude="{{map.latitude||39.65273}}" |
| 4 | markers="{{markers}}" polygons="{{polygons}}" | 4 | markers="{{markers}}" polygons="{{polygons}}" |
| 5 | bindmarkertap="markertap" | 5 | bindmarkertap="markertap" |
| 6 | bindcallouttap="markertap" | 6 | bindcallouttap="markertap" |
-
Please register or login to post a comment