Commit 62eb3bf2 authored by 刘阳's avatar 刘阳

fix: 答题添加判断

parent 3b6d5735
<template> <template>
<div ref="gk_screen_std" class="gk-screen-std"> <div ref="gk_screen_std" class="gk-screen-std">
<div v-if="!isChoice" ref="vd"> <div v-if="questionType === 1 || questionType === 2" ref="vd">
<geek-draw-board <geek-draw-board
ref="draw" ref="draw"
:points="paints[currentIndex]" :points="paints[currentIndex]"
...@@ -16,9 +16,14 @@ ...@@ -16,9 +16,14 @@
:key="itm.title" :key="itm.title"
>{{ itm.name }} >{{ itm.name }}
</el-button> </el-button>
<el-button @click="sendAnswer"
type="primary"
class="itm"
:disabled="disabled">提交
</el-button>
</div> </div>
</div> </div>
<div v-else> <div v-if="questionType === 0">
<div class="ans-wrap"> <div class="ans-wrap">
<el-button <el-button
v-for="itm in Answers" v-for="itm in Answers"
...@@ -32,10 +37,14 @@ ...@@ -32,10 +37,14 @@
</el-button> </el-button>
</div> </div>
</div> </div>
<el-button v-if="questionType === 0 "
<el-button type="primary" @click="sendChoose" :disabled="false" class="ans-commit"> type="primary"
@click="sendAnswer"
:disabled="disabled"
class="ans-commit">
提交 提交
</el-button> </el-button>
<div class="none" v-if="questionType === -1" >暂无题目作答,请等候老师发送</div>
</div> </div>
</template> </template>
...@@ -69,8 +78,9 @@ export default { ...@@ -69,8 +78,9 @@ export default {
paints: [], paints: [],
paintType: '', paintType: '',
currentIndex: '', currentIndex: '',
isChoice: true, questionType: -1,
paintTypes paintTypes,
getMsg: {}
}; };
}, },
methods: { methods: {
...@@ -86,13 +96,22 @@ export default { ...@@ -86,13 +96,22 @@ export default {
console.log(value); console.log(value);
this.currentAns = value; this.currentAns = value;
}, },
sendChoose() { sendAnswer() {
console.log('currentPaintData', this.$refs.draw.getImg()); let msg = ''
if (this.questionType === 0) {
msg = this.currentAns
} else if (this.questionType === 1 || this.questionType === 2) {
msg = this.$refs.draw.getImg()
} else {
msg = ''
}
socket.sendGroupMsg( socket.sendGroupMsg(
{ {
type: 'answer', payload: {
message: this.currentAns, type: this.questionType,
questionType: '' answer: msg,
}
}, },
(data) => { (data) => {
console.log('回执', data); console.log('回执', data);
...@@ -102,12 +121,17 @@ export default { ...@@ -102,12 +121,17 @@ export default {
}, },
dealMsg(msg) { dealMsg(msg) {
console.log('msg', msg); console.log('msg', msg);
if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.type === 'question') { this.getMsg = msg
this.disabled = false; // 42["msg",{"from":"teacher-1608135771425","type":"question",
// "payload":{"type":0,"title":"选择题"}}]
if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.payload.type > -1) {
this.questionType = msg.payload.type
} }
console.log('msg', this.questionType);
} }
}, },
beforeDestroy() { beforeDestroy() {
this.getMsg = {}
socket.offMsg(this.dealMsg); socket.offMsg(this.dealMsg);
}, },
mounted() { mounted() {
...@@ -142,7 +166,7 @@ export default { ...@@ -142,7 +166,7 @@ export default {
} }
} }
.draw-board { .draw-board {
height: 80vh; height: 100vh;
width: 100vw; width: 100vw;
background: #f5f5f5; background: #f5f5f5;
} }
...@@ -164,5 +188,9 @@ export default { ...@@ -164,5 +188,9 @@ export default {
font-size: 40px; font-size: 40px;
margin-top: 5vh; margin-top: 5vh;
} }
.none{
font-size: 26px;
margin-top: 40vh;
}
} }
</style> </style>
...@@ -75,9 +75,9 @@ export default { ...@@ -75,9 +75,9 @@ export default {
userId = `${new Date().getTime()}` userId = `${new Date().getTime()}`
} }
const routeName = joinObj.path const routeName = joinObj.path
// socket.connect(userId, () => { socket.connect(userId, () => {
this.$router.push({ name: routeName, query: { userId, roomId: this.roomId }}) this.$router.push({ name: routeName, query: { userId, roomId: this.roomId }})
// }) })
} }
}, },
mounted() { mounted() {
......
...@@ -186,6 +186,7 @@ export default { ...@@ -186,6 +186,7 @@ export default {
this.isJoin = true this.isJoin = true
this.mico = (this.micros[0] || {}).deviceId this.mico = (this.micros[0] || {}).deviceId
this.registerMsgReceived() this.registerMsgReceived()
document.body.addEventListener('touchmove', (e) => { document.body.addEventListener('touchmove', (e) => {
e.preventDefault(); e.preventDefault();
}, { passive: false }); }, { passive: false });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment