Commit 3b6d5735 authored by 刘阳's avatar 刘阳

fix: 禁用滑动

parent d2636bf8
<template> <template>
<div ref="gk_screen_std" class="gk-screen-std"> <div ref="gk_screen_std" class="gk-screen-std">
<div v-if="isChoice"> <div v-if="!isChoice" ref="vd">
<geek-draw-board ref="draw" <geek-draw-board
:points="paints[currentIndex]" :paintType="paintType" class="draw-board" /> ref="draw"
:points="paints[currentIndex]"
:paintType="paintType"
class="draw-board"
/>
<div class="tools-wrap"> <div class="tools-wrap">
<el-button class="itm" type="info" @click="changeTool(itm.title)" <el-button
v-for="itm in paintTypes" :key="itm.title">{{ itm.name }} class="itm"
type="info"
@click="changeTool(itm.title)"
v-for="itm in paintTypes"
:key="itm.title"
>{{ itm.name }}
</el-button> </el-button>
</div> </div>
</div> </div>
<div v-else> <div v-else>
<div class="ans-wrap"> <div class="ans-wrap">
<el-button v-for="itm in Answers" <el-button
v-for="itm in Answers"
:disabled="disabled" :disabled="disabled"
@click="chooseAnswer(itm.value)" @click="chooseAnswer(itm.value)"
:key="itm.value" type="primary" :key="itm.value"
:class="['ans-itm', itm.value === currentAns ? 'ans-itm-select': '' ]"> type="primary"
{{itm.title}} :class="['ans-itm', itm.value === currentAns ? 'ans-itm-select' : '']"
>
{{ itm.title }}
</el-button> </el-button>
</div> </div>
</div> </div>
<el-button type="primary" <el-button type="primary" @click="sendChoose" :disabled="false" class="ans-commit">
@click="sendChoose"
:disabled="false"
class="ans-commit">
提交 提交
</el-button> </el-button>
</div> </div>
</template> </template>
<script> <script>
import { GeekDrawBoard } from '@geek/geekui' import { GeekDrawBoard } from '@geek/geekui';
import socket from '../../utils/socket' import socket from '../../utils/socket';
const Answers = [ const Answers = [
{ title: 'A', value: 'A' }, { title: 'A', value: 'A' },
{ title: 'B', value: 'B' }, { title: 'B', value: 'B' },
{ title: 'C', value: 'C' }, { title: 'C', value: 'C' },
{ title: 'D', value: 'D' } { title: 'D', value: 'D' }
] ];
const paintTypes = [ const paintTypes = [
{ title: 'pencil', name: '铅笔', width: 20 }, { title: 'pencil', name: '铅笔', width: 20 },
{ title: 'redo', name: '撤回' }, { title: 'redo', name: '撤回' },
{ title: 'erase', name: '橡皮擦', width: 50 }, { title: 'erase', name: '橡皮擦', width: 50 },
{ title: 'clear', name: '清空' }, { title: 'clear', name: '清空' }
] ];
export default { export default {
name: 'vd',
components: { components: {
GeekDrawBoard GeekDrawBoard
}, },
...@@ -61,62 +71,53 @@ export default { ...@@ -61,62 +71,53 @@ export default {
currentIndex: '', currentIndex: '',
isChoice: true, isChoice: true,
paintTypes paintTypes
} };
}, },
methods: { methods: {
changeTool(title) { changeTool(title) {
if (title === 'redo' || title === 'clear') { if (title === 'redo' || title === 'clear') {
// eslint-disable-next-line no-unused-expressions // eslint-disable-next-line no-unused-expressions
this.$refs.draw && this.$refs.draw[title](); this.$refs.draw && this.$refs.draw[title]();
return return;
} }
this.paintType = title this.paintType = title;
}, },
chooseAnswer(value) { chooseAnswer(value) {
console.log(value) console.log(value);
this.currentAns = value this.currentAns = value;
}, },
sendChoose() { sendChoose() {
console.log('currentPaintData',this.$refs.draw.getImg()) console.log('currentPaintData', this.$refs.draw.getImg());
socket.sendGroupMsg({ socket.sendGroupMsg(
{
type: 'answer', type: 'answer',
message: this.currentAns, message: this.currentAns,
questionType: '', questionType: ''
},(data) => {
console.log('回执',data);
this.disabled = true
})
}, },
dealMsg(msg) { (data) => {
console.log('msg',msg) console.log('回执', data);
if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.type === 'question') { this.disabled = true;
this.disabled = false
} }
);
}, },
scrollFunc(evt) { dealMsg(msg) {
evt = evt || window.event; console.log('msg', msg);
if (evt.preventDefault) { if (msg && msg.from && msg.from.indexOf('teacher') > -1 && msg.type === 'question') {
// Firefox this.disabled = false;
evt.preventDefault();
evt.stopPropagation();
} else {
// IE
evt.cancelBubble = true;
evt.returnValue = false;
} }
return false;
} }
}, },
beforeDestroy() { beforeDestroy() {
socket.offMsg(this.dealMsg) socket.offMsg(this.dealMsg);
}, },
mounted() { mounted() {
this.paintType = 'pencil' this.paintType = 'pencil';
socket.onMsg(this.dealMsg) socket.onMsg(this.dealMsg);
document.addEventListener('DOMMouseScroll', this.scrollFunc, false); document.body.addEventListener('touchmove', (e) => {
document.addEventListener('mousewheel',this.scrollFunc,false); e.preventDefault();
}, }, { passive: false });
} }
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -140,10 +141,10 @@ export default { ...@@ -140,10 +141,10 @@ export default {
margin-left: 0; margin-left: 0;
} }
} }
.draw-board{ .draw-board {
height: 80vh; height: 80vh;
width: 100vw; width: 100vw;
background:#f5f5f5 background: #f5f5f5;
} }
.ans-wrap { .ans-wrap {
margin-top: 20vh; margin-top: 20vh;
......
...@@ -186,6 +186,9 @@ export default { ...@@ -186,6 +186,9 @@ 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) => {
e.preventDefault();
}, { passive: false });
} }
} }
</script> </script>
......
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