123456789101112131415161718192021222324252627282930313233 |
- export const authorizeRecord = async () => {
- let isAuth = await new Promise((r) => {
- wx.authorize({
- scope: 'scope.record',
- success: () => r(true),
- fail: () => r(false)
- })
- })
- if (isAuth) return true
- let res = await new Promise<WechatMiniprogram.ShowModalSuccessCallbackResult | boolean>(r => {
- wx.showModal({
- title: '提示',
- content: '您未授权录音,说话功能将无法使用',
- showCancel: true,
- confirmText: "授权",
- confirmColor: "#52a2d8",
- success: res => r(res),
- fail: () => r(false)
- })
- })
- if (!res || (typeof res === 'object' && res.cancel)) return;
- isAuth = await new Promise((r) => {
- wx.openSetting({
- success: res => r(res.authSetting['scope.record']),
- fail: () => r(false)
- })
- })
- return isAuth
- }
|