Selaa lähdekoodia

新增版本上下册选择

wangxy 2 viikkoa sitten
vanhempi
commit
1aecf17f7b
4 muutettua tiedostoa jossa 284 lisäystä ja 13 poistoa
  1. 24 0
      api/selectGradesTerms.js
  2. 7 0
      pages.json
  3. 44 13
      pages/selectGradesTerms/index.vue
  4. 209 0
      pages/selectVersion/selectVersion.vue

+ 24 - 0
api/selectGradesTerms.js

@@ -21,4 +21,28 @@ export function getIndexTree(data = {}) {
         data,
         timeout: 20000
     })
+}
+
+export function getCommonZhangList(data = {}) {
+    return request({
+        'url': '/common/zhang/list',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data,
+        timeout: 20000
+    })
+}
+
+export function getUserZhangList(data = {}) {
+    return request({
+        'url': '/app/user/zhang/list',
+        headers: {
+            isToken: true
+        },
+        method: 'post',
+        data,
+        timeout: 20000
+    })
 }

+ 7 - 0
pages.json

@@ -126,6 +126,13 @@
 			{
 				"navigationStyle": "custom"
 			}
+		},
+		{
+			"path" : "pages/selectVersion/selectVersion",
+			"style" : 
+			{
+				"navigationStyle": "custom"
+			}
 		}
 	],
 	 "tabBar": {

+ 44 - 13
pages/selectGradesTerms/index.vue

@@ -145,21 +145,44 @@
 
 			if (userCode !== 'Visitor') {
 				const auth = cacheManager.get('auth');
-				cacheManager.updateObject('auth', {
-					typeId: typeId,
-					levelId: levelId,
-					subjectId: subjectId,
-					zhangId: data.activeProduct == auth.levelId && data.activeXueke == auth.cardId ? auth.zhangId :
-						0,
-					currentZhang: 0
-				})
-				// 通知岛重新调用接口
-				cacheManager.remove('daoPageCache')
-				uni.redirectTo({
-					url: `/pages/study/index`
-				})
+				if (subjectId == 2) {
+					// 新版英语 需要选择上下册 ---- 上下册更新章数据
+					cacheManager.updateObject('auth', {
+						typeId: typeId,
+						levelId: levelId,
+						subjectId: subjectId,
+					})
+					// 通知岛重新调用接口
+					cacheManager.remove('daoPageCache')
+					uni.redirectTo({
+						url: `/pages/selectVersion/selectVersion`
+					})
+					return;
+				} else {
+					cacheManager.updateObject('auth', {
+						typeId: typeId,
+						levelId: levelId,
+						subjectId: subjectId,
+						zhangId: data.activeProduct == auth.levelId && data.activeXueke == auth.cardId ? auth.zhangId :
+							0,
+						currentZhang: 0
+					})
+					// 通知岛重新调用接口
+					cacheManager.remove('daoPageCache')
+					uni.redirectTo({
+						url: `/pages/study/index`
+					})
+				}
 			} else {
 				if (typeId == 1) {
+					if (subjectId == 2) {
+						// 新版英语 需要选择上下册
+						uni.redirectTo({
+							url: `/pages/selectVersion/selectVersion?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&tipFlag=${data.activeTipFlag}`
+						})
+						return;
+					}
+					
 					// 新岛
 					uni.redirectTo({
 						url: `/pages/study/index?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&tipFlag=${data.activeTipFlag}`
@@ -181,6 +204,14 @@
 				if (!data.activeProduct) {
 					return;
 				}
+				const auth = cacheManager.get('auth');
+				if (auth.subjectId == 2 && auth.typeId == 1) {
+					// 新版英语
+					uni.redirectTo({
+						url: `/selectVersion/selectVersion`
+					})
+					return;
+				}
 				
 				uni.redirectTo({
 					url: `/pages/study/index`

+ 209 - 0
pages/selectVersion/selectVersion.vue

@@ -0,0 +1,209 @@
+<template>
+	<view class="grades-terms-page">
+		<view class="icon-title-navBar-box">
+			<!-- 返回按钮↓ -->
+			<view class="nav-bar-icon" @click="handleBack"></view>
+		</view>
+		<view class="grade-item-box">
+			<view :key="item.id" @click="handleTopBottom(item)" v-for="item in data.allList"
+				:class="['grade-item',{active: item.id == data.shangxiaId}]">{{item.lable}}</view>
+		</view>
+		<scroll-view scroll-y="true" class="subject-body" :scroll-into-view="data.scrollTop">
+			<view class="subject-content-box">
+				<!-- 产品 -->
+				<view v-for="item in list" :key="item.id" :id="`s_${item.id}`" @click="handleSelectVersion(item)"
+					:class="[
+						    'subject-item',
+						    item.typeId === 1 && 'subject-jstx-item',
+						    {
+						      'active': item.id == data.shangxiaVersionId
+						    }
+						  ]">
+					<img :src="item.cover" class="subject-item-img" />
+					<view class="subject-item-text"><text>{{item.lable}}</text></view>
+				</view>
+			</view>
+		</scroll-view>
+		<view class="grade-line"></view>
+		<button class="grade-confirm-btn" @click="handleConfirm"></button>
+	</view>
+</template>
+
+<script setup>
+	import {
+		reactive,
+		toRefs,
+		toRef,
+		computed,
+		nextTick,
+		ref,
+	} from "vue";
+	import * as httpApi from "@/api/selectGradesTerms.js";
+	import {
+		getUserIdentity,
+		findRootNode,
+		findTreeNode
+	} from "@/utils/common.js"
+	import cacheManager from "@/utils/cacheManager.js"
+	import {
+		getCommonTree,
+		getIndexTree
+	} from "../../api/selectGradesTerms";
+	import {
+		onLoad
+	} from "@dcloudio/uni-app";
+
+
+	const data = reactive({
+		scrollTop: '',
+		allList: [],
+		levelId: null,
+		typeId: null,
+		subjectId: null,
+		tipFlag: null,
+		shangxiaId: 1, // 上下册
+		shangxiaVersionId: null, // 当前版本
+	})
+	
+	const list = computed(() => {
+		if (!data.allList.length) {
+			return []
+		}
+		const d_id = data.shangxiaId;
+	
+		return data.allList.find(item => item.id == d_id).children
+	})
+
+	onLoad(({
+		levelId,
+		subjectId,
+		shangxiaId, // 上下册Id
+		shangxiaVersionId, // 上下册版本Id
+		typeId,
+		tipFlag
+	}) => {
+		const userCode = getUserIdentity();
+		if (userCode !== 'Visitor') {
+			initUserProducts();
+		} else {
+			data.levelId = levelId;
+			data.subjectId = subjectId || 1;
+			data.shangxiaId = shangxiaId || 1; // 默认选中上册
+			data.shangxiaVersionId = shangxiaVersionId; // 默认选中上册
+			data.typeId = typeId;
+			data.activeTipFlag = tipFlag || '0';
+			initVisitProducts();
+		}
+	});
+
+	function handleBack() {
+		const userCode = getUserIdentity();
+		if (userCode !== 'Visitor') {
+			if (!data.activeProduct) {
+				return;
+			}
+			const auth = cacheManager.get('auth');
+			uni.redirectTo({
+				url: `/pages/selectGradesTerms/index`
+			})
+		} else {
+			uni.redirectTo({
+				url: `/pages/selectGradesTerms/index?productId=${data.levelId}&xuekeId=${data.subjectId}&tipFlag=${data.tipFlag}`
+			})
+		}
+	}
+
+	function handleTopBottom(item) {
+		data.shangxiaId = item.id;
+		data.shangxiaVersionId = null;
+	}
+
+	function handleSelectVersion(item) {
+		data.shangxiaVersionId = item.id
+	}
+
+
+	function handleConfirm() {
+		if (!data.shangxiaId) {
+			uni.showToast({
+				title: "请选择上下册",
+				duration: 2000,
+				icon: 'error'
+			});
+			return;
+		}
+		if (!data.shangxiaVersionId) {
+			uni.showToast({
+				title: "请选择版本",
+				duration: 2000,
+				icon: 'error'
+			});
+			return;
+		}
+		goDAOToStudy();
+	}
+	
+	// 跳转 岛 学习
+	function goDAOToStudy() {
+		const userCode = getUserIdentity();
+		if (userCode !== 'Visitor') {
+			const auth = cacheManager.get('auth');
+			cacheManager.updateObject('auth', {
+				// 修改上下册+版本字段
+			})
+			// 通知岛重新调用接口
+			cacheManager.remove('daoPageCache')
+			uni.redirectTo({
+				url: `/pages/study/index`
+			})
+		} else {
+			// 新英语岛
+			uni.redirectTo({
+				url: `/pages/study/index?levelId=${data.levelId}&typeId=${data.typeId}&subjectId=${data.subjectId}&tipFlag=${data.activeTipFlag}`
+			})
+		}
+	
+	}
+	
+
+	function initUserProducts() {
+		httpApi.getUserZhangList({
+			levelId: data.levelId
+		}).then(res => {
+			data.allList = res.data || [];
+			const {
+				levelId,
+			} = cacheManager.get('auth');
+			if (levelId) {
+				// LevelId 翻找根节点学科,执行选中高亮操作
+				const obj1 = findRootNode(data.allList, shangxiaId, 'shangxiaId');
+				const obj2 = findTreeNode(data.allList, shangxiaId, 'children', 'shangxiaId');
+				data.shangxiaVersionId = obj2.id;
+				data.shangxiaId = obj1.id;
+
+			} else {
+				data.shangxiaVersionId = null;
+				data.shangxiaId = 1
+			}
+
+			nextTick(() => {
+				// 滚动到某个元素显示
+				data.scrollTop = `s_${data.shangxiaVersionId}`
+			})
+		})
+	}
+
+	function initVisitProducts() {
+		httpApi.getCommonZhangList({
+			levelId: data.levelId
+		}).then(res => {
+			data.allList = res.data || [];
+		})
+	}
+
+
+</script>
+
+<style>
+
+</style>