|
@@ -56,10 +56,17 @@
|
|
|
</view> -->
|
|
|
</view>
|
|
|
|
|
|
- <view class="ans" id="ansRef">
|
|
|
+ <view class="ans" id="ansRef" :style="{zIndex: viewZindex.quesView}">
|
|
|
<image :src="props.board.ansUrl" alt="" />
|
|
|
</view>
|
|
|
|
|
|
+ <canvas
|
|
|
+ type="2d"
|
|
|
+ canvas-id="magnifier-canvas"
|
|
|
+ id="magnifier-canvas"
|
|
|
+ :style="{width: '300px', height: '386px', zIndex: viewZindex.magnifierView}"
|
|
|
+ ></canvas>
|
|
|
+
|
|
|
<movable-area
|
|
|
v-if="props.cardType !== undefined"
|
|
|
class="movable-area"
|
|
@@ -105,26 +112,35 @@
|
|
|
/>
|
|
|
</movable-view>
|
|
|
</movable-area>
|
|
|
-
|
|
|
</view>
|
|
|
-
|
|
|
</view>
|
|
|
|
|
|
-
|
|
|
- <!-- <audio :src="audioSrc" autoplay ></audio> -->
|
|
|
+ <!-- 实现放大镜功能 -->
|
|
|
+ <!-- <view class="magnifier" >
|
|
|
+ <view class="magnifier-navbar" :style="{width: '100vw', height: navbarInfo.height}" ></view>
|
|
|
+ <view class="magnifier-card" >
|
|
|
+ <canvas
|
|
|
+ type="2d"
|
|
|
+ canvas-id="magnifier-canvas"
|
|
|
+ id="magnifier-canvas"
|
|
|
+ style="width: 300px;height:386px"
|
|
|
+ ></canvas>
|
|
|
+ </view>
|
|
|
+ </view> -->
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
<script setup lang="ts" name="luojigou-board" >
|
|
|
import { defineProps, reactive, ref, computed, getCurrentInstance, defineEmits, watch } from 'vue'
|
|
|
-import { useStaticImg, useSchedulerOnce, useQueryElInfo, useAdaptationIpadAndPhone } from '@/hooks/index'
|
|
|
+import { useStaticImg, useNavbarInfo, useSchedulerOnce, useQueryElInfo, useAdaptationIpadAndPhone, useMagnifier } from '@/hooks/index'
|
|
|
import type { CardModeEnum } from '@/enum/constant';
|
|
|
import { useCalcQuantityStore } from '@/store/index';
|
|
|
import { AudioController } from '@/controller/AudioController';
|
|
|
import Hammer from 'hammerjs'
|
|
|
import { onMounted } from 'vue';
|
|
|
|
|
|
+
|
|
|
interface Buttons {
|
|
|
id: number,
|
|
|
x: number,
|
|
@@ -147,7 +163,8 @@ interface IProps {
|
|
|
playLoading: boolean,
|
|
|
getExpose: (records: any) => void
|
|
|
tipsButton: number
|
|
|
- audioSrc: string
|
|
|
+ audioSrc: string,
|
|
|
+ magnifierState: boolean
|
|
|
}
|
|
|
|
|
|
const staticImg = useStaticImg()
|
|
@@ -160,6 +177,8 @@ const props = defineProps<IProps>()
|
|
|
|
|
|
const emits = defineEmits(['playAudio', 'submit'])
|
|
|
|
|
|
+const navbarInfo = useNavbarInfo()
|
|
|
+
|
|
|
const state = reactive({
|
|
|
zIndex: 0, // 暂存zIndex
|
|
|
scale: 1
|
|
@@ -167,7 +186,8 @@ const state = reactive({
|
|
|
|
|
|
const viewZindex = ref({
|
|
|
moveView: 30,
|
|
|
- quesView: 31
|
|
|
+ magnifierView: 31,
|
|
|
+ quesView: 29
|
|
|
})
|
|
|
|
|
|
|
|
@@ -218,14 +238,9 @@ const TPos = (x: number, y: number) => {
|
|
|
|
|
|
}
|
|
|
|
|
|
-const getButtonIndex = (_y: number) => {
|
|
|
- console.log('ansItemHeight.value', ansItemHeight.value);
|
|
|
-
|
|
|
- return Math.floor(_y / ansItemHeight.value)
|
|
|
-}
|
|
|
+const getButtonIndex = (_y: number) => Math.floor(_y / ansItemHeight.value)
|
|
|
|
|
|
const getButtonPosByIndex = (index: number) => {
|
|
|
- console.log('getButtonPosByIndex:', ansRef.value?.width!, quesRef.value?.width! );
|
|
|
|
|
|
const x = ansRef.value?.width! + quesRef.value?.width!
|
|
|
|
|
@@ -256,7 +271,6 @@ buttons.splice(props.cardType == 1 ? buttons.length : buttons.length - 2, butto
|
|
|
|
|
|
// 让按钮回到原位
|
|
|
const disPatchButtonGoInitPos = (index: number) => {
|
|
|
-
|
|
|
useSchedulerOnce(() => {
|
|
|
buttons[index].x = buttons[index].initX + Math.random()
|
|
|
buttons[index].y = buttons[index].initY + Math.random()
|
|
@@ -266,7 +280,8 @@ const disPatchButtonGoInitPos = (index: number) => {
|
|
|
}
|
|
|
|
|
|
const touchStart = (item: Buttons) => {
|
|
|
- viewZindex.value.moveView = viewZindex.value.quesView + 1
|
|
|
+ // viewZindex.value.moveView = viewZindex.value.quesView + 1
|
|
|
+ viewZindex.value.moveView = viewZindex.value.magnifierView + 1
|
|
|
useSchedulerOnce(() => {
|
|
|
state.zIndex ++
|
|
|
item.zIndex = state.zIndex
|
|
@@ -332,7 +347,10 @@ const touchend = (ev: TouchEvent, item: Buttons) => {
|
|
|
|
|
|
|
|
|
// 每次松手后把题卡的zIndex提高1
|
|
|
- viewZindex.value.quesView = viewZindex.value.moveView + 1
|
|
|
+ // viewZindex.value.quesView = viewZindex.value.moveView + 1
|
|
|
+
|
|
|
+ // 每次松手后把放大镜的zIndex提高1
|
|
|
+ viewZindex.value.magnifierView = viewZindex.value.moveView + 1
|
|
|
|
|
|
}
|
|
|
|
|
@@ -384,7 +402,11 @@ const checkAns = (index: number, itemData: Buttons) => {
|
|
|
|
|
|
|
|
|
|
|
|
-// 让题卡图片支持双指捏合
|
|
|
+/**
|
|
|
+ * @description 放在onMounted生命周期里就可以生效,功能:把题卡放大缩小
|
|
|
+ * @description 需要在touchStart时 设置 viewZindex.value.moveView = viewZindex.value.quesView + 1
|
|
|
+ * @description 需要在touchend时 设置 viewZindex.value.quesView = viewZindex.value.moveView + 1
|
|
|
+ */
|
|
|
const createHammer = () => {
|
|
|
var square = document.querySelector('#ques-url');
|
|
|
var hammer = new Hammer(square);
|
|
@@ -460,8 +482,43 @@ const createHammer = () => {
|
|
|
|
|
|
}
|
|
|
|
|
|
+let a = () => {}
|
|
|
+let b = () => {}
|
|
|
+
|
|
|
+/**
|
|
|
+ * @description 放大镜功能
|
|
|
+ */
|
|
|
+
|
|
|
+
|
|
|
+// 动态设置canvas的宽高
|
|
|
+
|
|
|
+watch(
|
|
|
+ () => props.magnifierState,
|
|
|
+ () => {
|
|
|
+ if (props.magnifierState) {
|
|
|
+ a()
|
|
|
+ } else {
|
|
|
+ b()
|
|
|
+ }
|
|
|
+ console.log(props.magnifierState);
|
|
|
+
|
|
|
+ }
|
|
|
+)
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
- createHammer()
|
|
|
+ useMagnifier(
|
|
|
+ document.getElementById('magnifier-canvas') as HTMLCanvasElement,
|
|
|
+ 'magnifier-canvas',
|
|
|
+ {
|
|
|
+ ansUrl: props.board.ansUrl,
|
|
|
+ quesUrl: props.board.quesUrl,
|
|
|
+ instance: getCurrentInstance()!
|
|
|
+ }
|
|
|
+).then(r => {
|
|
|
+ console.log(r.draw);
|
|
|
+ a = r.draw
|
|
|
+ b = r.clear
|
|
|
+})
|
|
|
})
|
|
|
|
|
|
</script>
|
|
@@ -580,6 +637,16 @@ onMounted(() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ #magnifier-canvas {
|
|
|
+ position: absolute;
|
|
|
+ top: 206rpx;
|
|
|
+ left: 26rpx;
|
|
|
+ z-index: 30;
|
|
|
+ /deep/ .uni-canvas-canvas {
|
|
|
+ border-radius: 40rpx;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
.ans .ans-item:last-child {
|
|
|
border-bottom: none
|
|
|
}
|
|
@@ -695,4 +762,28 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
|
}
|
|
|
|
|
|
+// .magnifier {
|
|
|
+// width: 100vw;
|
|
|
+// height: 100vh;
|
|
|
+// background-color: rgba(0, 0, 0, 0.3);
|
|
|
+// position: fixed;
|
|
|
+// top: 0;
|
|
|
+// left: 0;
|
|
|
+// z-index: 1000;
|
|
|
+// display: flex;
|
|
|
+// flex-direction: column;
|
|
|
+// align-items: center;
|
|
|
+// .magnifier-navbar {
|
|
|
+// width: 100%;
|
|
|
+// position: relative;
|
|
|
+// }
|
|
|
+// .magnifier-card {
|
|
|
+// width: 714rpx;
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</style>
|