|
@@ -2,7 +2,7 @@
|
|
|
|
|
|
import { fetchRoom, RoomDetailType } from '../../api/fetchRoom'
|
|
import { fetchRoom, RoomDetailType } from '../../api/fetchRoom'
|
|
import { shareRoom } from '../../api/shareRoom'
|
|
import { shareRoom } from '../../api/shareRoom'
|
|
-import { getRTCSig, getArgoraRTCSig } from '../../api/sign'
|
|
|
|
|
|
+import { getRTCSig } from '../../api/sign'
|
|
import { server } from '../../config'
|
|
import { server } from '../../config'
|
|
import { authorizeRecord } from '../../utils/util'
|
|
import { authorizeRecord } from '../../utils/util'
|
|
import { audioManger, AudioManger } from './libs/audioManager'
|
|
import { audioManger, AudioManger } from './libs/audioManager'
|
|
@@ -28,9 +28,12 @@ Page({
|
|
m: '',
|
|
m: '',
|
|
showShare: false,
|
|
showShare: false,
|
|
// roleId: ''
|
|
// roleId: ''
|
|
- argoraConfig: { sdkAppId: '', token: '', chanelName: "", userId: "" },
|
|
|
|
|
|
+ argoraConfig: { sdkAppId: '', token: '', chanelName: "", userId: "", rtcSDKInit: false },
|
|
muted: true,
|
|
muted: true,
|
|
audioOperatorType: NaN,
|
|
audioOperatorType: NaN,
|
|
|
|
+ roomHostName: '',
|
|
|
|
+ roomInfo: {} as RoomDetailType
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
|
|
|
|
@@ -58,13 +61,33 @@ Page({
|
|
const isSuccess = await this.setWebViewUrl();
|
|
const isSuccess = await this.setWebViewUrl();
|
|
if (isSuccess) {
|
|
if (isSuccess) {
|
|
this.handleJoinSocket();
|
|
this.handleJoinSocket();
|
|
- this.handleJoinRTC();
|
|
|
|
|
|
+ if (!this.data.roomInfo.takeLookLock) {
|
|
|
|
+ this.handleJoinRTC();
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
async setRole(roomId: string) {
|
|
async setRole(roomId: string) {
|
|
let roomInfo: RoomDetailType
|
|
let roomInfo: RoomDetailType
|
|
roomInfo = await fetchRoom(roomId);
|
|
roomInfo = await fetchRoom(roomId);
|
|
|
|
+
|
|
|
|
+ this.setData({
|
|
|
|
+ roomInfo: roomInfo
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ if (roomInfo.takeLookLock) {
|
|
|
|
+ this.setData({
|
|
|
|
+ 'argoraConfig.rtcSDKInit': false
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ this.setData({
|
|
|
|
+ 'argoraConfig.rtcSDKInit': true
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
if (!roomInfo) {
|
|
if (!roomInfo) {
|
|
wx.showModal({
|
|
wx.showModal({
|
|
title: '提示',
|
|
title: '提示',
|
|
@@ -103,6 +126,13 @@ Page({
|
|
return
|
|
return
|
|
}
|
|
}
|
|
this.setData({ roomDetail: roomInfo, roomId: roomId, m: num })
|
|
this.setData({ roomDetail: roomInfo, roomId: roomId, m: num })
|
|
|
|
+ if (roomInfo && roomInfo.roomHostName?.length) {
|
|
|
|
+ var reg = /\\|\/|\?|\?|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\【|\】|\:|\:|\、|\^|\$|\#|\&|\%|\!|\~|\`|\|/g;
|
|
|
|
+ var temp = roomInfo.roomHostName.replace(reg, "◻");
|
|
|
|
+ this.setData({
|
|
|
|
+ roomHostName: temp.length > 14 ? encodeURIComponent(temp.substr(0, 14) + '...') : encodeURIComponent(temp)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
if (roomInfo && roomInfo.hostStatus === 0) {
|
|
if (roomInfo && roomInfo.hostStatus === 0) {
|
|
@@ -130,6 +160,9 @@ Page({
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// });
|
|
// });
|
|
|
|
+ if (roomInfo.head?.length) {
|
|
|
|
+ this.setData({ 'userInfo.avatarUrl': roomInfo.head })
|
|
|
|
+ }
|
|
|
|
|
|
this.setData({ role: 'leader' })
|
|
this.setData({ role: 'leader' })
|
|
} else {
|
|
} else {
|
|
@@ -169,16 +202,24 @@ Page({
|
|
}
|
|
}
|
|
filterNickname(this.data.userInfo.nickName);
|
|
filterNickname(this.data.userInfo.nickName);
|
|
|
|
|
|
|
|
+ let userNickName = this.data.userInfo.nickName.length > 14 ? encodeURIComponent(this.data.userInfo.nickName.substr(0, 14) + '...') : encodeURIComponent(this.data.userInfo.nickName)
|
|
|
|
+
|
|
|
|
+ const token = wx.getStorageSync('token') || '';
|
|
|
|
+
|
|
const params: SocketParams = {
|
|
const params: SocketParams = {
|
|
vruserId: `${this.data.userInfo.wxUserId}`,
|
|
vruserId: `${this.data.userInfo.wxUserId}`,
|
|
roomId: `${this.data.roomId}`,
|
|
roomId: `${this.data.roomId}`,
|
|
role: this.data.role,
|
|
role: this.data.role,
|
|
avatar: encodeURIComponent(this.data.userInfo.avatarUrl),
|
|
avatar: encodeURIComponent(this.data.userInfo.avatarUrl),
|
|
- name: this.data.userInfo.nickName.length > 14 ? encodeURIComponent(this.data.userInfo.nickName.substr(0, 14) + '...') : encodeURIComponent(this.data.userInfo.nickName),
|
|
|
|
|
|
+ name: (this.data.roomHostName.length > 0 && this.data.role === 'leader') ? this.data.roomHostName : userNickName,
|
|
isTour: this.data.isTour,
|
|
isTour: this.data.isTour,
|
|
m: this.data.m,
|
|
m: this.data.m,
|
|
fromMiniApp: 1,
|
|
fromMiniApp: 1,
|
|
|
|
+ vlog: 1,
|
|
|
|
+ wxToken: token
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
+
|
|
this.setData({
|
|
this.setData({
|
|
webviewParams: params
|
|
webviewParams: params
|
|
})
|
|
})
|
|
@@ -189,7 +230,8 @@ Page({
|
|
|
|
|
|
async autoLogin() {
|
|
async autoLogin() {
|
|
const app = getApp<IAppOption>();
|
|
const app = getApp<IAppOption>();
|
|
- if (!app.globalData.isLogin) {
|
|
|
|
|
|
+ const isLogin = wx.getStorageSync("isLogin")
|
|
|
|
+ if (!app.globalData.isLogin || !isLogin) {
|
|
const userInfo = await app.login(false)
|
|
const userInfo = await app.login(false)
|
|
console.log('hehe', userInfo)
|
|
console.log('hehe', userInfo)
|
|
userInfo && this.updateUserInfo(userInfo);
|
|
userInfo && this.updateUserInfo(userInfo);
|
|
@@ -225,7 +267,9 @@ Page({
|
|
const isSuccess = await this.setWebViewUrl();
|
|
const isSuccess = await this.setWebViewUrl();
|
|
if (isSuccess) {
|
|
if (isSuccess) {
|
|
this.handleJoinSocket();
|
|
this.handleJoinSocket();
|
|
- this.handleJoinRTC();
|
|
|
|
|
|
+ if (!this.data.roomInfo.takeLookLock) {
|
|
|
|
+ this.handleJoinRTC();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
updateUserInfo(data?: any) {
|
|
updateUserInfo(data?: any) {
|
|
@@ -272,15 +316,15 @@ Page({
|
|
});
|
|
});
|
|
switch (sign.operatorType) {
|
|
switch (sign.operatorType) {
|
|
case 0:
|
|
case 0:
|
|
- wx.showToast({
|
|
|
|
- title: '当前语音:腾讯'
|
|
|
|
- })
|
|
|
|
|
|
+ // wx.showToast({
|
|
|
|
+ // title: '当前语音:腾讯'
|
|
|
|
+ // })
|
|
this.handleJoinTRTCRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
|
|
this.handleJoinTRTCRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
|
|
break;
|
|
break;
|
|
case 1:
|
|
case 1:
|
|
- wx.showToast({
|
|
|
|
- title: '当前语音:声网'
|
|
|
|
- })
|
|
|
|
|
|
+ // wx.showToast({
|
|
|
|
+ // title: '当前语音:声网'
|
|
|
|
+ // })
|
|
this.handleJoinArgoraRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
|
|
this.handleJoinArgoraRTC(userId, roomId, String(sign.sdkAppId), sign.sign);
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|
|
@@ -301,6 +345,7 @@ Page({
|
|
chanelName: roomId,
|
|
chanelName: roomId,
|
|
//@ts-ignore
|
|
//@ts-ignore
|
|
userId: userId as any,
|
|
userId: userId as any,
|
|
|
|
+ rtcSDKInit: this.data.argoraConfig.rtcSDKInit
|
|
// roleId: roleId as any
|
|
// roleId: roleId as any
|
|
}
|
|
}
|
|
})
|
|
})
|
|
@@ -323,10 +368,26 @@ Page({
|
|
/**
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
*/
|
|
- onReady() {
|
|
|
|
|
|
+ async onReady() {
|
|
const app = getApp<IAppOption>();
|
|
const app = getApp<IAppOption>();
|
|
app.watch('userInfo', this.updateUserInfo)
|
|
app.watch('userInfo', this.updateUserInfo)
|
|
-
|
|
|
|
|
|
+ const systemInfo = await wx.getSystemInfo();
|
|
|
|
+ if (systemInfo.platform === 'windows') {
|
|
|
|
+ // debugger
|
|
|
|
+ wx.showModal({
|
|
|
|
+ title: '提示',
|
|
|
|
+ content: 'PC端暂不支持带看',
|
|
|
|
+ showCancel:false,
|
|
|
|
+ success(res) {
|
|
|
|
+ if (res.confirm) {
|
|
|
|
+ wx.switchTab({
|
|
|
|
+ url: "/pages/index/index"
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -405,6 +466,9 @@ Page({
|
|
handleSocketAction(action: SocketAction) {
|
|
handleSocketAction(action: SocketAction) {
|
|
console.warn('action', action)
|
|
console.warn('action', action)
|
|
switch (action.type) {
|
|
switch (action.type) {
|
|
|
|
+ case 'confirm-password':
|
|
|
|
+ this.handleConfirmPassword(action.data)
|
|
|
|
+ break;
|
|
case 'users-muted':
|
|
case 'users-muted':
|
|
this.handleActionMuted(action.userId, action.muted)
|
|
this.handleActionMuted(action.userId, action.muted)
|
|
break;
|
|
break;
|
|
@@ -414,10 +478,38 @@ Page({
|
|
case 'changeScene':
|
|
case 'changeScene':
|
|
this.hanldeAudioDefaultMuted(true);
|
|
this.hanldeAudioDefaultMuted(true);
|
|
break;
|
|
break;
|
|
|
|
+ case 'share':
|
|
|
|
+ this.handleShare(action.data);
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ handleShare(data: any) {
|
|
|
|
+ const userId = data.userId || '';
|
|
|
|
+
|
|
|
|
+ const f_userId = userId.replace('user_', '')
|
|
|
|
+ const app = getApp<IAppOption>();
|
|
|
|
+ if (f_userId && app.globalData.userInfo?.wxUserId == f_userId) {
|
|
|
|
+
|
|
|
|
+ const url = `/pages/share/share?id=${this.data.roomId}`
|
|
|
|
+ console.log('url', url)
|
|
|
|
+ wx.navigateTo({
|
|
|
|
+ url: url
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ handleConfirmPassword(data: any) {
|
|
|
|
+ const userId = data.userId || '';
|
|
|
|
+ const f_userId = userId.replace('user_', '')
|
|
|
|
+ const app = getApp<IAppOption>();
|
|
|
|
+ if (f_userId && app.globalData.userInfo?.wxUserId == f_userId) {
|
|
|
|
+ this.setData({
|
|
|
|
+ 'argoraConfig.rtcSDKInit': true
|
|
|
|
+ })
|
|
|
|
+ this.handleJoinRTC();
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
|
|
hanldeAudioDefaultMuted(value: boolean) {
|
|
hanldeAudioDefaultMuted(value: boolean) {
|
|
switch (this.data.audioOperatorType) {
|
|
switch (this.data.audioOperatorType) {
|