123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <view class="ezy-study-page">
- <shuxueZhangjie @clickGradeTerm="clickGradeTerm" @onLeft="onLeft" @onRight="onRight"
- @handleCheckCatalogue="handleCheckCatalogue" :options="infoData">
- </shuxueZhangjie>
- <!-- 蛋 -->
- <egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
- <catalogue ref="catalogueRef" @change-zhang="handleChangeZhang"></catalogue>
- <CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
- </view>
- </template>
- <script setup>
- import {
- userZhangInfo,
- userLocate,
- userZhangForntInfo,
- userZhangNextInfo,
- getCommonZhangInfo
- } from "@/api/learnPlan.js"
- import {
- reactive,
- ref,
- getCurrentInstance,
- onMounted
- } from "vue";
- import {
- 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 {
- useTabBarHistory
- } from '@/utils/emitEvents.js';
- import eggDialog from './eggDialog.vue'
- import {
- toast,getUserIdentity
- } from "@/utils/common";
- import cacheManager from "@/utils/cacheManager.js";
- const eggDialogRef = 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({
- jieList: [],
- haveFlag: '',
- nianji: '',
- number: '',
- cardId: '',
- zhangId: '',
- zhangName: '',
- numberStr: '',
- });
- onLoad((options) => {
- // 获取路由参数
- if(options){
- zhangId.value = options.zhangId
- nianji.value = options.nianji
- cardId.value = options.cardId
- }
-
- init(options)
- })
- function init(options){
- if (cacheManager.get('auth')) {
- //会员 取auth
- selectZhang.value = cacheManager.get('auth');
- console.log(selectZhang.value);
- // 已登录
- // 选择年级进入调用此接口
- //options.flag == 'selectGrades'
- getZhangInfo()
- // 蛋
- // eggDialogRef.value.eggShow();
- } else {
- console.log(options);
- // 未登录 游客
- getCommonZhang(options)
-
- }
- }
-
- function getZhangInfo(data) {
- let req = {
- nianji: selectZhang.value.nianji,
- cardId: selectZhang.value.cardId,
- zhangId: selectZhang.value.zhangId,
- }
- userZhangInfo(req).then(res => {
- cacheManager.set('zhangInfo', res.data)
- infoData.jieList = res.data.jieList
- infoData.haveFlag = res.data.haveFlag
- infoData.nianji = res.data.nianji
- infoData.number = res.data.number
- infoData.numberStr = res.data.numberStr
- infoData.cardId = res.data.cardId
- infoData.zhangId = res.data.zhangId
- infoData.zhangName = res.data.zhangName
- recordZhangJie()
- getNewData()
- // if (cacheManager.get('zhangInfo')) {
- // cacheManager.remove('zhangInfo')
- // cacheManager.set('zhangInfo', res.data)
- // } else {
- // cacheManager.set('zhangInfo', res.data)
- // }
- })
- }
- function getCommonZhang(data) {
-
- let req = {
- nianji: data.nianji,
- cardId: data.cardId,
- zhangId:data.zhangId,
- }
- getCommonZhangInfo(req).then(res => {
- infoData.jieList = res.data.jieList
- infoData.haveFlag = res.data.haveFlag
- infoData.nianji = res.data.nianji
- infoData.number = res.data.number
- infoData.numberStr = res.data.numberStr
- infoData.cardId = res.data.cardId
- infoData.zhangId = res.data.zhangId
- infoData.zhangName = res.data.zhangName
- //getNewData()
- })
- }
- function onLeft(event) {
- console.log('用户左滑了');
- let req = {
- nianji: selectZhang.value.nianji,
- zhangId: selectZhang.value.zhangId,
- cardId: selectZhang.value.cardId,
- }
- userZhangForntInfo(req).then(res => {
- cacheManager.set('zhangInfo', res.data)
- infoData.jieList = res.data.jieList
- infoData.haveFlag = res.data.haveFlag
- infoData.nianji = res.data.nianji
- infoData.number = res.data.number
- infoData.numberStr = res.data.numberStr
- infoData.cardId = res.data.cardId
- infoData.zhangId = res.data.zhangId
- infoData.zhangName = res.data.zhangName
- recordZhangJie()
- getNewData()
- })
- }
- function onRight(event) {
- console.log('用户又滑了');
- let req = {
- nianji: selectZhang.value.nianji,
- zhangId: selectZhang.value.zhangId,
- cardId: selectZhang.value.cardId,
- }
- userZhangNextInfo(req).then(res => {
- cacheManager.set('zhangInfo', res.data)
- infoData.jieList = res.data.jieList
- infoData.haveFlag = res.data.haveFlag
- infoData.nianji = res.data.nianji
- infoData.number = res.data.number
- infoData.numberStr = res.data.numberStr
- infoData.cardId = res.data.cardId
- infoData.zhangId = res.data.zhangId
- infoData.zhangName = res.data.zhangName
- recordZhangJie()
- getNewData()
- })
- }
- function getNewData() {
- selectZhang.value.zhangId = cacheManager.get('zhangInfo').zhangId;
- selectZhang.value.cardId = cacheManager.get('zhangInfo').cardId;
- selectZhang.value.nianji = cacheManager.get('zhangInfo').nianji;
- }
- function recordZhangJie() {
- let req = {
- nianji: selectZhang.value.nianji,
- userId: cacheManager.get('auth').userId,
- zhangId: infoData.zhangId,
- cardId: selectZhang.value.cardId,
- }
- userLocate(req).then(res => {
- })
- }
- function handleChangeZhang(data) {
- selectZhang.value = data;
- const authCode = getUserIdentity();
- if (authCode !== 'Visitor') {
- cacheManager.updateObject('auth', {
- zhangId: data.zhangId
- })
- }
- init()
- }
- function goKaoshi(data) {
- let zhangId = selectZhang.value ? selectZhang.value.zhangId : infoData.zhangId;
- let nianji = selectZhang.value.nianji;
- let cardId = selectZhang.value.cardId;
- uni.navigateTo({
- url: `/pages/unitTest/index?jieId=${data.jieId}&zhangId=${zhangId}&nianji=${nianji}&cardId=${cardId}`
- })
- }
- function goLookShipin(data) {
- data.progressMarkers = [{
- offset: 30,
- isCustomized: true,
- coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
- title: '变式1',
- time: '00:00:30',
- describe: 'test string',
- }, {
- offset: 120,
- isCustomized: true,
- coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
- title: '变式2',
- time: '00:02:00',
- describe: 'test string',
- }, {
- offset: 300,
- isCustomized: true,
- coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
- title: '变式3',
- time: '00:05:00',
- describe: 'test string',
- }]
- data.zhangId = infoData.zhangId
- data.nianji = infoData.nianji
- data.cardId = infoData.cardId
- uni.navigateTo({
- //url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
- url: '/pages/study/lookShipin?studyData=' + JSON.stringify(data)
- })
- }
- function listClick(data, index) {
- if (!cacheManager.get('auth')) {
- toast("当前为游客模式请登录!")
- uni.redirectTo({
- url: '/pages/login/index'
- })
- return;
- }
- // if(index !=0&&data.jieId!=79){
- // toast("付费章节!")
- // return false
- // }
- if (!data.vipFlag) {
- toast("付费章节!")
- return false
- }
- if (index == infoData.jieList.length - 1) {
- // 最后一项
- goKaoshi(data)
- } else {
- goLookShipin(data)
- }
- }
- function handleCheckCatalogue() {
- catalogueRef.value.showPopup();
- }
- function clickGradeTerm() {
- uni.navigateTo({
- url: `/pages/selectGradesTerms/index`,
- })
- }
- function eggBtn() {
- console.log('点击:开启提分之旅');
- }
- </script>
- <style>
- </style>
|