wangguoyu 3 months ago
parent
commit
9814bd9447

+ 12 - 0
api/word.js

@@ -34,6 +34,18 @@ export function getWordInfo(data = {}) {
     timeout: 20000
   })
 }
+
+export function getWordInfoYk(data = {}) {
+  return request({
+    'url': '/common/word/info',
+    headers: {
+      isToken: true
+    },
+    method: 'post',
+    data,
+    timeout: 20000
+  })
+}
 
 export function getCommonWordInfo(data = {}) {
   return request({

+ 5 - 2
pages/newEnglish/components/mainCard.vue

@@ -2,7 +2,7 @@
     <swiper class="word-view-swiper-box" :indicator-dots="false" :autoplay="false" :circular="false">
         <swiper-item>
             <view class="swiper-item uni-bg-red">
-                <xuePage :active-word="activeWord" :active-words="activeWords" @play-audio="handlePlayAudio"
+                <xuePage :active-word="activeWord" :active-words="activeWords" @goXiangjie="goXiangjie" @play-audio="handlePlayAudio"
                          :pageData="pageData"></xuePage>
             </view>
         </swiper-item>
@@ -51,10 +51,13 @@
             type: Array
         },
     })
-    const emits = defineEmits(['play-audio'])
+    const emits = defineEmits(['play-audio','goXiangjie'])
 
     function handlePlayAudio({url, code}) {
         emits('play-audio', {url, code})
+    }  
+	 function goXiangjie() {
+        emits('goXiangjie')
     }
 </script>
 

+ 23 - 2
pages/newEnglish/components/xiangjie.vue

@@ -37,25 +37,36 @@
 		onMounted
 	} from 'vue';
 	import {
-		getWordInfo
+		getWordInfo,
+		getWordInfoYk
 	} from "@/api/word.js"
 	import {
 		onLoad
 	} from '@dcloudio/uni-app';
+	
+	import {
+		getUserIdentity,
+	} from "@/utils/common.js"
 	const goXiangjie = () => {
 
 	}
+	
 	const pageInfo = ref({
 		kouyu: [],
 		xiangyi: [],
 		name: ''
 	})
 	const data = ref(null)
-
+	const userCode = getUserIdentity();
 
 	onLoad((options) => {
+		if (userCode !== 'Visitor') {
 		getInfo(options)
 		data.value = options
+		} else {
+		getCommonInfo(options)
+		data.value = options
+		}
 	})
 	const highlightWord = (text) => {
 		if (!text || !pageInfo.value.name){return text} 
@@ -81,6 +92,16 @@
 			pageInfo.value = res.data
 		})
 	}
+	const getCommonInfo = (data) => {
+		let req = {
+			jieId: data.jieId,
+			wordId: data.wordId
+		}
+		getWordInfoYk(req).then(res => {
+			console.log('res', res);
+			pageInfo.value = res.data
+		})
+	}
 </script>
 
 <style>

+ 33 - 21
pages/newEnglish/components/xuePage.vue

@@ -26,11 +26,13 @@
 			<!-- 音标拆分区 -->
 			<view v-if="data.isPindu" class="word-block-box yb-block-box">
 				<!-- pindu -->
-				<audioThreeVue v-for="(item,index) in activeWord.pindu" :key="index" :YItem="item" @play-audio="handlePlay"></audioThreeVue>
+				<audioThreeVue v-for="(item,index) in activeWord.pindu" :key="index" :YItem="item"
+					@play-audio="handlePlay"></audioThreeVue>
 			</view>
 			<view v-else class="yj-block-box">
 				<!-- yinjie -->
-				<audioFourVue v-for="(item,index) in activeWord.yinjie" :key="index" :YItem="item" @play-audio="handlePlay"></audioFourVue>
+				<audioFourVue v-for="(item,index) in activeWord.yinjie" :key="index" :YItem="item"
+					@play-audio="handlePlay"></audioFourVue>
 			</view>
 
 			<!-- 音标按钮 -->
@@ -41,10 +43,12 @@
 			<!-- 词根+实用口语 -->
 			<view v-if="activeWord.cigenzhuji.length" class="details-content-box xue-details-content-box">
 				<text class="details-title">词根助记</text>
-				<scroll-view class="cg-item-list" scroll-x @touchmove.stop >
-					<view class="cg-item-box" v-for="(item,index) in activeWord.cigenzhuji" :key="index" >
+				<scroll-view class="cg-item-list" scroll-x @touchmove.stop>
+					<view class="cg-item-box" v-for="(item,index) in activeWord.cigenzhuji" :key="index">
 						<view class="cg-item">
