//单机去搜索
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)
}
})
},