|
@@ -1,67 +1,70 @@
|
|
|
<template>
|
|
|
<div class="tool-list">
|
|
|
- <ul
|
|
|
- ref="toolListEl"
|
|
|
- @scroll="onToolListElScroll"
|
|
|
- @touchmove.prevent
|
|
|
- >
|
|
|
- <li
|
|
|
- v-for="toolItem in toolList"
|
|
|
- :key="toolItem.name"
|
|
|
+ <h3>请在下方选择正确的工具({{ selectedToolNum }}/{{ requiredToolList.length }})</h3>
|
|
|
+ <div class="wrapper">
|
|
|
+ <ul
|
|
|
+ ref="toolListEl"
|
|
|
+ @scroll="onToolListElScroll"
|
|
|
>
|
|
|
- <div
|
|
|
- class="tool-frame"
|
|
|
- :class="{
|
|
|
- active: toolItem.selected,
|
|
|
- }"
|
|
|
+ <!-- @touchmove.prevent -->
|
|
|
+ <li
|
|
|
+ v-for="(toolItem, idx) in toolList"
|
|
|
+ :key="toolItem.name"
|
|
|
+ @click="onClickToolItem(idx)"
|
|
|
>
|
|
|
- <img
|
|
|
- class=""
|
|
|
+ <div
|
|
|
+ class="tool-frame"
|
|
|
:class="{
|
|
|
active: toolItem.selected,
|
|
|
}"
|
|
|
- :src="toolItem.url"
|
|
|
- alt=""
|
|
|
- draggable="false"
|
|
|
>
|
|
|
- </div>
|
|
|
- <span
|
|
|
- class="tool-name"
|
|
|
- :class="{
|
|
|
- active: toolItem.selected,
|
|
|
- }"
|
|
|
- >{{ toolItem.name }}</span>
|
|
|
- </li>
|
|
|
- </ul>
|
|
|
- <button
|
|
|
- v-show="isShowLeftArrow"
|
|
|
- class="arrow-left"
|
|
|
- @click="onClickLeftArrow"
|
|
|
- >
|
|
|
- <img
|
|
|
- class=""
|
|
|
- src="@/assets/images/arrow-left.png"
|
|
|
- alt=""
|
|
|
- draggable="false"
|
|
|
+ <img
|
|
|
+ class=""
|
|
|
+ :class="{active: toolItem.selected,
|
|
|
+ }"
|
|
|
+ :src="toolItem.url"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <span
|
|
|
+ class="tool-name"
|
|
|
+ :class="{
|
|
|
+ active: toolItem.selected,
|
|
|
+ }"
|
|
|
+ >{{ toolItem.name }}</span>
|
|
|
+ </li>
|
|
|
+ </ul>
|
|
|
+ <button
|
|
|
+ v-show="isShowLeftArrow"
|
|
|
+ class="arrow-left"
|
|
|
+ @click="onClickLeftArrow"
|
|
|
>
|
|
|
- </button>
|
|
|
- <button
|
|
|
- v-show="isShowRightArrow"
|
|
|
- class="arrow-right"
|
|
|
- @click="onClickRightArrow"
|
|
|
- >
|
|
|
- <img
|
|
|
- class=""
|
|
|
- src="@/assets/images/arrow-right.png"
|
|
|
- alt=""
|
|
|
- draggable="false"
|
|
|
+ <img
|
|
|
+ class=""
|
|
|
+ src="@/assets/images/arrow-left.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ </button>
|
|
|
+ <button
|
|
|
+ v-show="isShowRightArrow"
|
|
|
+ class="arrow-right"
|
|
|
+ @click="onClickRightArrow"
|
|
|
>
|
|
|
- </button>
|
|
|
+ <img
|
|
|
+ class=""
|
|
|
+ src="@/assets/images/arrow-right.png"
|
|
|
+ alt=""
|
|
|
+ draggable="false"
|
|
|
+ >
|
|
|
+ </button>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ref, watch } from "vue"
|
|
|
+import { ref, watch, computed } from "vue"
|
|
|
import penUrl from '@/assets/images/pen.png'
|
|
|
import knifeUrl from '@/assets/images/knife.png'
|
|
|
import paintUrl from '@/assets/images/paint.png'
|
|
@@ -71,6 +74,14 @@ import copyingPaperUrl from '@/assets/images/copying-paper.png'
|
|
|
import rubberBoardUrl from '@/assets/images/rubber-board.png'
|
|
|
import engravingPaperUrl from '@/assets/images/engraving-paper.png'
|
|
|
|
|
|
+const props = defineProps(['requiredToolList'])
|
|
|
+const emit = defineEmits(['all-selected'])
|
|
|
+
|
|
|
+const requiredToolList = computed(() => {
|
|
|
+ return props.requiredToolList
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
const {
|
|
|
windowSizeInCssForRef,
|
|
|
windowSizeWhenDesignForRef,
|
|
@@ -79,7 +90,7 @@ const {
|
|
|
const toolList = ref([
|
|
|
{
|
|
|
name: '笔',
|
|
|
- selected: true,
|
|
|
+ selected: false,
|
|
|
url: penUrl,
|
|
|
},
|
|
|
{
|
|
@@ -119,6 +130,24 @@ const toolList = ref([
|
|
|
},
|
|
|
])
|
|
|
|
|
|
+const selectedToolNum = computed(() => {
|
|
|
+ return toolList.value.filter((item) => {
|
|
|
+ return item.selected
|
|
|
+ }).length
|
|
|
+})
|
|
|
+
|
|
|
+watch(selectedToolNum, (vNew) => {
|
|
|
+ if (vNew === requiredToolList.value.length) {
|
|
|
+ emit('all-selected')
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+watch(requiredToolList, () => {
|
|
|
+ toolList.value.forEach((item) => {
|
|
|
+ item.selected = false
|
|
|
+ })
|
|
|
+})
|
|
|
+
|
|
|
const toolListEl = ref(null)
|
|
|
const isShowLeftArrow = ref(false)
|
|
|
const isShowRightArrow = ref(true)
|
|
@@ -140,82 +169,107 @@ function onClickLeftArrow() {
|
|
|
function onClickRightArrow() {
|
|
|
toolListEl.value.scrollLeft += toolListEl.value.scrollWidth / 8
|
|
|
}
|
|
|
+
|
|
|
+function onClickToolItem(idx) {
|
|
|
+ if (requiredToolList.value.includes(idx)) {
|
|
|
+ if (toolList.value[idx].selected === false) {
|
|
|
+ toolList.value[idx].selected = true
|
|
|
+ window.alert('选择正确')
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ window.alert('您拿错工具了~请重新选择')
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
.tool-list{
|
|
|
- >ul{
|
|
|
- display: flex;
|
|
|
- overflow: auto;
|
|
|
- &::-webkit-scrollbar { height: 0; };
|
|
|
- >li{
|
|
|
- flex: 0 0 auto;
|
|
|
- display: inline-block;
|
|
|
- text-align: center;
|
|
|
- margin-right: calc(5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- >.tool-frame{
|
|
|
- width: calc(83 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
- height: calc(83 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
- background: rgba(255,255,255,0.3);
|
|
|
- border-radius: 2px 2px 2px 2px;
|
|
|
- border: 1px solid #FFFFFF;
|
|
|
- margin-bottom: calc(3 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- position: relative;
|
|
|
- >img{
|
|
|
- position: absolute;
|
|
|
- left: 0;
|
|
|
- bottom: 0;
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
+ >h3{
|
|
|
+ text-align: center;
|
|
|
+ font-size: calc(14 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ margin-bottom: calc(9 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ >.wrapper{
|
|
|
+ position: relative;
|
|
|
+ >ul{
|
|
|
+ display: flex;
|
|
|
+ overflow: auto;
|
|
|
+ padding-top: calc(19 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ &::-webkit-scrollbar { height: 0; };
|
|
|
+ >li{
|
|
|
+ flex: 0 0 auto;
|
|
|
+ display: inline-block;
|
|
|
+ text-align: center;
|
|
|
+ margin-right: calc(5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
+ >.tool-frame{
|
|
|
+ width: calc(83 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ height: calc(83 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ background: rgba(255,255,255,0.3);
|
|
|
+ border-radius: 2px 2px 2px 2px;
|
|
|
+ border: 1px solid #FFFFFF;
|
|
|
+ margin-bottom: calc(3 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
+ position: relative;
|
|
|
+ >img{
|
|
|
+ position: absolute;
|
|
|
+ left: 0;
|
|
|
+ bottom: 0;
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ >img.active{
|
|
|
+ width: 125%;
|
|
|
+ height: 125%;
|
|
|
+ }
|
|
|
}
|
|
|
- >img.active{
|
|
|
- width: 125%;
|
|
|
- height: 125%;
|
|
|
+ >.tool-frame.active{
|
|
|
+ border: calc(4 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef')) solid #FFE096;
|
|
|
+ }
|
|
|
+ >span{
|
|
|
+ font-size: calc(14 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
+ font-weight: 400;
|
|
|
+ color: #FFFFFF;
|
|
|
+ line-height: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ }
|
|
|
+ >span.active{
|
|
|
+ font-size: calc(14 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ font-family: Source Han Sans CN-Bold, Source Han Sans CN;
|
|
|
+ font-weight: bold;
|
|
|
+ color: #FFE096;
|
|
|
+ line-height: calc(16 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
}
|
|
|
}
|
|
|
- >.tool-frame.active{
|
|
|
- border: 4px solid #FFE096;
|
|
|
- }
|
|
|
- >span{
|
|
|
- font-size: 14px;
|
|
|
- font-family: Source Han Sans CN-Regular, Source Han Sans CN;
|
|
|
- font-weight: 400;
|
|
|
- color: #FFFFFF;
|
|
|
- line-height: 16px;
|
|
|
+ >li:first-of-type{
|
|
|
+ margin-left: calc(12 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
}
|
|
|
- >span.active{
|
|
|
- font-size: 14px;
|
|
|
- font-family: Source Han Sans CN-Bold, Source Han Sans CN;
|
|
|
- font-weight: bold;
|
|
|
- color: #FFE096;
|
|
|
- line-height: 16px;
|
|
|
+ >li:last-of-type{
|
|
|
+ margin-right: calc(12 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
}
|
|
|
}
|
|
|
- >li:first-of-type{
|
|
|
- margin-left: calc(12 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- }
|
|
|
- >li:last-of-type{
|
|
|
- margin-right: calc(12 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- }
|
|
|
- }
|
|
|
- >button.arrow-left{
|
|
|
- position: absolute;
|
|
|
- left: calc(8 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- top: calc(42.5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
- transform: translateY(-50%);
|
|
|
- height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- >img{
|
|
|
- height: 100%;
|
|
|
+ >button.arrow-left{
|
|
|
+ position: absolute;
|
|
|
+ left: calc(8 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
+ >img{
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- >button.arrow-right{
|
|
|
- position: absolute;
|
|
|
- right: calc(8 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
- top: calc(42.5 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
- transform: translateY(-50%);
|
|
|
- height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
- >img{
|
|
|
- height: 100%;
|
|
|
+ >button.arrow-right{
|
|
|
+ position: absolute;
|
|
|
+ right: calc(8 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));
|
|
|
+ top: 50%;
|
|
|
+ transform: translateY(-50%);
|
|
|
+ height: calc(24 / v-bind('windowSizeWhenDesignForRef') * v-bind('windowSizeInCssForRef'));;
|
|
|
+ >img{
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|