gemercheung 3 роки тому
батько
коміт
11485a2cba
2 змінених файлів з 24 додано та 7 видалено
  1. 4 1
      project.private.config.json
  2. 20 6
      socket.js

+ 4 - 1
project.private.config.json

@@ -189,5 +189,8 @@
       ]
     }
   },
-  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html"
+  "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+  "setting": {
+    "compileHotReLoad": false
+  }
 }

+ 20 - 6
socket.js

@@ -189,6 +189,17 @@ export default {
 
     return isAuth
   },
+  // 获取录音权限状态
+  async getAuthorizeRecordStatus() {
+    const isAuth = await new Promise((r, j) => {
+      wx.authorize({
+        scope: 'scope.record',
+        success: () => r(true),
+        fail: () => r(false)
+      })
+    })
+    return Promise.resolve(isAuth)
+  },
 
   async agetUserInfo() {
     const res = await util.request(api.UserInfo)
@@ -321,14 +332,15 @@ export default {
       console.log('**************')
       console.log(this.options)
     }
-    // wx.showToast({
-    //   title: this.data.peopleCount.toString(),
-    // })
+
+    let isAllowMic // 真正MIC权, 房主与 授权一个 要在房间isAllowMic开启
 
     if (Number(isAnchor) === 1) {
       this.role = "leader"
+      isAllowMic = 1
     } else {
       this.role = 'customer'
+      isAllowMic = 0
     }
 
     if (assistant && assistant.userId && assistant.userId == userInfo.userId) {
@@ -336,15 +348,17 @@ export default {
     }
     console.log('进入房间角色,', this.role);
 
+    const isAuthMic = await this.getAuthorizeRecordStatus();
+    console.log('当前用户录音权限状态', isAuthMic)
     return {
       role: this.role,
       userId: userInfo.userId,
-      roomType,
+      // roomType,
       avatar: userInfo.avatarUrl,
       nickname: userInfo.nickname,
       voiceStatus: getApp().globalData.voiceProps.noMute ? 0 : 2,
-      isAuthMic: !!this.isAuthorizeRecord,
-      enableTalk: this.role === 'leader' ? true : undefined,
+      isAuthMic: isAuthMic ? 1 : 0,
+      isAllowMic: isAllowMic,
       roomId: roomId,
       sceneNumber: sceneId,
       onlineStatus: true,