This commit is contained in:
zdg 2024-08-16 13:41:33 +08:00
parent 7fb98309fb
commit 75caf13d8b
4 changed files with 52 additions and 23 deletions

View File

@ -173,3 +173,15 @@ export function endClass(id) {
params: {id}
})
}
/**
* @description 获取课堂信息
* @param {*} id
* @returns
*/
export function getClassInfo(id) {
return request({
url: '/smarttalk/classReserv/selectById',
method: 'get',
params: {id}
})
}

View File

@ -37,7 +37,7 @@ export class ImChat {
// this.userSig = sig
this.userID = userID
window.test = this
this.timGroupId = '@TGS#3CYWMK2ON' // 测试使用
// this.timGroupId = '@TGS#3CYWMK2ON' // 测试使用
if (isInit) return this.init()
}
// 设置配置
@ -131,7 +131,6 @@ export class ImChat {
} else {
if (status == 1) { // 已登录
console.log('已登录')
this.setGroupMsgReceive()
resolve({status, msg:'已登录'})
} else if (status == 2) { // 登录中
console.log('登录中')
@ -188,10 +187,10 @@ export class ImChat {
return this.timChat.TIMGroupCreate(option).then(res => {
if (res && res.code == 0) {
const timGroupId = res?.json_param?.create_group_result_groupid
if (!!timGroupId){
if (!!timGroupId && timGroupId != 'undefined'){
this.setConsole('%c创建群组成功', timGroupId)
this.timGroupId = timGroupId
this.setGroupMsgReceive()
// this.setGroupMsgReceive()
}
}
return res
@ -206,10 +205,12 @@ export class ImChat {
})
}
// 设置群消息接收
setGroupMsgReceive() {
setGroupMsgReceive(timGroupId) {
if (!this.timGroupId) this.timGroupId = timGroupId || ''
if (!this.timGroupId) return console.log('timGroupId为空')
return this.timChat.TIMMsgSetGroupReceiveMessageOpt({
groupId: this.timGroupId,
opt: TYPES.TIMReceiveMessageOpt.kTIMRecvMsgOpt_Not_Notify,
opt: TYPES.TIMReceiveMessageOpt.kTIMRecvMsgOpt_Receive,
data: '', // 用户自定义数据
})
}
@ -225,6 +226,8 @@ export class ImChat {
}
// 发送消息
sendMsg(conv_id, msg) {
if (!conv_id) return console.log('conv_id为空')
if (typeof msg == 'object') msg = JSON.stringify(msg)
const option = {
conv_id,
conv_type: TYPES.TIMConvType.kTIMConv_Group,
@ -240,12 +243,12 @@ export class ImChat {
user_data: '', // 用户自定义数据
// callback: (data) => {}
}
console.log('发送消息', option)
return this.timChat.TIMMsgSendMessageV2(option)
}
// 发送关闭(下课)消息
sendMsgClosed(){
const msg = this.getMsgObj(MsgEnum.HEADS.MSG_closed, '下课', MsgEnum.TYPES.TEACHER)
console.log('发送关闭消息', msg)
return this.sendMsg(this.timGroupId, msg)
}
// 获取消息对象

View File

@ -58,7 +58,6 @@ const initImChat = async () => {
const createGroup = async (groupName) => {
if (!imChatObj.imChat) return
await imChatObj.imChat.createGroup(groupName)
// emits('change', {type:'createGroup', data: imChat.timGroupId})
emits('change', 'createGroup', imChatObj.imChat.timGroupId)
}
// 退

View File

@ -39,7 +39,7 @@
// electron
import { onMounted, ref, reactive, watchEffect } from 'vue'
import { useRoute } from 'vue-router';
import { ElMessageBox, ElMessage } from 'element-plus'
import { ElMessageBox, ElMessage, ElLoading } from 'element-plus'
import * as classManageApi from '@/api/classManage'
import logo from '@root/resources/icon.png' // logo
import boardVue from './components/board.vue' // -
@ -78,13 +78,26 @@ const btnList = [ // 工具栏按钮列表
// === ===
onMounted(async() => {
setTimeout(() => {
getClassInfo() // ex3
resetStatus() // -
}, 200);
})
// ==== ===
// const test = (e) => { console.log('test', e) }
//
const getClassInfo = async () => {
const { data } = await classManageApi.getClassInfo(classObj.id)
classObj.data = data
if(!data.ex3 || data.ex3 == 'undefined') { //
await imChatRef.value.imChatObj.imChat.createGroup(data.className)
const timGroupId = imChatRef.value.imChatObj.imChat.timGroupId
classManageApi.startClass(classObj.id, timGroupId) //
} else { //
// console.log(': ', data.ex3)
imChatRef.value.imChatObj.imChat.timGroupId = data.ex3
// imChatRef.value.imChatObj.imChat.setGroupMsgReceive(data.ex3)
}
}
// tab-change
const tabChange = (val) => {
const bool = !toolStore.isPdfWin && !toolStore.showBoardAll
@ -108,7 +121,8 @@ const mouseChange = (bool) => {
// im-chat: {type, data}
const chatChange = (type, data) => {
if (type == 'createGroup') { // -
classManageApi.startClass(classObj.id, data)
console.log('创建群:', data)
!!data && classManageApi.startClass(classObj.id, data)
} else if (type == 'msg') { // im-chat
if (!data) return // msg
const { msgKey:head, msgcontent:msg, senduserid:sendId, msgType } = data
@ -167,18 +181,19 @@ const sideChange = async o => {
}).then(async() => {
await imChatRef.value?.imChatObj?.imChat?.sendMsgClosed() //
// const elMsg = ElMessage.warning({duration:0,message:'...'})
// // 2
// setTimeout(async() => {
// elMsg.close()
// toolStore.isToolWin = false
// await classManageApi.endClass(route.query.reservId)
// await imChatRef.value?.deleteGroup() //
// await imChatRef.value?.logout() // 退im
// ipcMsgSend('tool-sphere:close') //
// }, 2000);
const elMsg = ElLoading.service({lock: true, text: '正在下课...', background: 'rgba(0, 0, 0, 0.7)'})
// 2
setTimeout(async() => {
elMsg.close()
toolStore.isToolWin = false
await classManageApi.endClass(route.query.reservId)
await imChatRef.value?.deleteGroup() //
await imChatRef.value?.logout() // 退im
ipcMsgSend('tool-sphere:close') //
}, 2000);
isOver.value = false
setIgnore(true) // -穿
// isOver.value = false
// setIgnore(true) // -穿
}).catch(() => {
isOver.value = false
setIgnore(true) // -穿