wangguoyu 5 kuukautta sitten
vanhempi
commit
6ab2946e83
3 muutettua tiedostoa jossa 217 lisäystä ja 35 poistoa
  1. 24 21
      pages/study/index.vue
  2. 38 14
      pages/study/product/shuxue.vue
  3. 155 0
      pages/study/product/yingyu.vue

+ 24 - 21
pages/study/index.vue

@@ -1,12 +1,16 @@
 <template>
 	<view class="ezy-study-page">
-		<shuxueZhangjie @clickGradeTerm="clickGradeTerm" @onLeft="onLeft" @onRight="onRight"
-			@handleCheckCatalogue="handleCheckCatalogue" :options="infoData">
-		</shuxueZhangjie>
+		<shuxueZhangjie v-if="currentProduct ==1" @clickGradeTerm="clickGradeTerm" @onLeft="onLeft" @onRight="onRight"
+			@handleCheckCatalogue="handleCheckCatalogue" @listClick="listClick" :options="infoData">
+		</shuxueZhangjie>
+		<yingyuZhangjie v-if="currentProduct ==2" @clickGradeTerm="clickGradeTerm" @onLeft="onLeft" @onRight="onRight"
+			@handleCheckCatalogue="handleCheckCatalogue" @listClick="listClick" :options="infoData">
+		</yingyuZhangjie>
 		<!-- 蛋 -->
 		<egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
 		<catalogue ref="catalogueRef" @change-zhang="handleChangeZhang"></catalogue>
-		<CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
+		<CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
+				<tip-small-dialog ref="goPayDialogRef" @confirm-btn="goPay" :content="tipContent"></tip-small-dialog>
 	</view>
 
 </template>
@@ -28,8 +32,12 @@
 		onLoad
 	} from '@dcloudio/uni-app';
 	import catalogue from "@/components/catalogue/catalogue.vue";
-	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
-	import shuxueZhangjie from './product/shuxue.vue';
+	import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
+		import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
+		
+	import shuxueZhangjie from './product/shuxue.vue';
+	import yingyuZhangjie from './product/yingyu.vue';
+	
 	import {
 		useTabBarHistory
 	} from '@/utils/emitEvents.js';
@@ -38,12 +46,13 @@
 		toast,getUserIdentity
 	} from "@/utils/common";
 	import cacheManager from "@/utils/cacheManager.js";
-
-
+	const tipContent = '付费章节,是否前往开通付费?'; 
+	const currentProduct = cacheManager.get('auth').cardId; //当前产品
+	const goPayDialogRef = ref(null);
 	const eggDialogRef = ref(null);
-	const zhangId = ref(null);
-	const nianji = ref(null);
-	const cardId = ref(null);
+	const zhangId = ref(null); //游客使用
+	const nianji = ref(null);//游客使用
+	const cardId = ref(null);//游客使用
 	const catalogueRef = ref(null);
 	const selectZhang = ref(null);
 	let infoData = reactive({
@@ -262,18 +271,12 @@
 			})
 			return;
 		}
-
-		// if(index !=0&&data.jieId!=79){
-
-		//             toast("付费章节!")
-		//             return false
-		// }
-
-		if (!data.vipFlag) {
-			toast("付费章节!")
+		const authCode = getUserIdentity();
+		if (!(authCode=='VIP' || data.number == 1)) {
+			goPayDialogRef.value.handleShow();
 			return false
 		}
-		if (index == infoData.jieList.length - 1) {
+		if (data.number == infoData.jieList.length) {
 			// 最后一项
 			goKaoshi(data)
 		} else {

+ 38 - 14
pages/study/product/shuxue.vue

@@ -8,19 +8,19 @@
 				<view class="brand-item" v-for="(item, index) in options.jieList" :key="item.jieId"
 					@click="listClick(item, index)" :class="{ 'brand-active': index === 0 }">
 					<view class="brand-icon">
-						<template v-if="item.vipFlag">{{ index + 1 }}</template>
-						<template v-else-if="index === 0">1</template>
+						{{ item.number }}
 					</view>
-					<view class="brand-lock" v-if="item.vipFlag==0 && index !== 0"></view>
-					<view class="brand-growth">
-						<template v-if="item.vipFlag ==1">
-							<template v-if="item.growth === 0">蛋</template>
-							<template v-else-if="item.growth === 10">小鹅</template>
-							<template v-else-if="item.growth === 20">中鹅</template>
-							<template v-else-if="item.growth === 50">大鹅</template>
-						</template>
+					<view v-if="item.daeFlag">
+					<template v-if="growthType ==0">蛋</template>
+					<template v-if="growthType ==1">小鹅</template>
+					<template v-if="growthType ==2">中鹅</template>
+					<template v-if="growthType ==3">大鹅</template>
+					</view>
+					<!-- 如果用户不是 VIP 且不是第一项,则添加 brand-lock 类 -->
+					<view v-if="!(isVip=='VIP' || item.number == 1)" class="brand-lock"></view>
+					<view class="brand-content">
+						{{ item.jieName }}
 					</view>
-					<view class="brand-content">{{ item.jieName }}</view>
 				</view>
 			</view>
 		</view>
@@ -36,12 +36,18 @@
 		onMounted
 	} from "vue";
 	import cacheManager from "@/utils/cacheManager.js";
-	const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue'])
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue', 'listClick'])
 	const props = defineProps({
 		options: {
 			type: Object,
 		},
 	})
+	const isVip = getUserIdentity();
+	const growthType = cacheManager.get('auth').growthType;
 	const gradeMapping = {
 		1: '一年级',
 		2: '二年级',
@@ -52,8 +58,8 @@
 	};
 
 	const termMapping = {
-		1: '数学',
-		2: '英语'
+		1: ' 数学',
+		2: ' 英语'
 	};
 
 	let startX = ref(0);
@@ -65,6 +71,10 @@
 		$emit('clickGradeTerm');
 	}
 
+	function listClick(data) {
+		$emit('listClick', data);
+	}
+
 	function translateData(data) {
 		return gradeMapping[data.nianji] + termMapping[data.cardId]
 	}
@@ -114,11 +124,25 @@
 			console.log('error');
 		}
 	}
