Commit 0f8703bb authored by 甘瑞文's avatar 甘瑞文

学生

parent fd305480
...@@ -23,7 +23,6 @@ export default { ...@@ -23,7 +23,6 @@ export default {
// 检测类型 + 其他验证 // 检测类型 + 其他验证
eventId: { eventId: {
type: String, type: String,
default: 0,
required: true required: true
} }
}, },
...@@ -57,6 +56,9 @@ export default { ...@@ -57,6 +56,9 @@ export default {
this.stage = 'submitted' this.stage = 'submitted'
console.log('回执', data); console.log('回执', data);
}); });
},
onMsg(){
}, },
startCountdown() { startCountdown() {
if (this.intervalId) { if (this.intervalId) {
...@@ -79,12 +81,12 @@ export default { ...@@ -79,12 +81,12 @@ export default {
this.counttimes--; this.counttimes--;
}, },
}, },
beforeDestroy() { beforeDestroy() {
socket.onMsg(this.onMsg);
}, },
mounted() { mounted() {
this.startCountdown(); this.startCountdown();
socket.onMsg(this.onMsg);
// this.$emit('register', ); // this.$emit('register', );
} }
}; };
......
<template> <template>
<div class="gk-screen-std"> <div class="gk-screen-std">
<el-card class="select-card" v-show="this.stage === 'unsubmit'" v-loading="this.submitting"> <el-card class="select-card" v-show="step === 'unsubmit'" v-loading="submitting">
<div slot="header" class="clearfix select-card-header"> <div slot="header" class="clearfix select-card-header">
<span>请选择</span> <span>请选择</span>
<el-button @click="handleSubmit">确定</el-button>
</div> </div>
<div class="ans-wrap"> <div class="ans-wrap">
<el-radio-group v-model="answer"> <el-radio-group v-model="answer" @change="handleSubmit" >
<el-radio :label="itm.value" :key="itm.value" v-for="itm in Options">{{ itm.title }}</el-radio> <el-radio :label="itm.value" :key="itm.value" v-for="itm in Options">{{ itm.title }}</el-radio>
</el-radio-group> </el-radio-group>
</div> </div>
</el-card> </el-card>
<el-card class="result-card" v-show="this.stage === 'submitted'"> <el-card class="result-card" v-show="step === 'submitted'">
<div slot="header"> <div slot="header">
<span>你的选择是</span> <span>你的选择是</span>
</div> </div>
<h2 >{{this.answer}}</h2> <h2 >{{answer}}</h2>
</el-card>
<el-card class="result-card" v-show="step === 'stopped'">
<div slot="header">
<span>已经结束</span>
</div>
<h2 >{{!!answer ? '未作答' : '你的选择是 ' + answer + ' '}}</h2>
</el-card> </el-card>
</div> </div>
</template> </template>
...@@ -36,38 +41,20 @@ export default { ...@@ -36,38 +41,20 @@ export default {
// 检测类型 + 其他验证 // 检测类型 + 其他验证
eventId: { eventId: {
type: String, type: String,
default: 0,
required: true required: true
} }
}, },
data() { data() {
return { return {
stage: 'unsubmit', step: 'unsubmit',//unsubmit submitted stopped
answer: '', answer: '',
Options, Options,
submitting: false, submitting: false,
}; };
}, },
computed: {
// state: function () {
// if(this.finish){
// return 'finish'
// }
// if(this.counttimes > 3){
// return 'ready'
// }
// if(this.counttimes > 0){
// return 'counting'
// }
// return 'active'
// },
countingText() {
return this.counttimes > 4 ? 'Ready' : (this.counttimes > 3 ? 'Go!' : this.counttimes)
}
},
methods: { methods: {
handleSubmit() { handleSubmit() {
console.log('===handleSelect==='); console.log('===handleSubmit===');
console.log(`answer: ${this.answer}`) console.log(`answer: ${this.answer}`)
this.submitting = true this.submitting = true
socket.sendGroupMsg({ socket.sendGroupMsg({
...@@ -80,16 +67,30 @@ export default { ...@@ -80,16 +67,30 @@ export default {
} }
}, },
(data) => { (data) => {
this.stage = 'submitted' this.step = 'submitted'
this.submitting = false this.submitting = false
console.log('回执', data) console.log('回执', data)
}); });
}, },
onMsg(msg) {
console.log('select-question onmsg: ', msg);
if (!msg || !msg.from || msg.from.indexOf('teacher') < 0 || !msg.payload) {
return
}
if (!msg.payload.eventId || !msg.payload.type || msg.payload.type < 0) {
return
}
if(msg.type === 'question-stop' && msg.payload.eventId === this.eventId){
this.step = 'stopped'
return
}
}
}, },
beforeDestroy() { beforeDestroy() {
socket.offMsg(this.onMsg);
}, },
mounted() { mounted() {
socket.onMsg(this.onMsg);
} }
}; };
</script> </script>
......
...@@ -26,7 +26,7 @@ export default { ...@@ -26,7 +26,7 @@ export default {
}, },
data() { data() {
return { return {
currentComponment: 'locker', currentComponment: 'select-question',
eventId: 0 eventId: 0
}; };
}, },
...@@ -55,24 +55,35 @@ export default { ...@@ -55,24 +55,35 @@ export default {
); );
}, },
onMsg(msg) { onMsg(msg) {
console.log('msg', msg); console.log('home onmsg: ', msg);
if (!msg || !msg.from || !msg.from.indexOf('teacher') || !msg.payload) { if (!msg || !msg.from || msg.from.indexOf('teacher') < 0 || !msg.payload) {
return return
} }
if (!msg.payload.eventId || msg.payload.type < 0 || !msg.payload.questionType) { if (!msg.payload.eventId || !msg.payload.type || msg.payload.type < 0) {
return return
} }
this.eventId = msg.payload.eventId; if(msg.type === 'finish'){
const {questionType} = msg.payload;
if (questionType === 3) {
this.currentComponment = 'select-question'
} else if (questionType === 1) {
this.currentComponment = 'drawing-board'
} else if (questionType === 2) {
this.currentComponment = 'quick-response'
} else {
this.currentComponment = 'locker' this.currentComponment = 'locker'
return
} }
if(msg.type !== 'question'){
return
}
this.eventId = msg.payload.eventId;
this.currentComponment = 'locker';
this.$nextTick( () => {
const {type} = msg.payload;
if (type === 3) {
this.currentComponment = 'select-question'
} else if (type === 1) {
this.currentComponment = 'drawing-board'
} else if (type === 2) {
this.currentComponment = 'quick-response'
} else {
this.currentComponment = 'locker'
}
console.log(type, this.currentComponment)
})
} }
}, },
beforeDestroy() { beforeDestroy() {
......
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