Browse Source

openim使用说明

15376779826 1 tháng trước cách đây
mục cha
commit
6fff7aa14f

+ 3 - 0
.env.development

@@ -4,6 +4,9 @@ VUE_APP_TITLE = 医生服务系统
 # 腾讯IM
 # 腾讯IM
 VUE_APP_IM_CONFIG = 1600089394
 VUE_APP_IM_CONFIG = 1600089394
 
 
+#openIM
+VUE_APP_API_ADDR=https://im.muyi88.com/api
+VUE_APP_WS_ADDR=wss://im.muyi88.com/msg_gateway
 
 
 # 公司名称
 # 公司名称
 VUE_APP_COMPANY_NAME =福州市木易华康医药有限公司
 VUE_APP_COMPANY_NAME =福州市木易华康医药有限公司

+ 3 - 1
.env.prod-myhk

@@ -3,7 +3,9 @@ VUE_APP_TITLE = 医生服务系统
 
 
 # 腾讯IM
 # 腾讯IM
 VUE_APP_IM_CONFIG = 1600089394
 VUE_APP_IM_CONFIG = 1600089394
-
+#openIM
+VUE_APP_API_ADDR=https://im.muyi88.com/api
+VUE_APP_WS_ADDR=wss://im.muyi88.com/msg_gateway
 
 
 # 公司名称
 # 公司名称
 VUE_APP_COMPANY_NAME =福州市木易华康医药有限公司
 VUE_APP_COMPANY_NAME =福州市木易华康医药有限公司

+ 2 - 2
src/components/user/login.vue

@@ -107,8 +107,8 @@
             token: this.userToken,
             token: this.userToken,
             logLevel:6,
             logLevel:6,
             platformID: 5, // 使用配置的平台ID
             platformID: 5, // 使用配置的平台ID
-            apiAddr: 'https://web.im.cdwjyyh.com/api', // API地址
-            wsAddr: 'wss://web.im.cdwjyyh.com/msg_gateway', // WebSocket地址
+            apiAddr: process.env.VUE_APP_API_ADDR,
+            wsAddr: process.env.VUE_APP_WS_ADDR,
             dataDir: '/imdata' // 添加数据存储目录
             dataDir: '/imdata' // 添加数据存储目录
           }
           }
           console.log("config",config)
           console.log("config",config)

+ 2 - 2
src/store/modules/user.js

@@ -49,7 +49,7 @@ const user = {
           // 设置请求头
           // 设置请求头
           axios.defaults.headers.common['APPToken'] = res.token;
           axios.defaults.headers.common['APPToken'] = res.token;
           commit('SET_DOCTOR',res.doctor)
           commit('SET_DOCTOR',res.doctor)
-          commit('setUserId', "SCRMD"+res.doctor.doctorId)
+          commit('setUserId', "D"+res.doctor.doctorId)
           resolve(res)
           resolve(res)
         }).catch(error => {
         }).catch(error => {
           reject(error)
           reject(error)
@@ -69,7 +69,7 @@ const user = {
           commit('SET_NAME', doctor.doctorName)
           commit('SET_NAME', doctor.doctorName)
           commit('SET_AVATAR', avatar)
           commit('SET_AVATAR', avatar)
           commit('SET_DOCTOR', res.doctor)
           commit('SET_DOCTOR', res.doctor)
-          commit('setUserId', "scrmD"+res.doctor.doctorId)
+          commit('setUserId', "D"+res.doctor.doctorId)
           resolve(res)
           resolve(res)
         }).catch(error => {
         }).catch(error => {
           reject(error)
           reject(error)

+ 2 - 2
src/utils/im.js

@@ -6,8 +6,8 @@ const config = {
   SECRET: 'openIM123',
   SECRET: 'openIM123',
 
 
   // 服务器地址配置
   // 服务器地址配置
-  API_ADDRESS: 'https://web.im.cdwjyyh.com/api', // OpenIM API地址
-  WS_ADDRESS: 'wss://web.im.cdwjyyh.com/msg_gateway', // WebSocket地址
+  API_ADDRESS: 'https://web.im.fbylive.com/api', // OpenIM API地址
+  WS_ADDRESS: 'wss://web.im.fbylive.com/msg_gateway', // WebSocket地址
 
 
   // 平台配置
   // 平台配置
   PLATFORM_ID: 5, // 平台ID (5=Web)
   PLATFORM_ID: 5, // 平台ID (5=Web)

+ 15 - 5
src/views/im/index.vue

@@ -108,11 +108,11 @@ export default {
           token: this.userToken,
           token: this.userToken,
           logLevel:6,
           logLevel:6,
           platformID: 5, // 使用配置的平台ID
           platformID: 5, // 使用配置的平台ID
-          apiAddr: 'https://web.im.cdwjyyh.com/api', // API地址
-          wsAddr: 'wss://web.im.cdwjyyh.com/msg_gateway', // WebSocket地址
+          apiAddr: process.env.VUE_APP_API_ADDR,
+          wsAddr: process.env.VUE_APP_WS_ADDR,
           dataDir: '/imdata' // 添加数据存储目录
           dataDir: '/imdata' // 添加数据存储目录
         }
         }
-
+        console.log("config",config)
         this.OpenIM.login(config).then(() => {
         this.OpenIM.login(config).then(() => {
           this.$nextTick(() => {
           this.$nextTick(() => {
             this.checkSDKReadyState();
             this.checkSDKReadyState();
@@ -187,7 +187,12 @@ export default {
           this.$store.commit('updateConversationList', data)
           this.$store.commit('updateConversationList', data)
         })
         })
         .catch(({ errCode, errMsg }) => {
         .catch(({ errCode, errMsg }) => {
-          // 调用失败
+          if (errCode === 1004) {
+            console.log("暂无会话数据")
+            this.$store.commit('updateConversationList', [])
+          } else {
+            console.error("获取会话列表失败", errCode, errMsg)
+          }
         })
         })
       //查询好友列表
       //查询好友列表
       this.OpenIM.getFriendListPage({ offset:0, count:100 })
       this.OpenIM.getFriendListPage({ offset:0, count:100 })
@@ -198,7 +203,12 @@ export default {
           this.$store.commit('updateFriendList', data)
           this.$store.commit('updateFriendList', data)
         })
         })
         .catch(({ errCode, errMsg }) => {
         .catch(({ errCode, errMsg }) => {
-          // 调用失败
+          if (errCode === 1004) {
+            console.log("暂无好友数据")
+            this.$store.commit('updateFriendList', [])
+          } else {
+            console.error("获取好友列表失败", errCode, errMsg)
+          }
         })
         })
     },
     },