|
@@ -1,8 +1,8 @@
|
|
<template>
|
|
<template>
|
|
- <view class="luojigou-board" >
|
|
|
|
- <view class="board" :style="{scale: adaptatio, transformOrigin: '50% 0%'}" >
|
|
|
|
- <image class="board-img" :src="boardUrl" />
|
|
|
|
- <view class="board-header" :style="{zIndex: viewZindex.headerView}" id="game-label" >
|
|
|
|
|
|
+<view class="luojigou-board" >
|
|
|
|
+ <view class="board" :style="{ transform: `scale(${adaptatio})` ,transformOrigin: '50% 0%'}" >
|
|
|
|
+ <image class="board-img" :src="boardUrl" />
|
|
|
|
+ <view class="board-header" :style="{zIndex: viewZindex.headerView}" id="game-label" >
|
|
<view class="trumpt" @click="emits('playAudio')">
|
|
<view class="trumpt" @click="emits('playAudio')">
|
|
<!-- <image class="dog" :src="staticImg.trumptDog" /> -->
|
|
<!-- <image class="dog" :src="staticImg.trumptDog" /> -->
|
|
<image
|
|
<image
|
|
@@ -23,29 +23,29 @@
|
|
class="luojigou-dog"
|
|
class="luojigou-dog"
|
|
:src="staticImg.luojigouDog"
|
|
:src="staticImg.luojigouDog"
|
|
/>
|
|
/>
|
|
- </view>
|
|
|
|
- <view class="card" :style="{zIndex: viewZindex.quesView}" >
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <view class="card" :style="{zIndex: viewZindex.quesView}" >
|
|
<view class="ques" id="quesRef" >
|
|
<view class="ques" id="quesRef" >
|
|
<image id="ques-url" :src="props.board.quesUrl" alt="" />
|
|
<image id="ques-url" :src="props.board.quesUrl" alt="" />
|
|
</view>
|
|
</view>
|
|
- </view>
|
|
|
|
- <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: '600rpx', height: '772rpx', zIndex: viewZindex.magnifierView}"
|
|
|
|
- ></canvas>
|
|
|
|
- <movable-area
|
|
|
|
|
|
+ </view>
|
|
|
|
+ <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: 600 + 'rpx', height: 772 + 'rpx', zIndex: viewZindex.magnifierView}"
|
|
|
|
+ ></canvas>
|
|
|
|
+ <movable-area
|
|
v-if="props.cardType !== undefined"
|
|
v-if="props.cardType !== undefined"
|
|
class="movable-area"
|
|
class="movable-area"
|
|
id="movableAreaRef"
|
|
id="movableAreaRef"
|
|
:style="{
|
|
:style="{
|
|
width: 357 * rate+ 'rpx',
|
|
width: 357 * rate+ 'rpx',
|
|
height: 466 * rate + 'rpx',
|
|
height: 466 * rate + 'rpx',
|
|
- top: 102 * rate / adaptatio + 'rpx',
|
|
|
|
|
|
+ top: 102 * rate / adaptatio + 'rpx',
|
|
left: 50 + '%',
|
|
left: 50 + '%',
|
|
transform: `translateX(-${50}%)`,
|
|
transform: `translateX(-${50}%)`,
|
|
zIndex: viewZindex.moveView,
|
|
zIndex: viewZindex.moveView,
|
|
@@ -82,22 +82,15 @@
|
|
:src="staticImg.successFlag"
|
|
:src="staticImg.successFlag"
|
|
/>
|
|
/>
|
|
</movable-view>
|
|
</movable-view>
|
|
- </movable-area>
|
|
|
|
- <!-- 新手引导 -->
|
|
|
|
- <view class="intro" v-if="viewZindex.introView > 0" :style="{zIndex: viewZindex.introView}" @click="nextIntro" >
|
|
|
|
- <view class="lingheight" >
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ </movable-area>
|
|
</view>
|
|
</view>
|
|
|
|
+</view>
|
|
|
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts" name="luojigou-board" >
|
|
<script setup lang="ts" name="luojigou-board" >
|
|
import { defineProps, reactive, ref, computed, getCurrentInstance, defineEmits, watch } from 'vue'
|
|
import { defineProps, reactive, ref, computed, getCurrentInstance, defineEmits, watch } from 'vue'
|
|
-import { useStaticImg, useNavbarInfo, useSchedulerOnce, useQueryElInfo, useAdaptationIpadAndPhone, useMagnifier } from '@/hooks/index'
|
|
|
|
|
|
+import { useStaticImg, useNavbarInfo, useSchedulerOnce, useQueryElInfo, useAdaptationIpadAndPhone, useMagnifier, } from '@/hooks/index'
|
|
import type { CardModeEnum } from '@/enum/constant';
|
|
import type { CardModeEnum } from '@/enum/constant';
|
|
import { useCalcQuantityStore } from '@/store/index';
|
|
import { useCalcQuantityStore } from '@/store/index';
|
|
import { AudioController } from '@/controller/AudioController';
|
|
import { AudioController } from '@/controller/AudioController';
|
|
@@ -149,7 +142,7 @@ const state = reactive({
|
|
})
|
|
})
|
|
|
|
|
|
const viewZindex = ref({
|
|
const viewZindex = ref({
|
|
- moveView: 30, // 拖拽层
|
|
|
|
|
|
+ moveView: 32, // 拖拽层
|
|
magnifierView: 31, // 放大镜
|
|
magnifierView: 31, // 放大镜
|
|
quesView: 29, // 题卡
|
|
quesView: 29, // 题卡
|
|
headerView: 33,
|
|
headerView: 33,
|
|
@@ -175,6 +168,7 @@ const colorMap = new Map([
|
|
])
|
|
])
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
const boardUrl = props.cardType == 1 ? staticImg.boardSix : staticImg.boardFour
|
|
const boardUrl = props.cardType == 1 ? staticImg.boardSix : staticImg.boardFour
|
|
|
|
|
|
const ansRef = ref<UniApp.NodeInfo>()
|
|
const ansRef = ref<UniApp.NodeInfo>()
|
|
@@ -185,8 +179,6 @@ useQueryElInfo('#quesRef', (nodeInfo) => quesRef.value = nodeInfo as UniApp.Node
|
|
useQueryElInfo('#ansRef', (nodeInfo) => ansRef.value = nodeInfo as UniApp.NodeInfo, getCurrentInstance()!)
|
|
useQueryElInfo('#ansRef', (nodeInfo) => ansRef.value = nodeInfo as UniApp.NodeInfo, getCurrentInstance()!)
|
|
useQueryElInfo('#movableAreaRef', (nodeInfo) => movableAreaRef.value = nodeInfo as UniApp.NodeInfo, getCurrentInstance()!)
|
|
useQueryElInfo('#movableAreaRef', (nodeInfo) => movableAreaRef.value = nodeInfo as UniApp.NodeInfo, getCurrentInstance()!)
|
|
|
|
|
|
-console.log('adaptatio:', adaptatio);
|
|
|
|
-
|
|
|
|
const baseRatio = adaptatio
|
|
const baseRatio = adaptatio
|
|
|
|
|
|
const rate = baseRatio * 2
|
|
const rate = baseRatio * 2
|
|
@@ -262,8 +254,6 @@ const touchend = (ev: TouchEvent, item: Buttons) => {
|
|
if (item.disabled) return
|
|
if (item.disabled) return
|
|
|
|
|
|
const { x: itemX, y: itemY } = TPos(ev.changedTouches[0].pageX, ev.changedTouches[0].pageY)
|
|
const { x: itemX, y: itemY } = TPos(ev.changedTouches[0].pageX, ev.changedTouches[0].pageY)
|
|
-
|
|
|
|
- console.log("itemY:", itemY);
|
|
|
|
|
|
|
|
// 返回原点 (没有放在答案区, 按钮回到初始位置)
|
|
// 返回原点 (没有放在答案区, 按钮回到初始位置)
|
|
if (itemX < quesRef.value?.width! || itemY > ansRef.value?.height! ) {
|
|
if (itemX < quesRef.value?.width! || itemY > ansRef.value?.height! ) {
|
|
@@ -271,10 +261,8 @@ const touchend = (ev: TouchEvent, item: Buttons) => {
|
|
} else {
|
|
} else {
|
|
|
|
|
|
const index = getButtonIndex(itemY <= 0 ? 0 : itemY)
|
|
const index = getButtonIndex(itemY <= 0 ? 0 : itemY)
|
|
- console.log('index:', index);
|
|
|
|
|
|
|
|
const { x: targetX, y: targetY } = getButtonPosByIndex(index)
|
|
const { x: targetX, y: targetY } = getButtonPosByIndex(index)
|
|
- console.log(item.x , targetX , item.y, targetY);
|
|
|
|
|
|
|
|
// 直接点击答案区的按钮,答案区按钮回到初始位置
|
|
// 直接点击答案区的按钮,答案区按钮回到初始位置
|
|
if (item.x == targetX && item.y == targetY) {
|
|
if (item.x == targetX && item.y == targetY) {
|
|
@@ -325,7 +313,6 @@ const touchend = (ev: TouchEvent, item: Buttons) => {
|
|
// 判断答案 (学习计划适用逻辑)
|
|
// 判断答案 (学习计划适用逻辑)
|
|
const checkAns = (index: number, itemData: Buttons) => {
|
|
const checkAns = (index: number, itemData: Buttons) => {
|
|
const targetData = props.board.ansList
|
|
const targetData = props.board.ansList
|
|
- console.log(targetData, index, itemData);
|
|
|
|
|
|
|
|
// 移动到了正确位置
|
|
// 移动到了正确位置
|
|
if (targetData[index].ans === itemData.color) {
|
|
if (targetData[index].ans === itemData.color) {
|
|
@@ -368,21 +355,6 @@ const checkAns = (index: number, itemData: Buttons) => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-const nextIntro = () => {
|
|
|
|
-
|
|
|
|
- viewZindex.value.introView = viewZindex.value.headerView + 1
|
|
|
|
-
|
|
|
|
- viewZindex.value.quesView = viewZindex.value.introView + 1
|
|
|
|
-
|
|
|
|
- viewZindex.value.magnifierView = viewZindex.value.quesView + 1
|
|
|
|
-
|
|
|
|
- createMagnifier()
|
|
|
|
- nextTick(() => {
|
|
|
|
- a()
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* @description 放在onMounted生命周期里就可以生效,功能:把题卡放大缩小
|
|
* @description 放在onMounted生命周期里就可以生效,功能:把题卡放大缩小
|
|
* @description 需要在touchStart时 设置 viewZindex.value.moveView = viewZindex.value.quesView + 1
|
|
* @description 需要在touchStart时 设置 viewZindex.value.moveView = viewZindex.value.quesView + 1
|
|
@@ -404,7 +376,6 @@ const createHammer = () => {
|
|
}
|
|
}
|
|
|
|
|
|
hammerState.scaleCount = hammerState.scaleIndex * e.scale;
|
|
hammerState.scaleCount = hammerState.scaleIndex * e.scale;
|
|
- console.log(hammerState.scaleCount);
|
|
|
|
|
|
|
|
document.getElementById('quesRef')!.style.transform = `scale(${hammerState.scaleIndex * e.scale})`
|
|
document.getElementById('quesRef')!.style.transform = `scale(${hammerState.scaleIndex * e.scale})`
|
|
})
|
|
})
|
|
@@ -423,7 +394,6 @@ const createHammer = () => {
|
|
hammer.on('panend', (e) => {
|
|
hammer.on('panend', (e) => {
|
|
hammerState.x = e.deltaX + hammerState.x; // 记录水平方向上的偏移量
|
|
hammerState.x = e.deltaX + hammerState.x; // 记录水平方向上的偏移量
|
|
hammerState.y = e.deltaY + hammerState.y; // 记录垂直方向上的偏移量
|
|
hammerState.y = e.deltaY + hammerState.y; // 记录垂直方向上的偏移量
|
|
- console.log(hammerState.x);
|
|
|
|
|
|
|
|
const node = document.getElementById('quesRef')
|
|
const node = document.getElementById('quesRef')
|
|
|
|
|
|
@@ -463,20 +433,21 @@ const createHammer = () => {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-let a = () => {}
|
|
|
|
-let b = () => {}
|
|
|
|
|
|
+let draw = () => {}
|
|
|
|
+let clear = () => {}
|
|
|
|
|
|
// 动态设置canvas的宽高
|
|
// 动态设置canvas的宽高
|
|
|
|
|
|
-watch(
|
|
|
|
|
|
+watch(
|
|
() => props.magnifierState,
|
|
() => props.magnifierState,
|
|
() => {
|
|
() => {
|
|
if (props.magnifierState) {
|
|
if (props.magnifierState) {
|
|
- a()
|
|
|
|
|
|
+ draw()
|
|
|
|
+ viewZindex.value.magnifierView = viewZindex.value.moveView + 1
|
|
} else {
|
|
} else {
|
|
- b()
|
|
|
|
|
|
+ clear()
|
|
|
|
+ viewZindex.value.moveView = viewZindex.value.magnifierView + 1
|
|
}
|
|
}
|
|
- console.log(props.magnifierState);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
)
|
|
)
|
|
@@ -496,15 +467,15 @@ const createMagnifier = () => {
|
|
rate: rate
|
|
rate: rate
|
|
}
|
|
}
|
|
).then(r => {
|
|
).then(r => {
|
|
- a = r.draw
|
|
|
|
- b = r.clear
|
|
|
|
|
|
+ draw = r.draw
|
|
|
|
+ clear = r.clear
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
- createMagnifier()
|
|
|
|
|
|
+ useSchedulerOnce(() => {
|
|
|
|
+ createMagnifier()
|
|
|
|
+ }, 1000)
|
|
})
|
|
})
|
|
|
|
|
|
</script>
|
|
</script>
|
|
@@ -622,7 +593,6 @@ onMounted(() => {
|
|
object-fit: cover;
|
|
object-fit: cover;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
#magnifier-canvas {
|
|
#magnifier-canvas {
|
|
position: absolute;
|
|
position: absolute;
|
|
top: 206rpx;
|
|
top: 206rpx;
|
|
@@ -632,7 +602,6 @@ onMounted(() => {
|
|
border-radius: 40rpx;
|
|
border-radius: 40rpx;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
.ans .ans-item:last-child {
|
|
.ans .ans-item:last-child {
|
|
border-bottom: none
|
|
border-bottom: none
|
|
}
|
|
}
|
|
@@ -688,7 +657,7 @@ onMounted(() => {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
.mark-button {
|
|
.mark-button {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|