onshow(){
this.getAuthorizeInfo()
}
// 位置授權(quán)
? ? ? ? getAuthorizeInfo(){? ? ? ? ? ? ? ? //? 點(diǎn)擊事件
? ? ? ? ? ? const that = this;
? ? ? ? ? ? uni.authorize({
? ? ? ? ? ? ? ? scope: 'scope.userLocation',
? ? ? ? ? ? ? ? success() { // 允許授權(quán)
? ? ? ? ? ? ? ? ? ? that.getLocationInfo();
? ? ? ? ? ? ? ? },
? ? ? ? ? ? ? ? fail(){? ? // 拒絕授權(quán)
? ? ? ? ? ? ? ? ? ? that.openConfirm();
? ? ? ? ? ? ? ? ? ? console.log("你拒絕了授權(quán),無法獲得周邊信息")
? ? ? ? ? ? ? ? }
? ? ? ? ? ? })
? ? ? ? },
? ? ? ? // 獲取地理位置
? ? ? ? getLocationInfo(){?
? ? ? ? ? ? uni.getLocation({
? ? ? ? ? ? ? ? type: 'wgs84',
? ? ? ? ? ? ? ? success (res) {
? ? ? ? ? ? ? ? ? ? console.log(res);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? },
? ? ? ? // 再次獲取授權(quán)
? ? ? ? // 當(dāng)用戶第一次拒絕后再次請求授權(quán)
? ? ? ? openConfirm(){
? ? ? ? ? ? uni.showModal({
? ? ? ? ? ? ? ? title: '請求授權(quán)當(dāng)前位置',
? ? ? ? ? ? ? ? content: '需要獲取您的地理位置,請確認(rèn)授權(quán)',
? ? ? ? ? ? ? ? success: (res)=> {
? ? ? ? ? ? ? ? ? ? if (res.confirm) {
? ? ? ? ? ? ? ? ? ? ? ? uni.openSetting();// 打開地圖權(quán)限設(shè)置
? ? ? ? ? ? ? ? ? ? } else if (res.cancel) {
? ? ? ? ? ? ? ? ? ? ? ? uni.showToast({
? ? ? ? ? ? ? ? ? ? ? ? ? ? title: '你拒絕了授權(quán)党饮,無法獲得周邊信息',
? ? ? ? ? ? ? ? ? ? ? ? ? ? icon: 'none',
? ? ? ? ? ? ? ? ? ? ? ? ? ? duration: 1000
? ? ? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? });
? ? ? ? },