Prechádzať zdrojové kódy

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

tanxue 5 dní pred
rodič
commit
6120b441ec

+ 2 - 2
config.js

@@ -1,7 +1,7 @@
 // 应用全局配置
 export default   {
-  baseUrl: 'https://goosechampion.com/api',
-  // baseUrl: 'http://localhost:8080',
+ // baseUrl: 'https://goosechampion.com/api',
+   baseUrl: 'https://kf1.mtavip.com/api',
   // 应用信息
   appInfo: {
     // 应用名称

+ 1 - 1
pages/login/login.vue

@@ -117,7 +117,7 @@
 				login(req).then(res => {
 					if (res.code == 0) {
 						cacheManager.set('auth', res.data)
-						if (res.data.cardId == 0) {
+						if (res.data.levelId == 0) {
 							uni.redirectTo({
 								url: `/pages/selectGradesTerms/index`
 							})

+ 56 - 55
pages/study/index.vue

@@ -3,13 +3,17 @@
 	<swiper :circular="true"  @change="onChangeTab" :duration="currentDuration"
 		:current="current" class="ezy-study-swiper" :class="'ezy-study-swiper'+ currentProduct" >
 		<swiper-item v-for="(item,index) in zhangList" :key="index">
-			<shuxueZhangjie v-if="currentProduct ==1" @clickGradeTerm="clickGradeTerm"
+			<shuxueZhangjie v-if="currentProduct ==1&&typeId==2" @clickGradeTerm="clickGradeTerm"
 				@handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
 				:options="item">
 			</shuxueZhangjie>
-			<yingyuZhangjie v-if="currentProduct ==2" @clickGradeTerm="clickGradeTerm"
+			<yingyuZhangjie v-if="currentProduct ==2&&typeId==2" @clickGradeTerm="clickGradeTerm"
 				@handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm' :options="item">
-			</yingyuZhangjie>
+			</yingyuZhangjie>
+			<shuxueNewZhangjie v-if="currentProduct ==1&&typeId==1" @clickGradeTerm="clickGradeTerm"
+				@handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
+				:options="item">
+			</shuxueNewZhangjie>
 		</swiper-item>
 	</swiper>
 	<!-- 蛋 -->
@@ -47,7 +51,8 @@
 	import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
 	import dSwiper from '@/components/wSwiper/DSwiper.vue';
 
-	import shuxueZhangjie from './product/shuxue.vue';
+	import shuxueZhangjie from './product/shuxue.vue';
+	import shuxueNewZhangjie from './product/shuxueNew.vue';
 	import yingyuZhangjie from './product/yingyu.vue';
 
 	import {
@@ -74,7 +79,9 @@
 	const catalogueRef = ref(null);
 	const youkeZhangInfoData = ref(null);
 	const currentProduct = ref(null);
-	const selectZhang = ref(null);
+	const localAuth = ref(null);
+	const levelId = ref(null);
+	const typeId = ref(null);
 	const zhangList = ref(null);
 	const gradeTerm = ref(null);
 	let infoData = reactive({
@@ -87,14 +94,6 @@
 		zhangName: '',
 		numberStr: '',
 	});
-	const gradeMapping = {
-		1: 'L1',
-		2: 'L2',
-		3: 'L3',
-		4: 'L4',
-		5: 'L5',
-		6: 'L6'
-	};
 
 	const termMapping = {
 		1: ' 数学',
@@ -177,39 +176,42 @@
 		}
 	}
 
-	function init(options) {
+	function init(options) {
+		// FIXME   待修改 部分字段写死
 		if (cacheManager.get('auth')) {
-			//会员 取auth
-			selectZhang.value = cacheManager.get('auth');
-			currentProduct.value = cacheManager.get('auth').cardId;
+			levelId.value = options.levelId
+			typeId.value = options.typeId //1新2旧
+			localAuth.value = cacheManager.get('auth');
+		//	currentProduct.value = cacheManager.get('auth').subjectId;
+			currentProduct.value = 1;
 			//let currentObject = this.cacheZhangInfo.jieList.find(item => item.jieId == this.jieId);
-			console.log(selectZhang.value);
+			console.log(localAuth.value);
 			// 已登录
-			if (selectZhang.value.firstLogin) {
+			if (localAuth.value.firstLogin) {
 				nextTick(() => {
 					eggDialogRef.value.eggShow();
 				})
 			}
-			// cacheManager.set('daoPageCache',{isCache:true})
-			if(!cacheManager.get('daoPageCache').isCache){
-					getZhangInfo()
-				
-			}else{
-					console.log('shiyonghuancun');
-					translateData(cacheManager.get('auth'))
-					zhangList.value = cacheManager.get('zhangInfo').zhangList
-					current.value = cacheManager.get('auth').currentZhang
-					infoData.zhangId = cacheManager.get('zhangInfo').zhangList[current.value].zhangId
-					recordZhangJie()	
-			}
+			getZhangInfo()
+			// if(!cacheManager.get('daoPageCache').isCache){
+			// 		console.log('不实用换葱');
+			// 		getZhangInfo()
+			// }else{
+			// 		console.log('shiyonghuancun');
+			// 		translateData(cacheManager.get('auth'))
+			// 		zhangList.value = cacheManager.get('zhangInfo').zhangList
+			// 		current.value = cacheManager.get('auth').currentZhang
+			// 		infoData.zhangId = cacheManager.get('zhangInfo').zhangList[current.value].zhangId
+			// 		recordZhangJie()	
+			// }
 			
-			// 已登录付费未支付选择返回 -> 恢复弹窗
-			if (options.studyWithCatalgue) {
-				// 展开弹窗
-				nextTick(() => {
-					catalogueRef.value.showPopup({zhangId: infoData.zhangId});
-				}) 
-			}
+			// // 已登录付费未支付选择返回 -> 恢复弹窗
+			// if (options.studyWithCatalgue) {
+			// 	// 展开弹窗
+			// 	nextTick(() => {
+			// 		catalogueRef.value.showPopup({zhangId: infoData.zhangId});
+			// 	}) 
+			// }
 		} else {
 			zhangId.value = options.zhangId
 			nianji.value = options.nianji
@@ -223,15 +225,14 @@
 	}
 
 	function getZhangInfo(data) {
-		let req = {
-			nianji: selectZhang.value.nianji,
-			cardId: selectZhang.value.cardId,
-			zhangId: selectZhang.value.zhangId,
+		let req = {
+			levelId:1
 		}
 		userZhangInfo(req).then(res => {
 			cacheManager.set('zhangInfo', res.data)
-			let zhang = cacheManager.get('zhangInfo').zhangList.findIndex(zhang => zhang.zhangId == selectZhang
-				.value.zhangId);
+			let zhang = cacheManager.get('zhangInfo').zhangList.findIndex(zhang => zhang.zhangId == localAuth
+				.value.zhangId);
+				console.log('zhang',zhang);
 			if (zhang != -1) {
 				cacheManager.updateObject('auth', {
 					currentZhang: zhang
@@ -271,10 +272,10 @@
 
 	function recordZhangJie() {
 		let req = {
-			nianji: selectZhang.value.nianji,
+			levelId: levelId.value,
 			userId: cacheManager.get('auth').userId,
 			zhangId: infoData.zhangId,
-			cardId: selectZhang.value.cardId,
+			subjectId: currentProduct.value
 
 		}
 		userLocate(req).then(res => {
@@ -290,7 +291,6 @@
 
 	function handleChangeZhang(data) {
 		console.log(data);
-		selectZhang.value = data;
 		const authCode = getUserIdentity();
 		if (authCode !== 'Visitor') {
 			cacheManager.updateObject('auth', {
@@ -333,30 +333,31 @@
 			})
 		} else {
 			uni.redirectTo({
-				url: '/pages/study/lookShipin?jieId=' + data.jieId
+			url: '/pages/study/lookShipin?jieId=' + data.jieId + '&levelId=' + 7 + '&typeId=' + 2 + '&subjectId=' + 1
 			})
 		}
 	}
 
 	function translateData(data) {
-		gradeTerm.value = termMapping[data.cardId] +' · '+ gradeMapping[data.nianji]
+	//	gradeTerm.value = termMapping[data.subjectId] +' · '+ data.levelName
+		gradeTerm.value = data.levelName
 	}
 
 	function listClick(data,data2,index) {
-		//debugger
-		console.log('data',data);
-		console.log('data2',data2);
-		if ((!cacheManager.get('auth') && data2.number != 1)||(!cacheManager.get('auth') && data.type == 2) ) {
+		console.log('data',data);// 节内容
+		console.log('data2',data2); //章内容
+		if (!cacheManager.get('auth') ) {
 			youkeDialogRef.value.handleShow();
 			return;
 		}
 		const authCode = getUserIdentity();
 		console.log('authCode', authCode);
-		if (!(authCode == 'VIP' || data2.number == 1)) {
+		if (!(authCode == 'VIP' || data.firstFlag == 1)) {
 		//	debugger
 			goPayDialogRef.value.handleShow();
 			return false
-		}
+		}
+		return
 		if (data.type == 2) {
 			// 最后一项
 			goKaoshi(data,index)

+ 4 - 5
pages/study/product/shuxue.vue

@@ -24,10 +24,9 @@
 					</view>
 					<view v-if="isVip == 'Not-Vip'">
 						<!-- 序号或锁 -->
-						<view   class="brand-icon">{{ item.number }}
+						<view v-if="options.number ==1 && item.firstFlag ==1" class="brand-icon">{{ item.number }}
 						</view>
-						<!-- 锁 -->
-						<view   v-if="options.number !='1'" class="brand-lock"></view>
+						<view v-else class="brand-lock"></view>
 						<!-- 箭头 -->
 						<view v-if="item.daeFlag  &&  animalNum == index &&isVip != 'Visitor'" class="brand-arrow">
 						</view>
@@ -173,9 +172,9 @@
 		let brandActive = '';
 		if (isVip === 'VIP') {
 			brandActive = 'brand-active';
-		} else if (data.number == 1 && isVip =='Not-Vip') {
+		} else if (data.number == 1&&item.firstFlag==1 && isVip =='Not-Vip') {
 			brandActive = 'brand-active';
-		} else if (data.number == 1 && isVip =='Visitor' &&item.type ==1) {
+		} else if (data.number == 1&&item.firstFlag==1 && isVip =='Visitor' &&item.type ==1) {
 			brandActive = 'brand-active';
 		} else {
 			brandActive = '';

+ 283 - 0
pages/study/product/shuxueNew.vue

@@ -0,0 +1,283 @@
+<template>
+	<view class="ezy-study-page ezy-shuxue-study-page">
+		<view class="study-school-year" @click="clickGradeTerm">{{gradeTerm}}</view>
+		<view class="ezy-study-wrap">
+			<view class="chapter-box" @click="handleCheckCatalogue">{{options.numberStr}}</view>
+			<view @click="handleCheckCatalogue" :class="getTitleClass(options.zhangName)">
+				{{getZhangName(options.zhangName)}}
+			</view>
+			<!-- 动物类型 -->
+			<view v-if="growthType!=null" :class="currentGrowth()"></view>
+			<view>
+				<!-- 小岛 -->
+				<view class="brand-item" v-for="(item, index) in options.jieList" :key="item.jieId"
+					@click="listClick(item, index,options)" :class="getClass(options,index,isVip,item)">
+					<view v-if="isVip === 'VIP'">
+						<!-- 序号 -->
+						<view class="brand-icon" v-if="item.studyFlag===0">{{ item.number }}</view>
+						<!-- 星星 -->
+						<view class="brand-finish-icon" v-if="item.studyFlag===1"></view>
+						<!-- 箭头 -->
+						<view v-if="item.daeFlag &&animalNum == index" class="brand-arrow"></view>
+						<!-- 节名称 -->
+						<view class="brand-content">{{ item.jieName }}</view>
+					</view>
+					<view v-if="isVip == 'Not-Vip'">
+						<!-- 序号或锁 -->
+						<view v-if="options.number ==1 && item.firstFlag ==1" class="brand-icon">{{ item.number }}
+						</view>
+						<view v-else class="brand-lock"></view>
+						<!-- 箭头 -->
+						<view v-if="item.daeFlag  &&  animalNum == index &&isVip != 'Visitor'" class="brand-arrow">
+						</view>
+						<!-- 节名称 -->
+						<view class="brand-content"> {{ item.jieName }} </view>
+					</view>
+					
+					<view v-if="isVip == 'Visitor'">
+						<!-- 序号或锁 -->
+						<view   class="brand-icon">{{ item.number }}
+						</view>
+						<!-- 锁 -->
+						<view  v-if="options.number !='1' || item.type==2"  class="brand-lock"></view>
+						<!-- 箭头 -->
+						<view v-if="item.daeFlag  &&  animalNum == index &&isVip != 'Visitor'" class="brand-arrow">
+						</view>
+						<!-- 节名称 -->
+						<view class="brand-content"> {{ item.jieName }} </view>
+					</view>
+				</view>
+			</view>
+		</view>
+	</view>
+</template>
+
+<script setup>
+	import {
+		reactive,
+		ref,
+		watch,
+		getCurrentInstance,
+		onMounted,
+		nextTick
+	} from "vue";
+	import cacheManager from "@/utils/cacheManager.js";
+	import {
+		toast,
+		getUserIdentity
+	} from "@/utils/common";
+	import {
+		onShow
+	} from '@dcloudio/uni-app';
+	const growthType = ref(null);
+	onShow(() => {
+		growthType.value = cacheManager.get('auth') ? cacheManager.get('auth').growthType : null
+	})
+
+	const $emit = defineEmits(['clickGradeTerm', 'onLeft', 'onRight', 'handleCheckCatalogue', 'listClick'])
+	const props = defineProps({
+		options: {
+			type: Object,
+		},
+		gradeTerm: {
+			type: String,
+		},
+	})
+	const isVip = getUserIdentity();
+	console.log('isVip', isVip);
+	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('');
+	let animalNum = ref(0);
+
+	function clickGradeTerm() {
+		$emit('clickGradeTerm');
+	}
+
+	function listClick(data, index, data2) {
+		data.daeFlag = true
+		nextTick(() => {
+			animalNum.value = index
+		})
+		setTimeout(() => {
+			$emit('listClick', data, data2, index);
+		}, 300)
+
+	}
+	// 获取章name
+	function getZhangName(data) {
+		if (data.length <= 9) {
+			return data
+		} else {
+			return getZhangContent(data);
+		}
+	}
+
+	function currentGrowth(data) {
+		if (growthType.value == 0) {
+			return 'animal-img dan-img'
+		} else if (growthType.value == 1) {
+			return 'animal-img xiao-e-img'
+		} else if (growthType.value == 2) {
+			return 'animal-img zhong-e-img'
+		} else {
+			return 'animal-img da-e-img'
+		}
+	}
+
+	// 章换行显示
+	function getZhangContent(data) {
+
+		let length = data.length;
+		// 初始将字符串平分成两半
+		let halfLength = Math.floor(length / 2);
+
+		// 插入换行符
+		let firstLine = data.slice(0, halfLength);
+		let secondLine = data.slice(halfLength);
+		//console.log(firstLine + '\n' + secondLine, 'firstLine + + secondLine');
+		return firstLine + '\n' + secondLine;
+	}
+
+	// 章class
+	function getTitleClass(data) {
+
+		if (data.length <= 5) {
+			return 'chapter-title-box chapter-small-title-box'
+		} else if (data.length <= 9) {
+			return 'chapter-title-box chapter-middle-title-box'
+		} else if (data.length > 9) {
+			return 'chapter-title-box chapter-big-title-box'
+		}
+	}
+
+	// 获取节class
+	function getClass(data, index, isVip,item) {
+		//	console.log('data',data);
+		let brandActive = '';
+		if (isVip === 'VIP') {
+			brandActive = 'brand-active';
+		} else if (data.number == 1&&item.firstFlag==1 && isVip =='Not-Vip') {
+			brandActive = 'brand-active';
+		} else if (data.number == 1&&item.firstFlag==1 && isVip =='Visitor' &&item.type ==1) {
+			brandActive = 'brand-active';
+		} else {
+			brandActive = '';
+		}
+		let indexLast = data.jieList.length - 1;
+		// 判断最后一个为名称是否为单元测试,是单元测试则返回ceshi-jie
+		if (index === indexLast && data.jieList[data.jieList.length - 1].jieName == '单元测试') {
+			return 'ceshi-brand-item' + ' ' + brandActive;
+		} else {
+			return getJieClass(data, index, brandActive)
+		}
+	}
+	// 根据获取节字数获取class
+	function getJieClass(data, index, active) {
+		let itemJieName = data.jieList[index].jieName.length;
+		if (itemJieName > 7) {
+			return 'big-brand-item' + ' ' + active;
+		} else {
+			return 'small-brand-item' + ' ' + active;
+		}
+	}
+
+
+
+	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');
+		console.log(cacheManager.get('auth'));
+		if (cacheManager.get('auth')) {
+			console.log('啊啊啊啊啊');
+			$emit('onRight');
+		}
+
+	}
+
+	function onTouchEnd(event) {
+		if (isSliding.value) {
+			const distanceX = event.changedTouches[0].clientX - startX.value
+			if (distanceX > 200) {
+				onSwipeLeft();
+			} else if (distanceX < -200) {
+				onSwipeRight();
+			}
+			isSliding.value = false
+		} else {
+			console.log('error');
+		}
+	}
+
+	function dataRecom(data) {
+
+		const index = data.jieList.findIndex(item => item.studyFlag == 0);
+
+		if (index !== -1) {
+			data.jieList[index].daeFlag = true;
+			animalNum.value = index
+		}
+	}
+	watch(() => props.options, (newVal, oldVal) => {
+		//	console.log('New options:', newVal);
+		//	console.log('Old options:', oldVal);
+		// 在这里可以根据新的 options 做一些操作,比如发起请求等
+
+		dataRecom(newVal)
+	}, {
+		deep: true,
+		immediate: true
+	});
+	watch(() => props.gradeTerm, (newVal, oldVal) => {
+		//	console.log('New options:', newVal);
+		//	console.log('Old options:', oldVal);
+		// 在这里可以根据新的 options 做一些操作,比如发起请求等
+		gradeTerm.value = newVal
+
+	}, {
+		deep: true,
+		immediate: true
+	});
+</script>
+
+<style>
+
+</style>

+ 3 - 3
pages/study/product/yingyu.vue

@@ -21,9 +21,9 @@
 					</view>
 					<view v-if="isVip == 'Not-Vip'">
 						<!-- 序号 -->
-						<view  class="brand-icon">{{ item.number }}</view>
-						<!-- 锁 -->
-						<view v-if="options.number !='1'" class="brand-lock"></view>
+						<view v-if="options.number ==1 && item.firstFlag ==1" class="brand-icon">{{ item.number }}
+						</view>
+						<view v-else class="brand-lock"></view>
 						<!-- 箭头 -->
 						<view v-if="item.daeFlag  &&  animalNum == index && isVip != 'Visitor'" class="brand-arrow"></view>
 						<!-- 节名称 -->

+ 3 - 3
utils/common.js

@@ -57,11 +57,11 @@ export function catchError(promise) {
 export function getUserIdentity() {
 	const auth = cacheManager.get('auth');
 	if (auth) {
-		if (auth.cardList.some(item => item == auth.cardId)) {
-			// VIP
+		if ((auth.levelIdList || []).some(item => item == auth.levelId)) {
+			// 购买此levelId
 			return 'VIP'
 		}
-		// 非VIP
+		// 无购买此levelId
 		return 'Not-Vip';
 	} else {
 		// 游客