浏览代码

Merge branch '2025鹅状元dev' of https://gogs.mtavip.com/wangguoyu/uniProject into 2025鹅状元dev

tanxue 3 月之前
父节点
当前提交
3f0bc4ee99

+ 12 - 0
api/word.js

@@ -58,3 +58,15 @@ export function getWordZhangwo(data = {}) {
     timeout: 20000
   })
 }
+
+export function getWordShouCang(data = {}) {
+  return request({
+    'url': '/app/word/collect',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}

+ 1 - 0
pages.json

@@ -15,6 +15,7 @@
 		{
 			"path": "pages/selectGradesTerms/index",
 			"style": {
+				
 				"navigationBarTitleText": "选择学科和年纪",
 				"navigationStyle": "custom",
 				"app-plus": {

+ 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() {

+ 3 - 3
pages/newEnglish/components/mainCard.vue

@@ -19,8 +19,7 @@
 		</swiper-item>
 		<swiper-item>
 			<view class="swiper-item uni-bg-blue">
-				选
-				<hr />{{activeWord}}
+        <selectPage :active-word="activeWord" :active-words="activeWords"></selectPage>
 			</view>
 		</swiper-item>
 		<swiper-item>
@@ -33,7 +32,8 @@
 </template>
 
 <script setup>
-	import pinPageVue from './pinPage.vue';
+import pinPageVue from './pinPage.vue';
+import selectPage from './selectPage.vue';
 	import learnContent from './learnContent.vue';
 	const props = defineProps({
 		activeWord: {

+ 85 - 14
pages/newEnglish/components/pinPage.vue

@@ -6,8 +6,8 @@
 		<selectTypesVue activeSelect="2"></selectTypesVue>
 		<!-- 拼读区 -->
 		<view>
-			<view v-for="item in data.list">
-				<view></view>
+			<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,9 +17,15 @@
 		<!-- 音标区 -->
 		<view></view>
 		<!-- 图片区 -->
-		<view></view>
+		<view @click="handleReset">
+			{{data.result ? '正确': '错误'}}
+		</view>
 		<!-- 选择区 -->
-		<view></view>
+		<view>
+			<view v-for="item in data.randomList" :class="{active:  isSelect(item)}" @click="handleSelect(item)">
+				<view>内容:{{item}}</view>
+			</view>
+		</view>
 	</div>
 </template>
 
@@ -30,6 +36,14 @@
 		reactive,
 		computed
 	} from 'vue';
+	import {onLoad} from "@dcloudio/uni-app"
+	import * as httpApi from "@/api/word.js"
+	import {
+		getUserIdentity,
+	} from "@/utils/common.js"
+	
+	const userCode = getUserIdentity();
+	
 	const props = defineProps({
 		activeWord: {
 			type: Object,
@@ -41,32 +55,79 @@
 
 	const data = reactive({
 		list: [],
+		randomList: [],
 		selectList: [],
 		result: false, // 正确性
+    isAll: false, // 是否全答
+	})
+	
+	onLoad(() => {
+		initItem()
 	})
 
 	setTimeout(() => {
 		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--) {
+		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); // 复用方法一的洗牌算法
+	}
+
 	// 初始化 单词列表
-	function initList() {
-		data.selectList.forEach((item, index) => {
-			data.list[index] = ''
+	function initItem() {
+		
+		data.list = props.activeWord.chaifen;
+		data.randomList = randomClone(data.list);
+		data.list.forEach((item, index) => {
+			data.selectList[index] = ''
 		})
 	}
 
 	function handleSelect(word) {
-		if (data.list.find(item => item == word)) {
-			data.list[data.list.findIndex(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.list.forEach((item, index) => {
+		data.selectList.forEach((item, index) => {
 			// 无值 无修改
 			if (!item && !status) {
 				// 第一项空值覆盖
-				data.list[index] = word;
+				data.selectList[index] = word;
 				// 以有控制覆盖
 				status = true;
 			}
@@ -86,9 +147,19 @@
 	}
 
 	function noticeBackDb() {
-
+		if (userCode == 'Visitor') {
+			// 游客不更新后台
+			return;
+		}
+		httpApi.getWordZhangwo({
+			type: 1,
+			wordId: props.activeWord.id
+		})
 	}
 </script>
 
-<style>
+<style lang="scss" scoped>
+	
+	
+	
 </style>

+ 53 - 16
pages/newEnglish/components/selectPage.vue

@@ -6,18 +6,22 @@
 		<selectTypesVue activeSelect="2"></selectTypesVue>
 		<!-- 拼读区 -->
 		<view>
-			<view v-for="item in data.list">
-				<view></view>
-			</view>
+			{{data.name}}
+		</view>
+		<!--  音标区  -->
+		<view>
+			{{activeWord.yinbiao}}
 		</view>
 		<!-- 图片区 -->
-		<view></view>
+		<view>
+			{{ data.result ?'正确':'错误' }}
+		</view>
 		<!-- 选择区 -->
 		<view>
-			<view>{{data.qa}}</view>
-			<view>{{data.qb}}</view>
-			<view>{{data.qc}}</view>
-			<view>{{data.qd}}</view>
+			<view :class="{active: data.answer == 'A'}" @click="handleSelect('A')">{{data.opa}}</view>
+			<view :class="{active: data.answer == 'B'}" @click="handleSelect('B')">{{data.opb}}</view>
+			<view :class="{active: data.answer == 'C'}" @click="handleSelect('C')">{{data.opc}}</view>
+			<view :class="{active: data.answer == 'D'}" @click="handleSelect('D')">{{data.opd}}</view>
 		</view>
 	</view>
 </template>
@@ -25,10 +29,20 @@
 <script setup>
 	import selectWordsVue from './selectWords.vue';
 	import selectTypesVue from './selectTypes.vue';
+	import * as httpApi from "@/api/word.js"
+	import {
+		onLoad
+	} from "@dcloudio/uni-app"
 	import {
 		reactive,
 		computed
 	} from 'vue';
+	import {
+		getUserIdentity,
+	} from "@/utils/common.js"
+	
+	const userCode = getUserIdentity();
+	
 	const props = defineProps({
 		activeWord: { // 单词数据
 			type: Object,
@@ -38,21 +52,34 @@
 		},
 	})
 	const data = reactive({
-		list: [],
-		qa: null,
-		qb: null,
-		qc: null,
-		qd: null,
+		name: [],
+		opa: null,
+		opb: null,
+		opc: null,
+		opd: null,
 		answer: null, // 已选项
 		result: false, // 正确性
 	})
 
+	onLoad(() => {
+		initItem()
+	})
+
+	function initItem() {
+		data.name = props.activeWord.name;
+		data.opa = props.activeWord.opa;
+		data.opb = props.activeWord.opb;
+		data.opc = props.activeWord.opc;
+		data.opd = props.activeWord.opd;
+	}
+
 	function handleSelect(d1) {
 		data.answer = d1;
+		checkIsRight();
 	}
 
 	function checkIsRight() {
-		if (data.answer == props.activeWord.value) {
+		if (data.answer == props.activeWord.daan) {
 			// 正确
 			data.result = true;
 			noticeBackDb()
@@ -62,9 +89,19 @@
 	}
 
 	function noticeBackDb() {
-
+		if (userCode == 'Visitor') {
+			// 游客不更新后台
+			return;
+		}
+		httpApi.getWordZhangwo({
+			type: 2,
+			wordId: props.activeWord.id
+		})
 	}
 </script>
 
-<style>
+<style lang="scss" scoped>
+	.active {
+		color: red;
+	}
 </style>

+ 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({