|
@@ -14,7 +14,10 @@ Page({
|
|
|
currentGroup: null,
|
|
|
chatContent: [],
|
|
|
inputValue: '',
|
|
|
+ second: 5,
|
|
|
+ showmodal: false,
|
|
|
bottom: "", //滑到底状态 防止弹出消息不跳到最后一条
|
|
|
+ talkStatus: true, //初始值为true
|
|
|
onSdkReady: function (event) {
|
|
|
let _this = this;
|
|
|
console.log(event, "im准备好了")
|
|
@@ -36,6 +39,7 @@ Page({
|
|
|
_this.setData({
|
|
|
currentGroup: imResponse.data.group
|
|
|
})
|
|
|
+ _this.getjyList(imResponse.data.group)
|
|
|
console.log(_this.data.currentGroup, "加群成功") // 加入的群组资料
|
|
|
break;
|
|
|
case TIM.TYPES.JOIN_STATUS_ALREADY_IN_GROUP: // 已经在群中
|
|
@@ -48,7 +52,6 @@ Page({
|
|
|
console.warn('申请加群失败的相关信息', imError); // 申请加群失败的相关信息
|
|
|
});
|
|
|
} else {
|
|
|
- console.log(imResponse.data.groupList, _this.data.roomIdandcourseId, "888888888888888888")
|
|
|
for (let i = 0; i < imResponse.data.groupList.length; i++) {
|
|
|
if (imResponse.data.groupList[i].groupID == _this.data.roomIdandcourseId) {
|
|
|
// console.log(imResponse.data.groupList[i])
|
|
@@ -57,7 +60,7 @@ Page({
|
|
|
_this.setData({
|
|
|
currentGroup: imResponse.data.groupList[i]
|
|
|
})
|
|
|
- console.log(_this.data.currentGroup, "0000000000000000")
|
|
|
+ _this.getjyList(imResponse.data.groupList[i])
|
|
|
}
|
|
|
if (_this.data.currentGroup == null) {
|
|
|
let promise = _this.data.tim.joinGroup({
|
|
@@ -79,6 +82,7 @@ Page({
|
|
|
_this.setData({
|
|
|
currentGroup: imResponse.data.group
|
|
|
})
|
|
|
+ _this.getjyList(imResponse.data.group)
|
|
|
console.log(_this.data.currentGroup, "0000000000000000")
|
|
|
}).catch(function (imError) {
|
|
|
console.warn('申请加群失败的相关信息', imError); // 申请加群失败的相关信息
|
|
@@ -86,14 +90,12 @@ Page({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- // if (imResponse.data.groupList.length == 0 || this.data.currentGroup.length == 0)
|
|
|
- // }
|
|
|
}).catch(function (imError) {
|
|
|
console.log(imError, "获取群组列表失败的相关信息"); // 获取群组列表失败的相关信息
|
|
|
});
|
|
|
//修改成员名字
|
|
|
- let promise1 = this.data.tim.updateMyProfile({
|
|
|
- nick: this.data.miniName
|
|
|
+ let promise1 = _this.data.tim.updateMyProfile({
|
|
|
+ nick: _this.data.miniName
|
|
|
});
|
|
|
promise1.then(function (imResponse) {
|
|
|
console.log(imResponse.data, "更新资料成功"); // 群组列表
|
|
@@ -103,7 +105,7 @@ Page({
|
|
|
},
|
|
|
onSdkRecived: function (event) {
|
|
|
let _this = this;
|
|
|
- console.log(event.data, _this.data.currentGroup.groupID, "我收到消息了")
|
|
|
+ console.log(event.data[0].payload.data,"我收到消息了")
|
|
|
if (event.data[0].conversationType == "GROUP" && event.data[0].to == _this.data.currentGroup.groupID) {
|
|
|
console.log("我找到这个会话了", _this.data.chatContent)
|
|
|
if (_this.data.chatContent.length > 0) { // 表示不是第一次填数据,可以使用push
|
|
@@ -122,7 +124,6 @@ Page({
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
- console.log(_this.data.chatContent, "2222222222222222222222222")
|
|
|
if (event.data[0].payload.data == "stopLive") {
|
|
|
wx.showModal({
|
|
|
content: "当前直播结束了!",
|
|
@@ -144,83 +145,216 @@ Page({
|
|
|
_this.trtcRoomContext.unpublishLocalVideo();
|
|
|
_this.trtcRoomContext.unpublishLocalAudio();
|
|
|
}
|
|
|
+ if (event.data[0].payload.data == "readyPutLocalStream") {
|
|
|
+ _this.setData({
|
|
|
+ showmodal: true
|
|
|
+ })
|
|
|
+ _this.countdown()
|
|
|
+ }
|
|
|
+ if (event.data[0].payload.data == "stopTalk") {
|
|
|
+ _this.setData({
|
|
|
+ talkStatus: false
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '您被老师禁言啦', //提示文字
|
|
|
+ duration: 3000, //显示时长
|
|
|
+ mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
|
|
|
+ icon: 'none' //图标,支持"success"、"loading"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (event.data[0].payload.data == "keepTalk") {
|
|
|
+ _this.setData({
|
|
|
+ talkStatus: true
|
|
|
+ })
|
|
|
+ wx.showToast({
|
|
|
+ title: '您的禁言被解除了,可以正常发言啦', //提示文字
|
|
|
+ duration: 3000, //显示时长
|
|
|
+ mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
|
|
|
+ icon: 'none' //图标,支持"success"、"loading"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // if (event.data[0].payload.data == "stopTalkList") {
|
|
|
+ // console.log(event.data[0].payload, "1111111111")
|
|
|
+ // if (event.data[0].payload.description == "false") {
|
|
|
+ // _this.setData({
|
|
|
+ // talkStatus: false
|
|
|
+ // })
|
|
|
+ // wx.showToast({
|
|
|
+ // title: '您被老师禁言啦', //提示文字
|
|
|
+ // duration: 3000, //显示时长
|
|
|
+ // mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
|
|
|
+ // icon: 'none' //图标,支持"success"、"loading"
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ answer() {
|
|
|
+ this.setData({
|
|
|
+ showmodal: false,
|
|
|
+ second: 5
|
|
|
+ });
|
|
|
+ clearTimeout(this.data.timer);
|
|
|
+ let _this = this;
|
|
|
+ let message = _this.data.tim.createCustomMessage({
|
|
|
+ to: "teacher-" + _this.data.currentGroup.groupID,
|
|
|
+ conversationType: TIM.TYPES.CONV_C2C,
|
|
|
+ payload: {
|
|
|
+ data: 'yesStudentPutHand'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let promise = _this.data.tim.sendMessage(message);
|
|
|
+ promise.then(function (imResponse) {
|
|
|
+ console.log(imResponse, "我给老师发消息说我同意啦");
|
|
|
+ }).catch(function (imError) {
|
|
|
+ console.warn('我给老师发消息说我同意失败啦', imError);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ refuse() {
|
|
|
+ this.setData({
|
|
|
+ showmodal: false,
|
|
|
+ second: 5
|
|
|
+ });
|
|
|
+ clearTimeout(this.data.timer);
|
|
|
+ let _this = this;
|
|
|
+ let message = _this.data.tim.createCustomMessage({
|
|
|
+ to: "teacher-" + _this.data.currentGroup.groupID,
|
|
|
+ conversationType: TIM.TYPES.CONV_C2C,
|
|
|
+ payload: {
|
|
|
+ data: 'notStudentPutHand'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let promise = _this.data.tim.sendMessage(message);
|
|
|
+ promise.then(function (imResponse) {
|
|
|
+ console.log(imResponse, "我给老师发消息说我不同意");
|
|
|
+ }).catch(function (imError) {
|
|
|
+ console.warn('我给老师发消息说我不同意失败啦', imError);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ countdown() {
|
|
|
+ var second = this.data.second
|
|
|
+ if (second == 0) {
|
|
|
+ this.refuse();
|
|
|
+ return;
|
|
|
}
|
|
|
+ this.setData({
|
|
|
+ timer: setTimeout(() => {
|
|
|
+ this.setData({
|
|
|
+ second: second - 1
|
|
|
+ });
|
|
|
+ this.countdown();
|
|
|
+ }, 1000)
|
|
|
+ })
|
|
|
},
|
|
|
// 举手
|
|
|
handsup() {
|
|
|
- console.log(this.data.currentGroup)
|
|
|
+ console.log(this.data.currentGroup, "0000000000")
|
|
|
+ if (this.data.talkStatus) {
|
|
|
+ let message = this.data.tim.createCustomMessage({
|
|
|
+ to: "teacher-" + this.data.currentGroup.groupID,
|
|
|
+ conversationType: TIM.TYPES.CONV_C2C,
|
|
|
+ payload: {
|
|
|
+ data: 'studentPutHand'
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let promise = this.data.tim.sendMessage(message);
|
|
|
+ promise.then(function (imResponse) {
|
|
|
+ console.log(imResponse);
|
|
|
+ wx.showToast({
|
|
|
+ title: '举手成功',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 2000,
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ }).catch(function (imError) {
|
|
|
+ console.warn('sendMessage error:', imError);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '您被老师禁言啦', //提示文字
|
|
|
+ duration: 3000, //显示时长
|
|
|
+ mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
|
|
|
+ icon: 'none' //图标,支持"success"、"loading"
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //发送禁言列表消息
|
|
|
+ getjyList(e) {
|
|
|
let message = this.data.tim.createCustomMessage({
|
|
|
- to: "teacher-" + this.data.currentGroup.groupID,
|
|
|
+ to: "teacher-" + e.groupID,
|
|
|
conversationType: TIM.TYPES.CONV_C2C,
|
|
|
payload: {
|
|
|
- data: 'studentPutHand'
|
|
|
+ data: 'getStopTalkList'
|
|
|
}
|
|
|
});
|
|
|
let promise = this.data.tim.sendMessage(message);
|
|
|
promise.then(function (imResponse) {
|
|
|
- console.log(imResponse);
|
|
|
- wx.showToast({
|
|
|
- title: '举手成功',
|
|
|
- icon: 'success',
|
|
|
- duration: 2000,
|
|
|
- mask: true
|
|
|
- })
|
|
|
+ console.log("成功", imResponse);
|
|
|
}).catch(function (imError) {
|
|
|
console.warn('sendMessage error:', imError);
|
|
|
});
|
|
|
},
|
|
|
// 发消息
|
|
|
sendMessage() {
|
|
|
- if (this.data.inputValue == null || this.data.inputValue == "") {
|
|
|
- wx.showModal({
|
|
|
- content: "不可以发送空消息哦!",
|
|
|
- showCancel: false
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
- console.log(this.data.currentGroup)
|
|
|
- let message = this.data.tim.createTextMessage({
|
|
|
- to: this.data.currentGroup.groupID,
|
|
|
- conversationType: TIM.TYPES.CONV_GROUP,
|
|
|
- priority: TIM.TYPES.MSG_PRIORITY_NORMAL,
|
|
|
- payload: {
|
|
|
- text: this.data.inputValue
|
|
|
- }
|
|
|
- });
|
|
|
- let promise = this.data.tim.sendMessage(message);
|
|
|
- promise.then((imResponse) => {
|
|
|
- console.log(imResponse, "发送成功");
|
|
|
- if (this.data.chatContent.length > 0) { // 表示不是第一次填数据,可以使用push
|
|
|
- console.log("表示不是第一次填数据,可以使用push", this.data.chatContent)
|
|
|
- const chatContent = this.data.chatContent
|
|
|
- chatContent.push({
|
|
|
- nick: this.data.miniName,
|
|
|
- payload: {
|
|
|
- text: this.data.inputValue
|
|
|
- }
|
|
|
- })
|
|
|
- this.setData({
|
|
|
- chatContent: chatContent,
|
|
|
- bottom: 'scrollBottom'
|
|
|
+ if (this.data.talkStatus) {
|
|
|
+ if (this.data.inputValue == null || this.data.inputValue == "") {
|
|
|
+ wx.showModal({
|
|
|
+ content: "不可以发送空消息哦!",
|
|
|
+ showCancel: false
|
|
|
})
|
|
|
- } else { // 表示第一次填数据
|
|
|
- console.log("表示第一次填数据", this.data.chatContent)
|
|
|
- this.setData({
|
|
|
- chatContent: [{
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ console.log(this.data.currentGroup)
|
|
|
+ let message = this.data.tim.createTextMessage({
|
|
|
+ to: this.data.currentGroup.groupID,
|
|
|
+ conversationType: TIM.TYPES.CONV_GROUP,
|
|
|
+ priority: TIM.TYPES.MSG_PRIORITY_NORMAL,
|
|
|
+ payload: {
|
|
|
+ text: this.data.inputValue
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let promise = this.data.tim.sendMessage(message);
|
|
|
+ promise.then((imResponse) => {
|
|
|
+ console.log(imResponse, "发送成功");
|
|
|
+ if (this.data.chatContent.length > 0) { // 表示不是第一次填数据,可以使用push
|
|
|
+ console.log("表示不是第一次填数据,可以使用push", this.data.chatContent)
|
|
|
+ const chatContent = this.data.chatContent
|
|
|
+ chatContent.push({
|
|
|
nick: this.data.miniName,
|
|
|
payload: {
|
|
|
text: this.data.inputValue
|
|
|
}
|
|
|
- }],
|
|
|
- bottom: 'scrollBottom'
|
|
|
+ })
|
|
|
+ this.setData({
|
|
|
+ chatContent: chatContent,
|
|
|
+ bottom: 'scrollBottom'
|
|
|
+ })
|
|
|
+ } else { // 表示第一次填数据
|
|
|
+ console.log("表示第一次填数据", this.data.chatContent)
|
|
|
+ this.setData({
|
|
|
+ chatContent: [{
|
|
|
+ nick: this.data.miniName,
|
|
|
+ payload: {
|
|
|
+ text: this.data.inputValue
|
|
|
+ }
|
|
|
+ }],
|
|
|
+ bottom: 'scrollBottom'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ inputValue: ''
|
|
|
})
|
|
|
- }
|
|
|
- this.setData({
|
|
|
- inputValue: ''
|
|
|
+ }).catch(function (imError) {
|
|
|
+ console.warn('发送失败', imError);
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: '您被老师禁言啦', //提示文字
|
|
|
+ duration: 3000, //显示时长
|
|
|
+ mask: true, //是否显示透明蒙层,防止触摸穿透,默认:false
|
|
|
+ icon: 'none' //图标,支持"success"、"loading"
|
|
|
})
|
|
|
- }).catch(function (imError) {
|
|
|
- console.warn('发送失败', imError);
|
|
|
- });
|
|
|
+ }
|
|
|
},
|
|
|
bindKeyInput: function (e) {
|
|
|
this.setData({
|
|
@@ -237,7 +371,6 @@ Page({
|
|
|
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")
|
|
|
- console.log(sig, "ppppppppppppppppppppp")
|
|
|
let promise = this.data.tim.login({
|
|
|
userID: this.data.rtcConfig.userID,
|
|
|
userSig: sig.userSig
|
|
@@ -321,12 +454,12 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
+ console.log(options, "99999");
|
|
|
this.setData({
|
|
|
roomIdandcourseId: options.id
|
|
|
})
|
|
|
},
|
|
|
async onShow() {
|
|
|
- // console.log("我onShow了")
|
|
|
const sessionKey = await tools.checkSessionAndLogin();
|
|
|
const information = await tools.request('/wx/student/selStudentSessionKeyEcho', {
|
|
|
sessionKey
|