6/23修正预览,滚动事件

This commit is contained in:
Zy
2026-06-23 08:12:17 +08:00
parent 110d0707d2
commit ce2f31d74c
8 changed files with 79 additions and 12 deletions

View File

@@ -0,0 +1,51 @@
/**
* 请求权限
* @param {String} scope 权限标识
* @param {String} tip 拒绝后的提示文案
*/
export function requestAuth(scope, tip) {
return new Promise((resolve, reject) => {
// #ifdef APP-PLUS || MP-WEIXIN
uni.getSetting({
success: (res) => {
console.log(res)
// 1. 已授权
if (res.authSetting[scope]) {
resolve(true)
return
}
// 2. 未申请过,发起授权弹窗
uni.authorize({
scope,
success: () => resolve(true),
fail: () => {
// 3. 用户拒绝,引导去设置页开启
uni.showModal({
title: '权限申请',
content: tip,
confirmText: '去设置',
cancelText: '取消',
success: (modal) => {
if (modal.confirm) {
uni.openSetting({
success: (setRes) => {
resolve(setRes.authSetting[scope])
},
fail: () => reject(false)
})
} else {
reject(false)
}
}
})
}
})
},
fail: () => reject(false)
})
// #endif
// #ifdef H5
resolve(true)
// #endif
})
}