初始化项目

This commit is contained in:
zhihao
2025-12-11 15:37:54 +08:00
parent f9988ae675
commit 5d85ddfa83
28 changed files with 2102 additions and 9 deletions

View File

@@ -0,0 +1,52 @@
// utils/authorize.js
const SCOPE_MAP = { // 中文提示,可扩展
'scope.record':'录音',
'scope.userLocation': '位置信息'
}
/**
* 一次性申请多个权限
* @param {Array<string>} scopes 例:['scope.camera','scope.record']
* @returns {Promise<Object>} { ok: boolean, granted: Array, denied: Array }
*/
export function authorizeBatch(scopes) {
return new Promise((resolve) => {
const granted = [], denied = []
let idx = 0
//debugger
// 单步授权
function next() {
if (idx >= scopes.length) { // 队列走完
resolve({ ok: denied.length === 0, granted, denied })
return
}
const cur = scopes[idx++]
wx.getSetting({
success: ({ authSetting }) => {
if (authSetting[cur]) { // 已授权
granted.push(cur)
return next()
}
// 未授权 → 发起授权
wx.authorize({
scope: cur,
success() {
granted.push(cur)
next()
},
fail() { // 用户拒绝
denied.push(cur)
next()
}
})
},
fail: () => { // 异常也算拒绝
denied.push(cur)
next()
}
})
}
next() // 开始串行
})
}

View File

@@ -0,0 +1,24 @@
// utils/config.js
const getEnv = () => {
const accountInfo = wx.getAccountInfoSync().miniProgram;
return 'release';//accountInfo.envVersion || 'release';
};
const env = getEnv();
const config = {
develop: {
baseUrl: 'https://wx-xcx-check-dev.blv-oa.com:4433',
timeout: 10000
},
trial: {
baseUrl: 'https://wx-xcx-check-trial.blv-oa.com:4433',
timeout: 10000
},
release: {
baseUrl: 'https://wx-xcx-check.blv-oa.com:4433',
timeout: 10000
}
};
module.exports = config[env];