|
@@ -175,6 +175,7 @@
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
<script>
|
|
<script>
|
|
|
|
+ import Vue from 'vue'
|
|
import screenfull from 'screenfull'
|
|
import screenfull from 'screenfull'
|
|
import Pdf from '@/views/pdf.vue'
|
|
import Pdf from '@/views/pdf.vue'
|
|
import html2canvas from 'html2canvas'
|
|
import html2canvas from 'html2canvas'
|
|
@@ -194,7 +195,7 @@
|
|
import jwt_decode from "jwt-decode";
|
|
import jwt_decode from "jwt-decode";
|
|
// import E from "@/plugin/wangEditor.js"
|
|
// import E from "@/plugin/wangEditor.js"
|
|
import moreoage from '../assets/99page/htex.json'
|
|
import moreoage from '../assets/99page/htex.json'
|
|
- import { signalRInfo, sendMessage, onConnected, data } from "../plugin/signalr.js"
|
|
|
|
|
|
+ import { signalRInfo, sendMessage, onConnected, ImData } from "../plugin/signalr.js"
|
|
const width = window.innerWidth
|
|
const width = window.innerWidth
|
|
const height = window.innerHeight
|
|
const height = window.innerHeight
|
|
let vm = {}
|
|
let vm = {}
|
|
@@ -339,7 +340,12 @@
|
|
'channel_num': '',
|
|
'channel_num': '',
|
|
'channel_rest_api': '',
|
|
'channel_rest_api': '',
|
|
'channel_url':''
|
|
'channel_url':''
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ IMcounter: 0,
|
|
|
|
+ //座位号
|
|
|
|
+ seatNum: 0,
|
|
|
|
+ //加入学生单个信息
|
|
|
|
+ studentAlone: {}
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -1750,7 +1756,7 @@
|
|
}
|
|
}
|
|
).then(res => {
|
|
).then(res => {
|
|
console.log(res,'申请教室成功')
|
|
console.log(res,'申请教室成功')
|
|
- localStorage.getItem('classNum', res.channel_num)
|
|
|
|
|
|
+ localStorage.setItem('classNum',res.channel_num)
|
|
this.classNum = res.channel_num
|
|
this.classNum = res.channel_num
|
|
this.$api.joinclass(
|
|
this.$api.joinclass(
|
|
{
|
|
{
|
|
@@ -1761,19 +1767,184 @@
|
|
}
|
|
}
|
|
).then(res => {
|
|
).then(res => {
|
|
this.imConnect = res
|
|
this.imConnect = res
|
|
- console.log(res, this.imConnect,'加入教室成功')
|
|
|
|
- this.imConnectinfo(res.access_token,res.channel_url)
|
|
|
|
|
|
+ console.log(res,'加入教室成功')
|
|
|
|
+ this.imConnectinfo(this,res.access_token,res.channel_url)
|
|
}).catch(res => {
|
|
}).catch(res => {
|
|
|
|
+ console.log(res,'失败原因')
|
|
this.$Message.error('加入教室失败,请尝试重连!')
|
|
this.$Message.error('加入教室失败,请尝试重连!')
|
|
})
|
|
})
|
|
}).catch(res => {
|
|
}).catch(res => {
|
|
|
|
+ console.log(res)
|
|
this.$Message.error('通讯连接失败,请尝试重连!')
|
|
this.$Message.error('通讯连接失败,请尝试重连!')
|
|
})
|
|
})
|
|
},
|
|
},
|
|
/*IM连接*/
|
|
/*IM连接*/
|
|
- imConnectinfo(acToken,url) {
|
|
|
|
- signalRInfo(url, acToken);
|
|
|
|
- this.$Message.success('通讯连接成功!')
|
|
|
|
|
|
+ imConnectinfo(that,acToken,urls) {
|
|
|
|
+ /* signalRInfo(url, acToken);*/
|
|
|
|
+ this.ConnectSignalR(that,urls, acToken)
|
|
|
|
+ //this.$Message.success('通讯连接成功!')
|
|
|
|
+ },
|
|
|
|
+ /*开始连接IM*/
|
|
|
|
+ ConnectSignalR(that,url, token) {
|
|
|
|
+ console.log(url, '连接地址')
|
|
|
|
+ console.log(token)
|
|
|
|
+ console.log(that)
|
|
|
|
+ const options = {
|
|
|
|
+ accessTokenFactory: () => token
|
|
|
|
+ };
|
|
|
|
+ const connection = new signalR.HubConnectionBuilder()
|
|
|
|
+ .withUrl(url, options)
|
|
|
|
+ .configureLogging(signalR.LogLevel.Information)
|
|
|
|
+ .build();
|
|
|
|
+ connection.on('onMessage', onMessage);
|
|
|
|
+ connection.on('onConnected', onConnected);
|
|
|
|
+ connection.on('onDisconnected', onDisconnected);
|
|
|
|
+ //connection.on('connectionSlow', onConnectionSlow);
|
|
|
|
+ connection.onclose(() => {
|
|
|
|
+ console.log('close connection')
|
|
|
|
+ connection.start()
|
|
|
|
+ .then(() => console.log('re-connection!'))
|
|
|
|
+ .catch(setTimeout(() => connection.start(), 5000));
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+ console.log('connecting...');
|
|
|
|
+ connection.start()
|
|
|
|
+ .then(() => console.log('connected!'))
|
|
|
|
+ .catch(console.log('Start connect fail!!'));
|
|
|
|
+ function onConnected(message) {
|
|
|
|
+ //data.myConnectionId = message.ConnectionId;
|
|
|
|
+ message.id = this.IMcounter++; // vue transitions need an id
|
|
|
|
+ // data.messages.unshift(message);
|
|
|
|
+ }
|
|
|
|
+ function onMessage(message) {
|
|
|
|
+ console.log(message, '收到消息!!!!')
|
|
|
|
+ console.log(message.To[0],'111111111111')
|
|
|
|
+ message.id = that.IMcounter++; // vue transitions need an id
|
|
|
|
+ message.Timestamp = Math.floor(Date.now())
|
|
|
|
+ var stateinfo = JSON.parse(message.Text)
|
|
|
|
+ that.singnalRMessage(stateinfo, '8888', message.ConnectionId)
|
|
|
|
+ };
|
|
|
|
+ function onDisconnected(message) {
|
|
|
|
+ message.id = this.IMcounter++; // vue transitions need an id
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ /*signalR发送消息*/
|
|
|
|
+ singnalRMessage(message, pincode, connectionId,) {
|
|
|
|
+ console.log('调用到发送消息方法')
|
|
|
|
+ var messages = message
|
|
|
|
+ let user = JSON.parse(localStorage.getItem('user'))
|
|
|
|
+ let sender = user.sub
|
|
|
|
+ let receive = []
|
|
|
|
+ receive.push(messages.sender)
|
|
|
|
+ let channelapi = this.imConnect.channel_api + '/messages'
|
|
|
|
+ let classnum = localStorage.getItem('classNum')
|
|
|
|
+ let time = Math.floor(Date.now())
|
|
|
|
+ //学生信息
|
|
|
|
+ var messageText = {}
|
|
|
|
+ if (messages.action === "Announce.Ask") {
|
|
|
|
+ messageText = {
|
|
|
|
+ "payload": {
|
|
|
|
+ "announceURL": "",
|
|
|
|
+ "announce": {
|
|
|
|
+ "classState": "InProcess",
|
|
|
|
+ "hostConnID": "",
|
|
|
|
+ "className": "HiTeachCC",
|
|
|
|
+ "memberCount": 0,
|
|
|
|
+ "verifyMode": "Dynamic",
|
|
|
|
+ "pincode": pincode,
|
|
|
|
+ "channel": classnum,
|
|
|
|
+ "memberList": [],
|
|
|
|
+ "groupList": [],
|
|
|
|
+ "apI_Version": 0,
|
|
|
|
+ "allowVisitor": true,
|
|
|
|
+ "schoolId": "HiTeachCC",
|
|
|
|
+ "schoolName": "动态云端课程",
|
|
|
|
+ "totalOptions": [
|
|
|
|
+ "A",
|
|
|
|
+ "B",
|
|
|
|
+ "C",
|
|
|
|
+ "D",
|
|
|
|
+ "E",
|
|
|
|
+ "F",
|
|
|
|
+ "G",
|
|
|
|
+ "H",
|
|
|
|
+ "I"
|
|
|
|
+ ]
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ "action": "Announce.Push",
|
|
|
|
+ "clientType": "CC",
|
|
|
|
+ "sender": "HiTeachCC-" + sender,
|
|
|
|
+ "timestamp": time,
|
|
|
|
+ "waitReturn": false
|
|
|
|
+ }
|
|
|
|
+ } else if (messages.action === "MemberBinding") {
|
|
|
|
+ this.seatNum = this.seatNum+1
|
|
|
|
+ messageText = {
|
|
|
|
+ "payload": {
|
|
|
|
+ "activityRecordNumber": "198384384636751872",
|
|
|
|
+ "id": messages.sender,
|
|
|
|
+ "seatID": this.seatNum,
|
|
|
|
+ "name": messages.payload.memberName,
|
|
|
|
+ "className": "HiTeachCC",
|
|
|
|
+ "schoolId": "HiTeachCC",
|
|
|
|
+ "schoolName": "动态云端课程",
|
|
|
|
+ "hostBlobUrl": "",
|
|
|
|
+ "clientBlobUrl": "",
|
|
|
|
+ "blobSAS": "",
|
|
|
|
+ "errorCode": 0
|
|
|
|
+ },
|
|
|
|
+ "action": "BindingResult",
|
|
|
|
+ "clientType": "CC",
|
|
|
|
+ "sender": 'HiTeachCC-' + sender,
|
|
|
|
+ "timestamp": time,
|
|
|
|
+ "waitReturn": false
|
|
|
|
+ }
|
|
|
|
+ this.studentAlone = { "id": messages.sender, "accountid": messages.payload.memberID, "studentName": messages.payload.memberName, "sendTime": time, "headImg":''}
|
|
|
|
+ } else if (messages.action === "State.Get") {
|
|
|
|
+ console.log(this.studentAlone,'查看数据')
|
|
|
|
+ this.students = this.$store.state.students
|
|
|
|
+ let oneStudent = {
|
|
|
|
+ sort: this.seatNum,
|
|
|
|
+ id: this.studentAlone.id,
|
|
|
|
+ accountid: this.studentAlone.accountid,
|
|
|
|
+ studentName: this.studentAlone.studentName,
|
|
|
|
+ sendTime: this.studentAlone.sendTime,
|
|
|
|
+ headImg: this.studentAlone.headImg,
|
|
|
|
+ option: '',
|
|
|
|
+ done: true,
|
|
|
|
+ score: 0,
|
|
|
|
+ rank: '',
|
|
|
|
+ class: 'studyboxone',
|
|
|
|
+ showcardclass: 'brand',
|
|
|
|
+ answerclass: 'studyboxone',
|
|
|
|
+ answerbrand: 'brand',
|
|
|
|
+ statement: '',//发言,
|
|
|
|
+ status: 'online'
|
|
|
|
+ }
|
|
|
|
+ if (oneStudent.headImg === undefined || oneStudent.headImg==='') {
|
|
|
|
+ oneStudent.headImg = 'https://img.zcool.cn/community/01786557e4a6fa0000018c1bf080ca.png@1280w_1l_2o_100sh.png'
|
|
|
|
+ }
|
|
|
|
+ this.students.push(oneStudent)
|
|
|
|
+ console.log(this.students,'学生情况')
|
|
|
|
+ this.$store.state.students = this.students
|
|
|
|
+ }
|
|
|
|
+ if (messages.action !== "State.Get") {
|
|
|
|
+ this.$api.tomessage(channelapi,
|
|
|
|
+ {
|
|
|
|
+ "connectionId": connectionId,
|
|
|
|
+ "sender": sender,
|
|
|
|
+ "isPrivate": true,
|
|
|
|
+ "groupname": null,
|
|
|
|
+ "to": receive,
|
|
|
|
+ "text": JSON.stringify(messageText),
|
|
|
|
+ }
|
|
|
|
+ ).then(res => {
|
|
|
|
+ console.log(res, '消息发送成功')
|
|
|
|
+ }).catch(res => {
|
|
|
|
+ console.log(res, '消息发送失败')
|
|
|
|
+ })
|
|
|
|
+ }
|
|
},
|
|
},
|
|
/*白板缩放后 重新获取新的坐标未知*/
|
|
/*白板缩放后 重新获取新的坐标未知*/
|
|
getRelativePointerPosition(node) {
|
|
getRelativePointerPosition(node) {
|
|
@@ -3057,7 +3228,7 @@
|
|
},
|
|
},
|
|
watchtatalpage() {
|
|
watchtatalpage() {
|
|
return this.$store.state.totalpage
|
|
return this.$store.state.totalpage
|
|
- }
|
|
|
|
|
|
+ },
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
watchUrl(e) {
|
|
watchUrl(e) {
|
|
@@ -3122,7 +3293,7 @@
|
|
},
|
|
},
|
|
watchtatalpage(e) {
|
|
watchtatalpage(e) {
|
|
console.log(e,'监听到总页数变化')
|
|
console.log(e,'监听到总页数变化')
|
|
- }
|
|
|
|
|
|
+ },
|
|
///*监听页数变化*/
|
|
///*监听页数变化*/
|
|
//watchloadingpage(e) {
|
|
//watchloadingpage(e) {
|
|
// this.PdfshowLoading()
|
|
// this.PdfshowLoading()
|