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

学生

parent fd305480
......@@ -23,7 +23,6 @@ export default {
// 检测类型 + 其他验证
eventId: {
type: String,
default: 0,
required: true
}
},
......@@ -57,6 +56,9 @@ export default {
this.stage = 'submitted'
console.log('回执', data);
});
},
onMsg(){
},
startCountdown() {
if (this.intervalId) {
......@@ -79,12 +81,12 @@ export default {
this.counttimes--;
},
},
beforeDestroy() {
socket.onMsg(this.onMsg);
},
mounted() {
this.startCountdown();
socket.onMsg(this.onMsg);
// this.$emit('register', );
}
};
......
<template>
<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">
<span>请选择</span>
<el-button @click="handleSubmit">确定</el-button>
</div>
<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-group>
</div>
</el-card>
<el-card class="result-card" v-show="this.stage === 'submitted'">
<el-card class="result-card" v-show="step === 'submitted'">
<div slot="header">
<span>你的选择是</span>
</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>
</div>
</template>
......@@ -36,38 +41,20 @@ export default {
// 检测类型 + 其他验证
eventId: {
type: String,
default: 0,
required: true
}
},
data() {
return {
stage: 'unsubmit',
step: 'unsubmit',//unsubmit submitted stopped
answer: '',
Options,
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: {
handleSubmit() {
console.log('===handleSelect===');
console.log('===handleSubmit===');
console.log(`answer: ${this.answer}`)
this.submitting = true
socket.sendGroupMsg({
......@@ -80,16 +67,30 @@ export default {
}
},
(data) => {
this.stage = 'submitted'
this.step = 'submitted'
this.submitting = false
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() {
socket.offMsg(this.onMsg);
},
mounted() {
socket.onMsg(this.onMsg);
}
};
</script>
......
......@@ -26,7 +26,7 @@ export default {
},
data() {
return {
currentComponment: 'locker',
currentComponment: 'select-question',
eventId: 0
};
},
......@@ -55,24 +55,35 @@ export default {
);
},
onMsg(msg) {
console.log('msg', msg);
if (!msg || !msg.from || !msg.from.indexOf('teacher') || !msg.payload) {
console.log('home onmsg: ', msg);
if (!msg || !msg.from || msg.from.indexOf('teacher') < 0 || !msg.payload) {
return
}
if (!msg.payload.eventId || msg.payload.type < 0 || !msg.payload.questionType) {
if (!msg.payload.eventId || !msg.payload.type || msg.payload.type < 0) {
return
}
this.eventId = msg.payload.eventId;
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 {
if(msg.type === 'finish'){
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() {
......
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