+	function dataRecom(data){
+		if(data&&data.jieList.length>0){
+			data.jieList.some(item => {
+			    if (item.studyFlag == 0) {
+			        item.daeFlag = true;
+			        return true; // 返回 true 以终止 some 循环
+			    }
+			    return false;
+			});
+		}
+		console.log(data);
+		console.log("1111");
+	}
 	watch(() => props.options, (newVal, oldVal) => {
 		console.log('New options:', newVal);
 		console.log('Old options:', oldVal);
 		// 在这里可以根据新的 options 做一些操作,比如发起请求等
 		gradeTerm.value = translateData(newVal);
+		dataRecom(newVal)
 	}, {
 		deep: true,
 		immediate: true

+ 155 - 0
pages/study/product/yingyu.vue

@@ -0,0 +1,155 @@
+<template>
+	<view>
+		英语	英语	英语	英语	英语
+		<view class="study-school-year" @click="clickGradeTerm">{{gradeTerm}}</view>
+		<view class="ezy-study-wrap" @touchstart="onTouchStart" @touchend="onTouchEnd">
+			<view class="chapter-box" @click="handleCheckCatalogue">{{options.numberStr}}</view>
+			<view class="chapter-title-box">{{options.zhangName}}</view>
+			<view>
+				<view class="brand-item" v-for="(item, index) in options.jieList" :key="item.jieId"
+					@click="listClick(item, index)" :class="{ 'brand-active': index === 0 }">
+					<view class="brand-icon">
+						{{ item.number }}
+					</view>
+					<view v-if="item.daeFlag">
+					<template v-if="growthType ==0">蛋</template>
+					<template v-if="growthType ==1">小鹅</template>
+					<template v-if="growthType ==2">中鹅</template>
+					<template v-if="growthType ==3">大鹅</template>
+					</view>
+					<!-- 如果用户不是 VIP 且不是第一项,则添加 brand-lock 类 -->
+					<view v-if="!(isVip=='VIP' || item.number == 'Lesson 1')" class="brand-lock"></view>
+					<view class="brand-content">
+						{{ item.jieName }}
+					</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script setup>
+	import {
+		reactive,
+		ref,
+		watch,
+		getCurrentInstance,
+		onMounted
+	} from "vue";
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue', 'listClick'])
+	const props = defineProps({
+		options: {
+			type: Object,
+		},
+	})
+	const isVip = getUserIdentity();
+	const growthType = cacheManager.get('auth').growthType;
+	const gradeMapping = {
+		1: '一年级',
+		2: '二年级',
+		3: '三年级',
+		4: '四年级',
+		5: '五年级',
+		6: '六年级'
+	};
+
+	const termMapping = {
+		1: ' 数学',
+		2: ' 英语'
+	};
+
+	let startX = ref(0);
+	let isSliding = ref(false);
+	let endX = ref(0);
+	let gradeTerm = ref('');
+
+	function clickGradeTerm() {
+		$emit('clickGradeTerm');
+	}
+
+	function listClick(data) {
+		$emit('listClick', data);
+	}
+
+	function translateData(data) {
+		return gradeMapping[data.nianji] + termMapping[data.cardId]
+	}
+
+	function handleCheckCatalogue() {
+		$emit('handleCheckCatalogue');
+	}
+
+	function onTouchStart(event) {
+		console.log(event.touches.length);
+		isSliding.value = false
+		if (event.touches.length === 1) {
+			isSliding.value = true;
+			startX.value = event.touches[0].pageX;
+		} else {
+			isSliding.value = false;
+			event.preventDefault()
+			return
+		}
+	}
+
+	function onSwipeLeft(event) {
+		console.log('11111');
+		if (cacheManager.get('auth')) {
+			$emit('onLeft');
+		}
+	}
+
+	function onSwipeRight(event) {
+		console.log('22222');
+		if (cacheManager.get('auth')) {
+			$emit('onRight');
+		}
+
+	}
+
+	function onTouchEnd(event) {
+		if (isSliding.value) {
+			const distanceX = event.changedTouches[0].clientX - startX.value
+			if (distanceX > 0) {
+				onSwipeLeft();
+			} else if (distanceX < 0) {
+				onSwipeRight();
+			}
+			isSliding.value = false
+		} else {
+			console.log('error');
+		}
+	}
+	function dataRecom(data){
+		if(data&&data.jieList.length>0){
+			data.jieList.some(item => {
+			    if (item.studyFlag == 0) {
+			        item.daeFlag = true;
+			        return true; // 返回 true 以终止 some 循环
+			    }
+			    return false;
+			});
+		}
+		console.log(data);
+		console.log("1111");
+	}
+	watch(() => props.options, (newVal, oldVal) => {
+		console.log('New options:', newVal);
+		console.log('Old options:', oldVal);
+		// 在这里可以根据新的 options 做一些操作,比如发起请求等
+		gradeTerm.value = translateData(newVal);
+		dataRecom(newVal)
+	}, {
+		deep: true,
+		immediate: true
+	});
+</script>
+
+<style>
+
+</style>