|
@@ -15,6 +15,8 @@ Page({
|
|
|
currentGroup: null,
|
|
|
chatContent: [],
|
|
|
inputValue: '',
|
|
|
+ isLoad:false,
|
|
|
+ // streamIdList:[],
|
|
|
// second: 5,
|
|
|
showmodal: false,
|
|
|
bottom: "", //滑到底状态 防止弹出消息不跳到最后一条
|
|
@@ -54,6 +56,9 @@ Page({
|
|
|
});
|
|
|
} else {
|
|
|
for (let i = 0; i < imResponse.data.groupList.length; i++) {
|
|
|
+ console.log(imResponse, '我是imResponse')
|
|
|
+ console.log(imResponse.data.groupList[i].groupID, '我是循环出来的id')
|
|
|
+ console.log(_this.data.roomIdandcourseId, '我是带过来的id')
|
|
|
if (imResponse.data.groupList[i].groupID == _this.data.roomIdandcourseId) {
|
|
|
// console.log(imResponse.data.groupList[i])
|
|
|
// let pushArr = this.data.currentGroup.push(imResponse.data.groupList[i])
|
|
@@ -63,8 +68,10 @@ Page({
|
|
|
})
|
|
|
_this.getjyList(imResponse.data.groupList[i])
|
|
|
}
|
|
|
+ console.log(_this.data.currentGroup)
|
|
|
}
|
|
|
if (_this.data.currentGroup == null) {
|
|
|
+ console.log('我进入null')
|
|
|
let promise = _this.data.tim.joinGroup({
|
|
|
groupID: _this.data.roomIdandcourseId,
|
|
|
type: TIM.TYPES.GRP_MEETING
|
|
@@ -393,6 +400,7 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
async onTim() {
|
|
|
+ console.log("onTim++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
|
|
this.data.tim.on(TIM.EVENT.SDK_READY, this.data.onSdkReady, this);
|
|
|
this.data.tim.on(TIM.EVENT.MESSAGE_RECEIVED, this.data.onSdkRecived, this);
|
|
|
const sig = await getusersig.genTestUserSig(this.data.rtcConfig.userID, this.data.rtcConfig.sdkAppID, "f1ca85809aed35d82d8bb76612787e38dada5d0a6f233662777b42bdb7eb880b")
|
|
@@ -417,6 +425,9 @@ Page({
|
|
|
let promise = this.data.tim.logout();
|
|
|
promise.then(function (imResponse) {
|
|
|
console.log(imResponse.data, " 登出成功");
|
|
|
+ this.setData({
|
|
|
+ tim: null
|
|
|
+ })
|
|
|
}).catch(function (imError) {
|
|
|
console.warn(' 登出失败:', imError);
|
|
|
});
|
|
@@ -485,29 +496,33 @@ Page({
|
|
|
roomID: Number(this.data.roomIdandcourseId) //课程id
|
|
|
// userID: this.data.rtcConfig.userID
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
// onLoad(options) {
|
|
|
- // console.log(options, "99999");
|
|
|
- // this.setData({
|
|
|
- // roomIdandcourseId: options.id
|
|
|
- // })
|
|
|
+ // console.log(options, "我onLoad了");
|
|
|
+ // this.setData({
|
|
|
+ // roomIdandcourseId: options.id
|
|
|
+ // })
|
|
|
+ // console.log(this.data.roomIdandcourseId)
|
|
|
// },
|
|
|
+
|
|
|
async onShow() {
|
|
|
- // 获取当前小程序的页面栈
|
|
|
let pages = getCurrentPages();
|
|
|
- // 数组中索引最大的页面--当前页面
|
|
|
let currentPage = pages[pages.length - 1];
|
|
|
- // 打印出当前页面中的 options
|
|
|
console.log(currentPage.options.id, 'wwww')
|
|
|
this.setData({
|
|
|
roomIdandcourseId: currentPage.options.id
|
|
|
})
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ if(this.data.isLoad){
|
|
|
+ this.trtcRoomContext.subscribeRemoteAudio({
|
|
|
+ userID: "0"
|
|
|
+ }).then(() => {
|
|
|
+ console.log("音频订阅")
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ this.setData({
|
|
|
+ isLoad:true
|
|
|
+ })
|
|
|
+ console.log("我onshow了")
|
|
|
const sessionKey = await tools.checkSessionAndLogin();
|
|
|
const information = await tools.request('/wx/student/selStudentSessionKeyEcho', {
|
|
|
sessionKey
|
|
@@ -520,7 +535,6 @@ Page({
|
|
|
this.setData({
|
|
|
['rtcConfig.userSig']: sig.userSig
|
|
|
})
|
|
|
- //保持页面常亮
|
|
|
wx.setKeepScreenOn({
|
|
|
keepScreenOn: true,
|
|
|
})
|
|
@@ -537,12 +551,58 @@ Page({
|
|
|
'cos-wx-sdk': COS
|
|
|
});
|
|
|
this.onTim();
|
|
|
+ }
|
|
|
+
|
|
|
+ // console.log("我onshow了")
|
|
|
+ // const sessionKey = await tools.checkSessionAndLogin();
|
|
|
+ // const information = await tools.request('/wx/student/selStudentSessionKeyEcho', {
|
|
|
+ // sessionKey
|
|
|
+ // }, 'POST');
|
|
|
+ // this.setData({
|
|
|
+ // miniName: information.data.data.miniName,
|
|
|
+ // ['rtcConfig.userID']: information.data.data.id.toString()
|
|
|
+ // })
|
|
|
+ // const sig = await getusersig.genTestUserSig(this.data.rtcConfig.userID, this.data.rtcConfig.sdkAppID, "f1ca85809aed35d82d8bb76612787e38dada5d0a6f233662777b42bdb7eb880b")
|
|
|
+ // this.setData({
|
|
|
+ // ['rtcConfig.userSig']: sig.userSig
|
|
|
+ // })
|
|
|
+ // wx.setKeepScreenOn({
|
|
|
+ // keepScreenOn: true,
|
|
|
+ // })
|
|
|
+ // this.trtcRoomContext = this.selectComponent('#trtcroom')
|
|
|
+ // this.bindTRTCRoomEvent()
|
|
|
+ // let option = {
|
|
|
+ // SDKAppID: 1400404379 // 接入时需要将0替换为您的即时通信 IM 应用的 SDKAppID
|
|
|
+ // };
|
|
|
+ // this.setData({
|
|
|
+ // tim: TIM.create(option)
|
|
|
+ // })
|
|
|
+ // this.data.tim.setLogLevel(0); // 普通级别,日志量较多,接入时建议使用
|
|
|
+ // this.data.tim.registerPlugin({
|
|
|
+ // 'cos-wx-sdk': COS
|
|
|
+ // });
|
|
|
+ // this.onTim();
|
|
|
},
|
|
|
onHide() {
|
|
|
console.log("zbdetail-onhide了")
|
|
|
this.trtcRoomContext.unpublishLocalVideo();
|
|
|
this.trtcRoomContext.unpublishLocalAudio();
|
|
|
- this.offTim();
|
|
|
+ // this.offTim();
|
|
|
+ // this.trtcRoomContext.unsubscribeRemoteVideo({
|
|
|
+ // userID: "0",
|
|
|
+ // streamType: "main"
|
|
|
+ // }).then(() => {
|
|
|
+ // console.log("远端视频订阅成功")
|
|
|
+ // })
|
|
|
+ this.trtcRoomContext.unsubscribeRemoteAudio({
|
|
|
+ userID: "0"
|
|
|
+ }).then(() => {
|
|
|
+ console.log("音频取消订阅")
|
|
|
+ })
|
|
|
+ // this.trtcRoomContext.exitRoom().then(()=>{
|
|
|
+ // console.log("退出房间成功")
|
|
|
+ // // 退出房间成功
|
|
|
+ // })
|
|
|
},
|
|
|
onUnload() {
|
|
|
console.log("zbdetail-onUnload")
|