//單機去搜索 toSearch:function(){ this.getLocation(res => { console.log('成功') wx.navigateTo({ url: `../search_new/search_new`, }) }, res => { console.log('失敗') wx.showModal({ title: '獲取定位失敗', content: '親~,沒有定位無法進行搜索喲~,去打開地理位置吧~', confirmText: '確認', cancelText: "取消", success: (ress) => { //確認,去打開位置受權 if (ress.confirm) { wx.openSetting({ success: (ress) => { console.log(ress) if (ress.authSetting['scope.userLocation']) { wx.navigateTo({ url: `../search_new/search_new`, }) } }, }) //取消二次受權,顯示最新上架 } else if (ress.cancel) { } } }) }) },
//位置受權 getLocation: function (successCallBack, errorCallBack){ wx.getLocation({ type: 'wgs84', success(res) { successCallBack(res) }, fail(res){ errorCallBack(res) } }) },