| | |
| | | }, |
| | | onShow() { |
| | | this.init(); |
| | | this.userAuthorization(); |
| | | }, |
| | | methods: { |
| | | init() { |
| | | this.roleType = uni.getStorageSync('roleType'); |
| | | console.log(this.roleType, 'indexTabbar'); |
| | | switch (this.roleType) { |
| | | case 1: |
| | | console.log('customerIndexRef'); |
| | |
| | | default: |
| | | break; |
| | | } |
| | | }, |
| | | // 要求用户授权相机/麦克风权限 |
| | | userAuthorization() { |
| | | wx.getSetting({ |
| | | success(res) { |
| | | wx.startRecord(); |
| | | console.log('success'); |
| | | if (!res.authSetting['scope.record'] || !res.authSetting['scope.camera']) { |
| | | if (!res.authSetting['scope.camera']) { |
| | | wx.authorize({ |
| | | scope: 'scope.camera', |
| | | success() { |
| | | // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 |
| | | console.log('授权成功'); |
| | | }, |
| | | fail() { |
| | | console.log('授权失败'); |
| | | } |
| | | }); |
| | | } else if (!res.authSetting['scope.record']) { |
| | | wx.authorize({ |
| | | scope: 'scope.record', |
| | | success() { |
| | | // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 |
| | | console.log('授权成功'); |
| | | }, |
| | | fail: () => { |
| | | console.log('授权失败'); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }, |
| | | fail() { |
| | | console.log('获取失败'); |
| | | } |
| | | }); |
| | | } |
| | | } |
| | | }; |