【uniapp】小程序授权拒绝后,再次打开提示框

场景描述:uniapp 小程序授权拒绝后,再次打开提示框

<button type="default" @click="savePosterImg">保存图片</button>
savePosterImg() {
			let self = this;
			uni.showLoading({
				title: '加载中'
			});
			// 下载海报图片
			uni.downloadFile({
				url: self.poster_img,
				success(res) {
					uni.hideLoading();
					// 图片保存到本地
					uni.saveImageToPhotosAlbum({
						filePath: res.tempFilePath,
						success(data) {
							uni.showToast({
								title: '保存成功',
								icon: 'success',
								duration: 2000
							});
							// 关闭商品海报
							self.isCreatedImg = false;
						},
						fail(err) {
							if (err.errMsg === 'saveImageToPhotosAlbum:fail auth deny') {
								//打开自己设定的弹窗 !important
								self.settingShow=true
								// 关闭商品海报
								self.isCreatedImg = false;
							}
						},
						complete(res) {
							console.log('complete');
						}
					});
				}
			});
		},
	//这是我自己定义的组件
	<uni-popup ref="settingPopup" type="middle" :show='settingShow' class="locationCommentPop" padding="0" >
			<template v-slot=""  >
					<view class="" style="width: 600rpx;">
						<view class="pop-title">检测到您没打开相册权限,是否去设置打开</view>
						<view class="pop-btns box-s-b">
							<button type="default" class="pop-cancle" @click="locationCancel">取消</button>
							//需要自定义这个button按钮 绑定打开设定的属性
							<button open-type="openSetting" class="pop-open" bindopensetting="hidetowast">打开设置页</button>
						</view>
					</view>
			</template>
		
		</uni-popup>

原因
在这里插入图片描述
如果用户之前拒绝了授权,此接口会直接进入失败回调,一般搭配uni.getSetting和uni.openSetting使用。

逻辑点
当点击保存图片当相册,小程序拒绝授权之后,下次检测到用户已经拒绝授权了,则出现另外的弹窗,给弹窗里的button 设定打开授权页的属性
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值