收藏
回答

小程序同意了隐私协议也打开了相机权限,为什么camera还是提示user cance auth?

<camera resolution='low' @error="handleCameraError" frame-size='small' device-position="back" style="width: 100vw; height: 100vh">

</camera>

const handleCameraError = async (err) => {

		console.log(err);		

		context?.stopRecord()

		code && (breakscreenRecordingApi({

				code,

				necklaceCode: pet.device.necklace_code,

				status: false

			}),

			await deleteVideoApi({

				id: code

			}));

		canShow.value = false

		uni.showModal({

			title: '提示',

			content: '请开启摄像头权限,否则无法拍照',

			confirmText: '去开启',

			success(res) {

				if (res.confirm) {

					uni.openSetting({

						success(res) {

							if (res.authSetting["scope.camera"]) {

					

								// uni.redirectTo({

								// 	url: ‘’

								// })

								canShow.value = true

								context = wx.createCameraContext()

							} else {

								uni.navigateBack({

									delta: 1

								})

							}

						}

					})

				} else if (res.cancel) {

					console.log('用户点击取消')

					uni.navigateBack({

						delta: 1

					})

				}

			}

		})

	}

onLoad(async (opt) => {

    uni.getSetting({

			success(res) {

				console.log(res);

				if (!res.authSetting['scope.camera']) {




					console.log('未授权');

					uni.authorize({

						scope: 'scope.camera',

						success() {

							canShow.value = true

							context = wx.createCameraContext()

						},

						fail(err) {

							// console.log(123, err);

							handleCameraError(err)

						}

					})

				} else {

					canShow.value = true




					context = wx.createCameraContext()

				}

			},

			fail(err) {

				console.log(err);

			}

		})

})

小程序中的隐私协议同意了,摄像头权限、麦克风权限都打开了,并没有手动关闭权限,但camera的@err方法还是提示user cance auth

手机型号:小米14;系统:安卓14

回答关注问题邀请回答
收藏
登录 后发表内容