|
@@ -4,7 +4,8 @@
|
|
|
<selectTypesVue activeSelect="2"></selectTypesVue>
|
|
|
<!-- 拼读区 -->
|
|
|
<!-- 单词字母多余6个需要追加 class:pin-small-words-box -->
|
|
|
- <view class="pin-words-box" :class="{'pin-small-words-box': wordLength > 6, 'isAll': data.isAll, 'pin-right-words-box': data.isAll && data.result, 'pin-error-words-box': data.isAll && !data.result}">
|
|
|
+ <view class="pin-words-box"
|
|
|
+ :class="{'pin-small-words-box': wordLength > 6, 'isAll': data.isAll, 'pin-right-words-box': data.isAll && data.result, 'pin-error-words-box': data.isAll && !data.result}">
|
|
|
<view class="words-item" v-for="item in data.selectList">{{item}}</view>
|
|
|
</view>
|
|
|
<view class="pin-body-box">
|
|
@@ -12,40 +13,39 @@
|
|
|
<view class="clean-btn" v-if="isAlreadyAnswer" @click="handleReset"></view>
|
|
|
<!-- 提示 -->
|
|
|
<view class="pin-tip" v-else>提示:请点击页面下方字母,选择正确答案。</view>
|
|
|
- <!-- 解释区 需要分成多行 -->
|
|
|
+ <!-- 解释区-->
|
|
|
<view class="pin-words-explain-box">
|
|
|
<view class="words-explain-item" v-for="item in activeWord.jianyi" :key="item">{{item}}</view>
|
|
|
</view>
|
|
|
- <!-- 播放和待播放需要写个切换 大哥看这里 -->
|
|
|
- <!-- 待播放 -->
|
|
|
- <view class="audio-play-btn"></view>
|
|
|
- <!-- 播放中 -->
|
|
|
- <view class="audio-playing-btn" v-if="false"></view>
|
|
|
+ <audioOneVue @play-audio="handlePlay" :activeWord="activeWord"></audioOneVue>
|
|
|
</view>
|
|
|
- <!-- 选择区 单词字母多余6个需要追加 class:pin-small-words-box -->
|
|
|
+ <!-- 选择区 -->
|
|
|
<view class="pin-words-box pin-words-change-box" :class="{'pin-small-words-box': wordLength>6}">
|
|
|
- <view class="words-item words-change-item" v-for="item in data.randomList" :key="item" :class="{disabled: isSelect(item)}" @click="handleSelect(item)">{{item}}</view>
|
|
|
+ <view class="words-item words-change-item" v-for="item in data.randomList" :key="item"
|
|
|
+ :class="{disabled: isSelect(item)}" @click="handleSelect(item)">{{item}}</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import selectTypesVue from './selectTypes.vue';
|
|
|
+ import audioOneVue from './audioOne.vue';
|
|
|
import {
|
|
|
reactive,
|
|
|
- computed
|
|
|
+ computed,
|
|
|
} from 'vue';
|
|
|
- import {onLoad} from "@dcloudio/uni-app"
|
|
|
+ import {
|
|
|
+ onLoad
|
|
|
+ } from "@dcloudio/uni-app"
|
|
|
import * as httpApi from "@/api/word.js"
|
|
|
import {
|
|
|
getUserIdentity,
|
|
|
} from "@/utils/common.js"
|
|
|
- import {useAudio} from "./useAudio.js"
|
|
|
-
|
|
|
|
|
|
-
|
|
|
+ const emits = defineEmits(['play-audio'])
|
|
|
+
|
|
|
const userCode = getUserIdentity();
|
|
|
-
|
|
|
+
|
|
|
const props = defineProps({
|
|
|
activeWord: {
|
|
|
type: Object,
|
|
@@ -54,8 +54,10 @@
|
|
|
type: Array
|
|
|
},
|
|
|
})
|
|
|
-
|
|
|
- const { handlePlay } = useAudio(props.activeWord.yinpin)
|
|
|
+
|
|
|
+ function handlePlay(opt) {
|
|
|
+ emits('play-audio', opt)
|
|
|
+ }
|
|
|
|
|
|
const data = reactive({
|
|
|
list: [],
|
|
@@ -64,49 +66,45 @@
|
|
|
result: false, // 正确性
|
|
|
isAll: false, // 是否全答
|
|
|
})
|
|
|
-
|
|
|
+
|
|
|
onLoad(() => {
|
|
|
initItem()
|
|
|
})
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
- console.log('activeWord', props.activeWord)
|
|
|
- })
|
|
|
-
|
|
|
- const wordLength = computed(() => props.activeWord.name.length)
|
|
|
+ const wordLength = computed(() => props.activeWord.name.length)
|
|
|
const isAlreadyAnswer = computed(() => {
|
|
|
return data.selectList.some(item => item != '')
|
|
|
})
|
|
|
|
|
|
- function isSelect(item) {
|
|
|
- return data.selectList.some(ite => ite == item)
|
|
|
- }
|
|
|
+ function isSelect(item) {
|
|
|
+ return data.selectList.some(ite => ite == item)
|
|
|
+ }
|
|
|
|
|
|
- function handleReset() {
|
|
|
- data.list.forEach((item, index) => {
|
|
|
- data.selectList[index] = ''
|
|
|
- })
|
|
|
+ function handleReset() {
|
|
|
+ data.list.forEach((item, index) => {
|
|
|
+ data.selectList[index] = ''
|
|
|
+ })
|
|
|
|
|
|
- data.result = false;
|
|
|
- data.isAll = false;
|
|
|
- }
|
|
|
+ data.result = false;
|
|
|
+ data.isAll = false;
|
|
|
+ }
|
|
|
|
|
|
function shuffleArray(array) {
|
|
|
- for (let i = array.length - 1; i > 0; i--) {
|
|
|
- const j = Math.floor(Math.random() * (i + 1));
|
|
|
- [array[i], array[j]] = [array[j], array[i]]; // ES6解构赋值交换元素
|
|
|
- }
|
|
|
- return array;
|
|
|
+ for (let i = array.length - 1; i > 0; i--) {
|
|
|
+ const j = Math.floor(Math.random() * (i + 1));
|
|
|
+ [array[i], array[j]] = [array[j], array[i]]; // ES6解构赋值交换元素
|
|
|
+ }
|
|
|
+ return array;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
function randomClone(arr) {
|
|
|
- const clone = [...arr];
|
|
|
- return shuffleArray(clone); // 复用方法一的洗牌算法
|
|
|
+ const clone = [...arr];
|
|
|
+ return shuffleArray(clone); // 复用方法一的洗牌算法
|
|
|
}
|
|
|
|
|
|
// 初始化 单词列表
|
|
|
function initItem() {
|
|
|
-
|
|
|
+
|
|
|
data.list = props.activeWord.chaifen;
|
|
|
data.randomList = randomClone(data.list);
|
|
|
data.list.forEach((item, index) => {
|
|
@@ -115,16 +113,6 @@
|
|
|
}
|
|
|
|
|
|
function handleSelect(word) {
|
|
|
-
|
|
|
-
|
|
|
- // 点击触发取消
|
|
|
- /*if (data.selectList.find(item => item == word)) {
|
|
|
- data.selectList[data.selectList.findIndex(item => item == word)] = '';
|
|
|
- // 校验正确性
|
|
|
- checkIsRight();
|
|
|
- return;
|
|
|
- }*/
|
|
|
-
|
|
|
// 覆盖状态
|
|
|
let status = false;
|
|
|
data.selectList.forEach((item, index) => {
|
|
@@ -138,13 +126,13 @@
|
|
|
})
|
|
|
// 校验正确性
|
|
|
checkIsRight();
|
|
|
-
|
|
|
+
|
|
|
if (data.selectList.some(item => item == '')) {
|
|
|
- data.isAll = false;
|
|
|
+ data.isAll = false;
|
|
|
} else {
|
|
|
- data.isAll = true;
|
|
|
+ data.isAll = true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
function checkIsRight() {
|
|
@@ -170,7 +158,7 @@
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
</style>
|