浏览代码

update 选 拼

wangxy 3 月之前
父节点
当前提交
90582c1095
共有 3 个文件被更改,包括 59 次插入11 次删除
  1. 10 0
      pages/newEnglish/components/beiPage.vue
  2. 27 5
      pages/newEnglish/components/pinPage.vue
  3. 22 6
      pages/newEnglish/index.vue

+ 10 - 0
pages/newEnglish/components/beiPage.vue

@@ -24,6 +24,12 @@
 		reactive,
 		computed
 	} from 'vue';
+	import {
+		getUserIdentity,
+	} from "@/utils/common.js"
+	
+	const userCode = getUserIdentity();
+	
 	const props = defineProps({
 		activeWord: { // 单词数据
 			type: Object,
@@ -54,6 +60,10 @@
 
 	function noticeBackDb() {
 		// 通知后台已学完当前单词
+		if (userCode == 'Visitor') {
+			// 游客不更新后台
+			return;
+		}
 	}
 	
 	function handleReset() {

+ 27 - 5
pages/newEnglish/components/pinPage.vue

@@ -6,7 +6,7 @@
 		<selectTypesVue activeSelect="2"></selectTypesVue>
 		<!-- 拼读区 -->
 		<view>
-			<view v-for="item in data.selectList">
+			<view v-for="item in data.selectList" :class="{isAll: data.isAll, right:  data.isAll && data.result, wrong:  data.isAll && !data.result}">
 				<view>内容:{{item}}</view>
 			</view>
 		</view>
@@ -17,12 +17,12 @@
 		<!-- 音标区 -->
 		<view></view>
 		<!-- 图片区 -->
-		<view>
+		<view @click="handleReset">
 			{{data.result ? '正确': '错误'}}
 		</view>
 		<!-- 选择区 -->
 		<view>
-			<view v-for="item in data.randomList" @click="handleSelect(item)">
+			<view v-for="item in data.randomList" :class="{active:  isSelect(item)}" @click="handleSelect(item)">
 				<view>内容:{{item}}</view>
 			</view>
 		</view>
@@ -58,6 +58,7 @@
 		randomList: [],
 		selectList: [],
 		result: false, // 正确性
+    isAll: false, // 是否全答
 	})
 	
 	onLoad(() => {
@@ -68,6 +69,18 @@
 		console.log('activeWord', props.activeWord)
 	})
 
+  function isSelect(item) {
+    return data.selectList.some(ite => ite == item)
+  }
+
+  function handleReset() {
+    data.list.forEach((item, index) => {
+      data.selectList[index] = ''
+    })
+
+    data.result = false;
+    data.isAll = false;
+  }
 
 	function shuffleArray(array) {
 	  for (let i = array.length - 1; i > 0; i--) {
@@ -93,12 +106,21 @@
 	}
 
 	function handleSelect(word) {
-		if (data.selectList.find(item => item == word)) {
+
+    if (data.selectList.some(item => item == '') != -1) {
+      data.isAll = true;
+    } else {
+      data.isAll = false;
+    }
+
+    // 点击触发取消
+		/*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) => {

+ 22 - 6
pages/newEnglish/index.vue

@@ -7,8 +7,8 @@
 		<view class="ezy-tab-border">
 			<view class="ezy-border-body">
 				<template v-for="item in data.wordList">
-					<mainCardVue :active-word="data.activeWord" :active-words="activeWords" v-if="item.id == data.activeId"
-						:key="item.id">
+					<mainCardVue :active-word="data.activeWord" :active-words="activeWords"
+						v-if="item.id == data.activeId" :key="item.id">
 					</mainCardVue>
 				</template>
 			</view>
@@ -35,9 +35,9 @@
 		onLoad
 	} from "@dcloudio/uni-app";
 	import * as httpApi from "@/api/word.js"
-  import {
-    getUserIdentity,
-  } from "@/utils/common.js"
+	import {
+		getUserIdentity,
+	} from "@/utils/common.js"
 
 	const userCode = getUserIdentity();
 
@@ -162,7 +162,23 @@
 		}
 	}
 
-	function handleShouCang() {}
+	function handleShouCang() {
+		httpApi.getWordShouCang({
+			wordId: data.activeId
+		}).then(res => {
+			if (res.data) {
+				uni.showToast({
+					title: '收藏成功'
+				})
+				data.collectFlag = 1;
+			} else {
+				uni.showToast({
+					title: '收藏取消'
+				})
+				data.collectFlag = 0;
+			}
+		})
+	}
 
 	function initWordInfo() {
 		httpApi.getWordInfo({