Commit 491c9d48a50148b04cce7542db6338faab837132

Authored by wangfan
1 parent 6b43e9a2

C端调整

@@ -5,9 +5,13 @@ Component({ @@ -5,9 +5,13 @@ Component({
5 * 组件的属性列表 5 * 组件的属性列表
6 */ 6 */
7 properties: { 7 properties: {
8 - hasAllowFail:{ 8 + hasAllowFail:{//强制获取定位
9 type:Boolean, 9 type:Boolean,
10 value:false, 10 value:false,
  11 + },
  12 + hasAllowaAuthDeny:{//是否允许用户拒绝
  13 + type:Boolean,
  14 + value:true,
11 } 15 }
12 }, 16 },
13 17
@@ -22,7 +26,7 @@ Component({ @@ -22,7 +26,7 @@ Component({
22 * 组件的方法列表 26 * 组件的方法列表
23 */ 27 */
24 methods: { 28 methods: {
25 - getPos(){ 29 + getPos(fouce=false){
26 this._getPos().then(res => { 30 this._getPos().then(res => {
27 console.log('wx.getLocation.then', res); 31 console.log('wx.getLocation.then', res);
28 failCount=0; 32 failCount=0;
@@ -45,8 +49,10 @@ Component({ @@ -45,8 +49,10 @@ Component({
45 success:()=>{ 49 success:()=>{
46 console.log('wx.showModal::success,给默认坐标'); 50 console.log('wx.showModal::success,给默认坐标');
47 this.triggerEvent("pos",{ 51 this.triggerEvent("pos",{
48 - latitude: 39.6846701,  
49 - longitude: 118.1763001, 52 + //latitude: 39.6846701,
  53 + //longitude: 118.1763001,
  54 + latitude:'',
  55 + longitude:'',
50 }); 56 });
51 }, 57 },
52 }) 58 })
@@ -55,11 +61,18 @@ Component({ @@ -55,11 +61,18 @@ Component({
55 if ('getLocation:fail auth deny' == e.errMsg 61 if ('getLocation:fail auth deny' == e.errMsg
56 || 'getLocation:fail:auth denied' == e.errMsg 62 || 'getLocation:fail:auth denied' == e.errMsg
57 || 'getLocation:fail authorize no response' == e.errMsg) { 63 || 'getLocation:fail authorize no response' == e.errMsg) {
  64 + failCount=0;
  65 + if(this.data.hasAllowaAuthDeny && !fouce){
  66 + this.triggerEvent("pos",{
  67 + latitude: '',
  68 + longitude: '',
  69 + });
  70 + return;
  71 + }
58 this.selectComponent('#showModal').options({ 72 this.selectComponent('#showModal').options({
59 header: '定位失败', 73 header: '定位失败',
60 body: '需要地理位置授权' 74 body: '需要地理位置授权'
61 }).show(); 75 }).show();
62 - failCount=0;  
63 } else { 76 } else {
64 failCount=failCount+1; 77 failCount=failCount+1;
65 setTimeout(() => { 78 setTimeout(() => {
@@ -71,9 +84,14 @@ Component({ @@ -71,9 +84,14 @@ Component({
71 _getPos(){ 84 _getPos(){
72 return new Promise((success, fail) => { 85 return new Promise((success, fail) => {
73 let rex={latitude:'',longitude:''}; 86 let rex={latitude:'',longitude:''};
  87 + wx.showLoading({
  88 + title: '包间查找中',
  89 + })
  90 + let hasSuccess=false;
74 wx.getLocation({ 91 wx.getLocation({
75 type: 'gcj02', 92 type: 'gcj02',
76 success: (res) => { 93 success: (res) => {
  94 + hasSuccess=true;
77 rex=res; 95 rex=res;
78 success(res) 96 success(res)
79 }, 97 },
@@ -81,11 +99,15 @@ Component({ @@ -81,11 +99,15 @@ Component({
81 fail(res) 99 fail(res)
82 }, 100 },
83 complete: (res) => { 101 complete: (res) => {
  102 + wx.hideLoading()
84 console.log('wx.getLocation', res) 103 console.log('wx.getLocation', res)
85 } 104 }
86 }); 105 });
87 setTimeout(()=>{ 106 setTimeout(()=>{
88 - success(rex) 107 + if(!hasSuccess){
  108 + success(rex)
  109 + wx.hideLoading()
  110 + }
89 },2000) 111 },2000)
90 }) 112 })
91 }, 113 },
@@ -178,6 +178,7 @@ Page({ @@ -178,6 +178,7 @@ Page({
178 onpos(e){ 178 onpos(e){
179 let res=e.detail; 179 let res=e.detail;
180 this.hasGetLocation=true; 180 this.hasGetLocation=true;
  181 + if(!res.latitude) return;
181 let map = this.data.map; 182 let map = this.data.map;
182 map.latitude = res.latitude; 183 map.latitude = res.latitude;
183 map.longitude = res.longitude; 184 map.longitude = res.longitude;
@@ -365,8 +366,8 @@ Page({ @@ -365,8 +366,8 @@ Page({
365 } 366 }
366 let markers = []; 367 let markers = [];
367 let param={ 368 let param={
368 - lat: this.user.latitude==39.6846701?'':this.user.latitude,  
369 - lng: this.user.longitude==118.1763001?'':this.user.longitude, 369 + lat: this.user.latitude==def_latitude?'':this.user.latitude,
  370 + lng: this.user.longitude==def_longitude?'':this.user.longitude,
370 offset: 0, 371 offset: 0,
371 rows: 50, 372 rows: 50,
372 distance: 100000, 373 distance: 100000,
@@ -484,8 +485,12 @@ Page({ @@ -484,8 +485,12 @@ Page({
484 wx.showTabBar(); 485 wx.showTabBar();
485 }, 486 },
486 moveToLocation(){ 487 moveToLocation(){
  488 + if(this.user.latitude==def_latitude){
  489 + this.selectComponent('#getpos').getPos(true);
  490 + return;
  491 + }
487 let map=this.data.map; 492 let map=this.data.map;
488 - console.log(this.user.latitude,this.mapData.latitude); 493 + console.log(this.user.latitude,this.mapData.latitude,def_latitude);
489 if(this.user.latitude==this.mapData.latitude && this.user.longitude==this.mapData.longitude) return; 494 if(this.user.latitude==this.mapData.latitude && this.user.longitude==this.mapData.longitude) return;
490 map.latitude=this.user.latitude 495 map.latitude=this.user.latitude
491 map.longitude=this.user.longitude 496 map.longitude=this.user.longitude