-							<view :class="{isEven: index% 2 !== 0 && index!==activeWord.cigenzhuji.length-1,isOdd: index% 2 === 0 && index!==activeWord.cigenzhuji.length-1}">{{item.en}}</view>
+							<view
+								:class="{isEven: index% 2 !== 0 && index!==activeWord.cigenzhuji.length-1,isOdd: index% 2 === 0 && index!==activeWord.cigenzhuji.length-1}">
+								{{item.en}}</view>
 							<view>{{item.zn}}</view>
 						</view>
 						<view class="cg-symbol" v-if="index<activeWord.cigenzhuji.length-2">+</view>
@@ -52,7 +56,7 @@
 					</view>
 				</scroll-view>
 			</view>
-				
+
 			<!-- 实用语句 -->
 			<view class="details-content-box xue-details-content-box">
 				<text class="details-title">实用口语</text>
@@ -87,8 +91,8 @@
 		useAudioCache
 	} from './useAudio.js';
 
-	const emits = defineEmits(['play-audio'])
-
+	const emits = defineEmits(['play-audio','goXiangjie'])
+	const userCode = getUserIdentity();
 	const {
 		cacheAudio,
 		clearAudioCache
@@ -96,12 +100,10 @@
 
 
 	const data = reactive({
-		isPlaying:false,
-		isPindu:true,
+		isPlaying: false,
+		isPindu: true,
 	})
 
-	const userCode = getUserIdentity();
-
 	const props = defineProps({
 		activeWord: { // 单词数据
 			type: Object,
@@ -116,31 +118,41 @@
 
 
 	const highlightWord = (text) => {
-		if (!text || !props.activeWord.name){return text} 
+		if (!text || !props.activeWord.name) {
+			return text
+		}
 		const word = props.activeWord.name;
 		const regex = new RegExp(word, 'gi');
 		return text.replace(regex, (match) => {
 			return `<span style="color: #3a7fe9;">${match}</span>`;
 		});
 	}
-	
+
 	async function handlePlay(opt) {
 		emits('play-audio', opt)
 	}
-	
+
 	function handlePindu() {
 		data.isPindu = true
 	}
-	
+
 	function handleYinjie() {
 		data.isPindu = false
 	}
 
-  function goXiangjie() {
-    uni.redirectTo({
-      url: '/pages/newEnglish/components/xiangjie?jieId='+props.pageData.jieId+'&wordId='+props.pageData.activeId
-    })
-  }
+	function goXiangjie() {
+
+		if (userCode !== 'Visitor') {
+			uni.redirectTo({
+				url: '/pages/newEnglish/components/xiangjie?jieId=' + props.pageData.jieId + '&wordId=' + props
+					.pageData.activeId
+			})
+		} else {
+			emits('goXiangjie')
+		}
+
+
+	}
 </script>
 
 <style>

+ 10 - 3
pages/newEnglish/index.vue

@@ -8,7 +8,8 @@
 			<view class="ezy-border-body">
 				<template v-for="item in data.wordList">
 					<mainCardVue :active-word="data.activeWord" :pageData="data" :active-words="activeWords"
-						@play-audio="handlePlayAudio" v-if="item.id == data.activeId" :key="item.id">
+						@play-audio="handlePlayAudio" @goXiangjie="goXiangjie" v-if="item.id == data.activeId"
+						:key="item.id">
 					</mainCardVue>
 				</template>
 			</view>
@@ -240,6 +241,12 @@
 		}
 	}
 
+	function goXiangjie() {
+		uni.redirectTo({
+			url: `/pages/newEnglish/components/xiangjie?levelId=${data.levelId}&typeId=${data.typeId}&subjectId=${data.subjectId}&tipFlag=${data.tipFlag}&wordId=${data.activeId}&youkeZhangId=${data.zhangId}&jieId=${data.jieId}`
+		})
+	}
+
 	function handleCacheAudio() {
 
 		const arr = []
@@ -262,8 +269,8 @@
 		url,
 		code
 	}) {
-	 console.log('播放', url)
-	 console.log('播放', code)
+		console.log('播放', url)
+		console.log('播放', code)
 		const cachedPath = await cacheAudio(url);
 		if (cachedPath && cachedPath.includes('.mp3')) {
 			// console.log('地址:', cachedPath)