123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view class="grades-terms-page">
- <view class="icon-title-navBar-box">
- <!-- 返回按钮↓ -->
- <view class="nav-bar-icon" @click="handleBack"></view>
- </view>
- <view class="grades-body">
- <view class="grades-change-title"></view>
- <text class="grades-title-desc">我们会根据您选择,为您匹配对应的学习内容</text>
- <view class="grades-terms-title terms-title-img"></view>
- <view class="grade-item-box">
- <view v-for="item in xueke_list" :key="item.id" @click="handleSelectXueke(item)"
- :class="['grade-item',{active: item.id == activeXueke}]">{{item.label}}</view>
- </view>
- <view class="grades-terms-title grades-title-img"></view>
- <view class="grade-item-box" v-if="activeXueke != 2">
- <!-- 数学 -->
- <view v-for="item in nianji_list" :key="item.id" @click="handleSelectGrade(item)"
- :class="['grade-item', {active: item.id == activeNianji}]">{{item.label}}</view>
- </view>
- <view class="grade-item-box" v-else>
- <!-- 英语 -->
- <template v-for="item in nianji_list" :key="item.id">
- <view @click="handleSelectGrade(item)" v-if="item.id != 6"
- :class="['grade-item', {active: item.id == activeNianji}]">{{item.label}}</view>
- <view v-else class="grade-yingyu-item"></view>
- </template>
- </view>
- <view class="grade-line"></view>
- <button class="grade-confirm-btn" @click="handleConfirm"></button>
- </view>
- <coming-soon-dialog ref="comingSoonDialogRef"></coming-soon-dialog>
- </view>
- </template>
- <script setup>
- import comingSoonDialog from './comingSoonDialog.vue';
- import {
- reactive,
- toRefs,
- ref,
- } from "vue";
- import {
- nianji_list,
- xueke_list,
- } from "@/utils/constant.js";
- import {
- onLoad
- } from "@dcloudio/uni-app";
- import {
- getUserIdentity
- } from "@/utils/common.js"
- import cacheManager from "@/utils/cacheManager.js"
- import {
- getCardOnline
- } from "../../api/catalogue";
- const comingSoonDialogRef = ref(null);
- function useSelectGrade() {
- const userCode = getUserIdentity();
- const data = reactive({
- activeNianji: null, // 当前年级
- activeXueke: null, // 当前学期
- activeTipFlag: null, // 当前学期
- });
- onLoad(({
- nianji,
- cardId,
- tipFlag
- }) => {
- if (userCode !== 'Visitor') {
- const {
- nianji: nianji_,
- cardId: cardId_
- } = cacheManager.get('auth');
- data.activeNianji = nianji_;
- data.activeXueke = cardId_;
- } else {
- data.activeNianji = nianji;
- data.activeXueke = cardId;
- data.activeTipFlag = tipFlag || '0';
- }
- });
- // 选择 年级+学期
- function handleConfirm() {
- if (!data.activeXueke) {
- uni.showToast({
- title: "请选择课程类别",
- duration: 2000,
- icon: 'error'
- });
- return;
- }
- if (!data.activeNianji) {
- uni.showToast({
- title: "请选择课程等级",
- duration: 2000,
- icon: 'error'
- });
- return;
- }
- getCardOnline({
- cardId: data.activeXueke,
- nianji: data.activeNianji
- }).then(res => {
- if (res.data) {
- goDAOToStudy();
- } else {
- comingSoonDialogRef.value.handleShow();
- }
- })
- }
- // 跳转 岛 学习
- function goDAOToStudy() {
- if (userCode !== 'Visitor') {
- const auth = cacheManager.get('auth');
- cacheManager.updateObject('auth', {
- typeId: typeId,
- levelId: levelId,
- subjectId: subjectId, // 此处subjectId 独立加入缓存,单独维护,勿动 @date 2025/05/14
- zhangId: data.activeProduct == auth.nianji && data.activeXueke == auth.cardId ? auth.zhangId :
- 0,
- currentZhang: 0
- })
- cacheManager.remove('daoPageCache')
- // 数序
- uni.redirectTo({
- url: `/pages/study/index`
- })
- } else {
- // 数序
- uni.redirectTo({
- url: `/pages/study/index?nianji=${data.activeNianji}&cardId=${data.activeXueke}&zhangId=0&tipFlag=${data.activeTipFlag}`
- })
- }
- }
- function handleBack() {
- if (userCode !== 'Visitor') {
- uni.redirectTo({
- url: `/pages/study/index`
- })
- } else {
- uni.redirectTo({
- url: '/pages/login/index'
- })
- }
- }
- return {
- ...toRefs(data),
- handleBack,
- // 方法
- handleConfirm, // 选择年级+学科
- };
- }
- const {
- activeNianji,
- activeXueke,
- handleConfirm,
- handleBack
- } = useSelectGrade()
- function handleSelectGrade(item) {
- activeNianji.value = item.id;
- }
- function handleSelectXueke(item) {
- activeXueke.value = item.id;
- }
- </script>
|