|
@@ -2,21 +2,21 @@
|
|
<view class="grades-terms-page">
|
|
<view class="grades-terms-page">
|
|
<view class="icon-title-navBar-box">
|
|
<view class="icon-title-navBar-box">
|
|
<!-- 返回按钮↓ -->
|
|
<!-- 返回按钮↓ -->
|
|
- <view class="nav-bar-icon" @click="handleBack"></view>
|
|
|
|
|
|
+ <view class="nav-bar-icon" @click="handleBack"></view>
|
|
</view>
|
|
</view>
|
|
<view class="grade-item-box">
|
|
<view class="grade-item-box">
|
|
<view :key="xueke.id" @click="handleSelectXueke(xueke)" v-for="xueke in xuekeData"
|
|
<view :key="xueke.id" @click="handleSelectXueke(xueke)" v-for="xueke in xuekeData"
|
|
- :class="['grade-item',{active: xueke.id == activeXueke}]">{{xueke.lable}}</view>
|
|
|
|
|
|
+ :class="['grade-item',{active: xueke.id == activeXueke}]">{{xueke.lable}}</view>
|
|
</view>
|
|
</view>
|
|
<view class="subject-body">
|
|
<view class="subject-body">
|
|
<view class="subject-content-box">
|
|
<view class="subject-content-box">
|
|
<!-- 产品 -->
|
|
<!-- 产品 -->
|
|
<view v-for="item in xuekeList" :key="item.id" @click="handleSelectGrade(item)"
|
|
<view v-for="item in xuekeList" :key="item.id" @click="handleSelectGrade(item)"
|
|
- :class="['subject-item', {active: item.id == activeProduct}]">
|
|
|
|
- <view class="subject-item-border">
|
|
|
|
- <img :src="item.cover" class="subject-item-img"/>
|
|
|
|
- <view class="subject-item-text">{{item.lable}}</view>
|
|
|
|
- </view>
|
|
|
|
|
|
+ :class="['subject-item', {active: item.id == activeProduct}]">
|
|
|
|
+ <view class="subject-item-border">
|
|
|
|
+ <img :src="item.cover" class="subject-item-img" />
|
|
|
|
+ <view class="subject-item-text">{{item.lable}}</view>
|
|
|
|
+ </view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
@@ -26,66 +26,76 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
<script setup>
|
|
-
|
|
|
|
import {
|
|
import {
|
|
reactive,
|
|
reactive,
|
|
toRefs,
|
|
toRefs,
|
|
- computed
|
|
|
|
|
|
+ computed
|
|
} from "vue";
|
|
} from "vue";
|
|
- import * as httpApi from "@/api/selectGradesTerms.js";
|
|
|
|
|
|
+ import * as httpApi from "@/api/selectGradesTerms.js";
|
|
import {
|
|
import {
|
|
onLoad
|
|
onLoad
|
|
} from "@dcloudio/uni-app";
|
|
} from "@dcloudio/uni-app";
|
|
- import {getUserIdentity,findRootNode,findTreeNode} from "@/utils/common.js"
|
|
|
|
|
|
+ import {
|
|
|
|
+ getUserIdentity,
|
|
|
|
+ findRootNode,
|
|
|
|
+ findTreeNode
|
|
|
|
+ } from "@/utils/common.js"
|
|
import cacheManager from "@/utils/cacheManager.js"
|
|
import cacheManager from "@/utils/cacheManager.js"
|
|
- import {getCommonTree, getIndexTree} from "../../api/selectGradesTerms";
|
|
|
|
|
|
+ import {
|
|
|
|
+ getCommonTree,
|
|
|
|
+ getIndexTree
|
|
|
|
+ } from "../../api/selectGradesTerms";
|
|
|
|
|
|
function useSelectGrade() {
|
|
function useSelectGrade() {
|
|
const userCode = getUserIdentity();
|
|
const userCode = getUserIdentity();
|
|
|
|
|
|
const data = reactive({
|
|
const data = reactive({
|
|
activeProduct: null, // 当前年级
|
|
activeProduct: null, // 当前年级
|
|
- activeXueke: null, // 当前学期
|
|
|
|
|
|
+ activeXueke: 1, // 当前学期
|
|
activeTipFlag: null, // 当前学期
|
|
activeTipFlag: null, // 当前学期
|
|
- xuekeData: [], // 学科总数据
|
|
|
|
|
|
+ xuekeData: [], // 学科总数据
|
|
});
|
|
});
|
|
|
|
|
|
- onLoad(({productId,xuekeId,tipFlag}) => {
|
|
|
|
|
|
+ onLoad(({
|
|
|
|
+ productId,
|
|
|
|
+ xuekeId,
|
|
|
|
+ tipFlag
|
|
|
|
+ }) => {
|
|
if (userCode !== 'Visitor') {
|
|
if (userCode !== 'Visitor') {
|
|
- initUserProducts();
|
|
|
|
|
|
+ initUserProducts();
|
|
} else {
|
|
} else {
|
|
- data.activeProduct = productId;
|
|
|
|
- data.activeXueke = xuekeId;
|
|
|
|
- data.activeTipFlag = tipFlag || '0';
|
|
|
|
- initVisitProducts();
|
|
|
|
|
|
+ data.activeProduct = productId;
|
|
|
|
+ data.activeXueke = xuekeId;
|
|
|
|
+ data.activeTipFlag = tipFlag || '0';
|
|
|
|
+ initVisitProducts();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- // 初始化游客产品数据
|
|
|
|
- function initVisitProducts() {
|
|
|
|
- httpApi.getCommonTree().then(res => {
|
|
|
|
- data.xuekeData = res.data||[];
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function initUserProducts() {
|
|
|
|
- httpApi.getIndexTree().then(res => {
|
|
|
|
- data.xuekeData = res.data||[];
|
|
|
|
- const {
|
|
|
|
- levelId,
|
|
|
|
- } = cacheManager.get('auth');
|
|
|
|
- if (levelId) {
|
|
|
|
- // LevelId 翻找根节点学科,执行选中高亮操作
|
|
|
|
- const xuekeObj = findRootNode(data.xuekeData, levelId,'levelId');
|
|
|
|
- const productObj = findTreeNode(data.xuekeData, levelId,'levelId');
|
|
|
|
- data.activeProduct = productObj.id;
|
|
|
|
- data.activeXueke = xuekeObj.id;
|
|
|
|
- } else {
|
|
|
|
- data.activeProduct = null;
|
|
|
|
- data.activeXueke = null
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ // 初始化游客产品数据
|
|
|
|
+ function initVisitProducts() {
|
|
|
|
+ httpApi.getCommonTree().then(res => {
|
|
|
|
+ data.xuekeData = res.data || [];
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ function initUserProducts() {
|
|
|
|
+ httpApi.getIndexTree().then(res => {
|
|
|
|
+ data.xuekeData = res.data || [];
|
|
|
|
+ const {
|
|
|
|
+ levelId,
|
|
|
|
+ } = cacheManager.get('auth');
|
|
|
|
+ if (levelId) {
|
|
|
|
+ // LevelId 翻找根节点学科,执行选中高亮操作
|
|
|
|
+ const xuekeObj = findRootNode(data.xuekeData, levelId, 'levelId');
|
|
|
|
+ const productObj = findTreeNode(data.xuekeData, levelId, 'children','levelId');
|
|
|
|
+ data.activeProduct = productObj.id;
|
|
|
|
+ data.activeXueke = xuekeObj.id;
|
|
|
|
+ } else {
|
|
|
|
+ data.activeProduct = null;
|
|
|
|
+ data.activeXueke = null
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
// 选择 年级+学期
|
|
// 选择 年级+学期
|
|
function handleConfirm() {
|
|
function handleConfirm() {
|
|
@@ -105,53 +115,60 @@
|
|
});
|
|
});
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- goDAOToStudy();
|
|
|
|
|
|
+ goDAOToStudy();
|
|
}
|
|
}
|
|
|
|
|
|
// 跳转 岛 学习
|
|
// 跳转 岛 学习
|
|
function goDAOToStudy() {
|
|
function goDAOToStudy() {
|
|
- const Product = data.xuekeData.find(item => item.id == data.activeXueke).children.find(item => item.id == data.activeProduct)
|
|
|
|
- const levelId = Product.levelId;
|
|
|
|
- const typeId = Product.typeId;
|
|
|
|
- const subjectId = Product.subjectId;
|
|
|
|
|
|
+ const Product = data.xuekeData.find(item => item.id == data.activeXueke).children.find(item => item.id == data
|
|
|
|
+ .activeProduct)
|
|
|
|
+ const levelId = Product.levelId;
|
|
|
|
+ const typeId = Product.typeId;
|
|
|
|
+ const subjectId = Product.subjectId;
|
|
|
|
|
|
if (userCode !== 'Visitor') {
|
|
if (userCode !== 'Visitor') {
|
|
const auth = cacheManager.get('auth');
|
|
const auth = cacheManager.get('auth');
|
|
cacheManager.updateObject('auth', {
|
|
cacheManager.updateObject('auth', {
|
|
- typeId: typeId,
|
|
|
|
- levelId: levelId,
|
|
|
|
- subjectId: subjectId,
|
|
|
|
- zhangId: data.activeProduct == auth.nianji && data.activeXueke == auth.cardId ? auth.zhangId: 0,
|
|
|
|
- currentZhang: 0
|
|
|
|
|
|
+ typeId: typeId,
|
|
|
|
+ levelId: levelId,
|
|
|
|
+ subjectId: subjectId,
|
|
|
|
+ zhangId: data.activeProduct == auth.nianji && data.activeXueke == auth.cardId ? auth.zhangId :
|
|
|
|
+ 0,
|
|
|
|
+ currentZhang: 0
|
|
})
|
|
})
|
|
cacheManager.remove('daoPageCache')
|
|
cacheManager.remove('daoPageCache')
|
|
uni.redirectTo({
|
|
uni.redirectTo({
|
|
url: `/pages/study/index`
|
|
url: `/pages/study/index`
|
|
})
|
|
})
|
|
} else {
|
|
} else {
|
|
- if (typeId == 1) {
|
|
|
|
- // 新岛
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: `/pages/study/index?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&tipFlag=${data.activeTipFlag}`
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- // 旧岛
|
|
|
|
- uni.redirectTo({
|
|
|
|
- url: `/pages/study/index?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&zhangId=0&tipFlag=${data.activeTipFlag}`
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ if (typeId == 1) {
|
|
|
|
+ // 新岛
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: `/pages/study/index?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&tipFlag=${data.activeTipFlag}`
|
|
|
|
+ })
|
|
|
|
+ } else {
|
|
|
|
+ // 旧岛
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: `/pages/study/index?levelId=${levelId}&typeId=${typeId}&subjectId=${subjectId}&zhangId=0&tipFlag=${data.activeTipFlag}`
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
function handleBack() {
|
|
function handleBack() {
|
|
if (userCode !== 'Visitor') {
|
|
if (userCode !== 'Visitor') {
|
|
- uni.redirectTo({ url: `/pages/study/index`})
|
|
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: `/pages/study/index`
|
|
|
|
+ })
|
|
} else {
|
|
} else {
|
|
- uni.redirectTo({url: '/pages/login/index'})
|
|
|
|
|
|
+ uni.redirectTo({
|
|
|
|
+ url: '/pages/login/index'
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
return {
|
|
return {
|
|
...toRefs(data),
|
|
...toRefs(data),
|
|
handleBack,
|
|
handleBack,
|
|
@@ -163,28 +180,26 @@
|
|
const {
|
|
const {
|
|
activeProduct,
|
|
activeProduct,
|
|
activeXueke,
|
|
activeXueke,
|
|
- xuekeData,
|
|
|
|
|
|
+ xuekeData,
|
|
handleConfirm,
|
|
handleConfirm,
|
|
handleBack
|
|
handleBack
|
|
} = useSelectGrade()
|
|
} = useSelectGrade()
|
|
|
|
|
|
- const xuekeList = computed(() => {
|
|
|
|
|
|
+ const xuekeList = computed(() => {
|
|
|
|
|
|
- if (!xuekeData.value.length) {
|
|
|
|
- return []
|
|
|
|
- }
|
|
|
|
- const d_id = activeXueke.value || xuekeData.value[0].id;
|
|
|
|
- return xuekeData.value.find(item => item.id == d_id).children
|
|
|
|
- })
|
|
|
|
|
|
+ if (!xuekeData.value.length) {
|
|
|
|
+ return []
|
|
|
|
+ }
|
|
|
|
+ const d_id = activeXueke.value;
|
|
|
|
+ return xuekeData.value.find(item => item.id == d_id).children
|
|
|
|
+ })
|
|
|
|
|
|
- function handleSelectGrade(item) {
|
|
|
|
|
|
+ function handleSelectGrade(item) {
|
|
activeProduct.value = item.id;
|
|
activeProduct.value = item.id;
|
|
}
|
|
}
|
|
|
|
|
|
function handleSelectXueke(item) {
|
|
function handleSelectXueke(item) {
|
|
activeXueke.value = item.id;
|
|
activeXueke.value = item.id;
|
|
- activeProduct.value = null;
|
|
|
|
|
|
+ activeProduct.value = null;
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
</script>
|
|
</script>
|