index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. <template>
  2. <view>
  3. <swiper :circular="true" @change="onChangeTab" :duration="currentDuration" :current="current"
  4. class="ezy-study-swiper" :class="'ezy-study-swiper'+ currentProduct">
  5. <swiper-item v-for="(item,index) in zhangList" :key="index">
  6. <!-- 旧的数学 -->
  7. <shuxueZhangjie v-if="currentProduct ==1&&typeId==2" @clickGradeTerm="clickGradeTerm"
  8. @handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
  9. :options="item" :youkeImage="youkeImage">
  10. </shuxueZhangjie>
  11. <!-- 旧的英语 -->
  12. <yingyuZhangjie v-if="currentProduct ==2&&typeId==2" @clickGradeTerm="clickGradeTerm"
  13. @handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
  14. :options="item" :youkeImage="youkeImage">
  15. </yingyuZhangjie>
  16. <!-- 新的数学 -->
  17. <shuxueNewZhangjie v-if="currentProduct ==1&&typeId==1" @clickGradeTerm="clickGradeTerm"
  18. @handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
  19. :options="item" :youkeImage="youkeImage">
  20. </shuxueNewZhangjie>
  21. <!-- 新的英语(人教版等等) -->
  22. <yingyuNewZhangjie v-if="currentProduct ==2&&typeId==1" @clickGradeTerm="clickGradeTerm"
  23. @handleCheckCatalogue="handleCheckCatalogue(item)" @listClick="listClick" :gradeTerm='gradeTerm'
  24. :options="item" :zhangName="zhangName" :youkeImage="youkeImage" :youkeImageBook="youkeImageBook">
  25. </yingyuNewZhangjie>
  26. </swiper-item>
  27. </swiper>
  28. <!-- 蛋 -->
  29. <egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
  30. <catalogue ref="catalogueRef" :list=zhangList @change-zhang="handleChangeZhang"
  31. @listSelectJieClick="listSelectJieClick"></catalogue>
  32. <CustomTabBar :levelId="levelId" :currentTabNumber="0" :subjectId="subjectId" :typeId="typeId"
  33. :tipFlag="tipFlag">
  34. </CustomTabBar>
  35. <tip-small-dialog ref="goPayDialogRef" @confirm-btn="goPayPage" :content="tipContent"></tip-small-dialog>
  36. <tip-big-dialog ref="youkeDialogRef" @confirm-btn="ykConfirm" :imgShow="true"></tip-big-dialog>
  37. <dao-tip-dialog ref="daoTipDialogRef" v-if="showDaoTip" :productTip="productTipImg"
  38. @dao-tip-close="daoTipClose"></dao-tip-dialog>
  39. <tipMiddleDialog ref="tipDialogRef" :closeFlag='false' @confirm-btn="BanbenConfirmBtn" :title="tipTitle"
  40. :content="tipContentVersion"></tipMiddleDialog>
  41. <tip-dialog ref="tipDialogRef2" :closeFlag='false' :title="tipTitle"
  42. :content="tipContentVersionAndroid"></tip-dialog>
  43. </view>
  44. </template>
  45. <script setup>
  46. import daoTipDialog from './daoTipDialog.vue';
  47. import {
  48. userZhangInfo,
  49. userLocate,
  50. userZhangForntInfo,
  51. userZhangNextInfo,
  52. getCommonZhangInfo
  53. } from "@/api/learnPlan.js"
  54. import {
  55. getVersion
  56. } from "@/api/login.js"
  57. import {
  58. getWordListYk,
  59. getWordList,
  60. wordXuewan
  61. } from "@/api/word.js"
  62. import {
  63. reactive,
  64. ref,
  65. nextTick,
  66. getCurrentInstance,
  67. onMounted,
  68. computed
  69. } from "vue";
  70. import {
  71. onLoad
  72. } from '@dcloudio/uni-app';
  73. import catalogue from "@/components/catalogue/catalogue.vue";
  74. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  75. import tipSmallDialog from '@/components/dialog/tipSmallDialog.vue'
  76. import tipBigDialog from '@/components/dialog/tipBigDialog.vue';
  77. import tipMiddleDialog from '@/components/dialog/tipMiddleDialog.vue';
  78. import dSwiper from '@/components/wSwiper/DSwiper.vue';
  79. import shuxueZhangjie from './product/shuxue.vue';
  80. import shuxueNewZhangjie from './product/shuxueNew.vue';
  81. import yingyuZhangjie from './product/yingyu.vue';
  82. import yingyuNewZhangjie from './product/yingyuNew.vue';
  83. import {
  84. useTabBarHistory
  85. } from '@/utils/emitEvents.js';
  86. import eggDialog from './eggDialog.vue'
  87. import tipDialog from '@/components/dialog/tipDialog.vue';
  88. import config from '../../config.js'
  89. import {
  90. toast,
  91. getUserIdentity
  92. } from "@/utils/common";
  93. import cacheManager from "@/utils/cacheManager.js";
  94. import TipDialog from "../../components/dialog/tipDialog";
  95. const tipContent = '是否前往开通付费?'; //当前产品
  96. const goPayDialogRef = ref(null);
  97. const youkeDialogRef = ref(null);
  98. const dSwiperRef = ref(null);
  99. const eggDialogRef = ref(null);
  100. const current = ref(0);
  101. const zid = ref(0);
  102. const currentDuration = ref(500)
  103. const YouKeContent = '您当前的身份是游客,想要体验完整内容需注册成用户!';
  104. const tipFlag = ref(null) //游客使用
  105. const catalogueRef = ref(null);
  106. const youkeImage = ref(null);
  107. const youkeImageBook = ref(null);
  108. const currentProduct = ref(null);
  109. const localAuth = ref(null);
  110. const levelId = ref(null); //游客使用
  111. const subjectId = ref(null); //游客使用
  112. const youkeZhangId = ref(null); //游客使用
  113. const zhangName = ref(null);
  114. const typeId = ref(null);
  115. const zhangList = ref(null);
  116. const gradeTerm = ref(null);
  117. let infoData = reactive({
  118. jieList: [],
  119. haveFlag: '',
  120. number: '',
  121. zhangId: '',
  122. zhangName: '',
  123. numberStr: '',
  124. });
  125. const termMapping = {
  126. 1: ' 数学',
  127. 2: ' 英语'
  128. };
  129. const daoTipDialogRef = ref(null);
  130. const showDaoTip = ref(true);
  131. const productTipImg = ref('');
  132. const version = config.appInfo.version;
  133. const tipDialogRef = ref(null);
  134. const tipDialogRef2 = ref(null);
  135. const tipTitle = '升级提醒';
  136. const tipContentVersion = '您的APP不是最新版本,部分功能不能使用,请升级至最新版本!';
  137. const tipContentVersionAndroid = '您的APP不是最新版本,部分功能不能使用,请到应用商店升级至最新版本!'
  138. onLoad((options) => {
  139. init(options);
  140. getLoginInit()
  141. })
  142. function listSelectJieClick(item, data, index) {
  143. if (cacheManager.get('auth')) {
  144. cacheManager.updateObject('auth', {
  145. currentZhang: zhangList.value.findIndex(citem => citem.zhangId == item.zhangId),
  146. zhangId: item.zhangId
  147. })
  148. }
  149. listClick(data, item, index);
  150. }
  151. function BanbenConfirmBtn() {
  152. const systemInfo = uni.getSystemInfoSync();
  153. if (systemInfo.platform == 'ios') {
  154. const appStoreUrl = 'itms-apps://itunes.apple.com/app/6741551741'
  155. plus.runtime.openURL(appStoreUrl)
  156. }
  157. }
  158. function getLoginInit() {
  159. getVersion({}).then(res => {
  160. if (version != res.data.version) {
  161. const systemInfo = uni.getSystemInfoSync();
  162. if (systemInfo.platform == 'ios') {
  163. tipDialogRef.value.handleShow();
  164. } else {
  165. tipDialogRef2.value.handleShow();
  166. }
  167. }
  168. })
  169. }
  170. function getProjectImg() {
  171. if (currentProduct.value == 1 && typeId.value == 2) {
  172. // 数学
  173. productTipImg.value = 'static/images/study/shuxue/shuxue-tip.gif';
  174. getBj('shuxue')
  175. } else if (currentProduct.value == 2 && typeId.value == 2) {
  176. // 英语
  177. productTipImg.value = 'static/images/study/yingyu/yingyu-tip.gif'
  178. getBj('yingyu');
  179. } else if (currentProduct.value == 1 && typeId.value == 1) {
  180. // 数学新(计算特训)
  181. productTipImg.value = 'static/images/study/jstx/jstx-tip.gif'
  182. getBj('shuxueNew');
  183. } else if (currentProduct.value == 2 && typeId.value == 1) {
  184. // 英语新(超级单词)
  185. productTipImg.value = 'static/images/study/cjdc/new-yingyu-tip.gif'
  186. getBj('yingyuNew');
  187. }
  188. }
  189. function getBj(data) {
  190. let bjType = cacheManager.get('dao-tip')[data];
  191. if (cacheManager.get('auth')) {
  192. // 非游客
  193. if (bjType !== 'has') {
  194. nextTick(() => {
  195. daoTipDialogRef.value.handleShow();
  196. })
  197. }
  198. } else {
  199. // 游客
  200. if (tipFlag.value === '0') {
  201. nextTick(() => {
  202. daoTipDialogRef.value.handleShow();
  203. })
  204. }
  205. }
  206. }
  207. function daoTipClose() {
  208. if (cacheManager.get('auth')) {
  209. // 非游客 记缓存
  210. if (currentProduct.value == 1 && typeId.value == 2) {
  211. // 数学
  212. cacheManager.updateObject('dao-tip', {
  213. shuxue: 'has'
  214. })
  215. } else if (currentProduct.value == 2 && typeId.value == 2) {
  216. // 英语
  217. cacheManager.updateObject('dao-tip', {
  218. yingyu: 'has'
  219. })
  220. } else if (currentProduct.value == 1 && typeId.value == 1) {
  221. // 数学新(计算特训)
  222. cacheManager.updateObject('dao-tip', {
  223. shuxueNew: 'has'
  224. })
  225. } else if (currentProduct.value == 2 && typeId.value == 1) {
  226. // 英语新(超级单词)
  227. cacheManager.updateObject('dao-tip', {
  228. yingyuNew: 'has'
  229. })
  230. }
  231. } else {
  232. //游客
  233. tipFlag.value = '1';
  234. }
  235. }
  236. function onChangeTab(e) {
  237. console.log('e', e);
  238. console.log(e.detail.current);
  239. if (cacheManager.get('auth')) {
  240. // 新的英语人教版
  241. if (currentProduct.value == 2 && typeId.value == 1) {
  242. infoData.zhangId = cacheManager.get('zhangInfo').zhangList[0].zhangId
  243. cacheManager.updateObject('auth', {
  244. currentZhang: e.detail.current,
  245. zhangId: infoData.zhangId
  246. })
  247. } else {
  248. // 旧的数学 英语 新的数学
  249. infoData.zhangId = cacheManager.get('zhangInfo').zhangList[e.detail.current].zhangId
  250. cacheManager.updateObject('auth', {
  251. currentZhang: e.detail.current,
  252. zhangId: infoData.zhangId
  253. })
  254. }
  255. }
  256. }
  257. function init(options) {
  258. if (cacheManager.get('auth')) {
  259. localAuth.value = cacheManager.get('auth');
  260. currentProduct.value = localAuth.value.subjectId;
  261. typeId.value = localAuth.value.typeId;
  262. console.log(localAuth.value);
  263. // 已登录
  264. if (localAuth.value.firstLogin) {
  265. nextTick(() => {
  266. eggDialogRef.value.eggShow();
  267. })
  268. }
  269. if (!cacheManager.get('zhangInfo')) {
  270. console.log('无zhangInfo缓存');
  271. chooseMethodNoCache()
  272. } else {
  273. console.log('使用缓存Zhanginfo');
  274. chooseMethodUseCache()
  275. }
  276. } else {
  277. chooseMethodYouke(options)
  278. }
  279. }
  280. function chooseMethodNoCache() {
  281. // 新的英语 (人教版 之类的 新结构)
  282. if (currentProduct.value == 2 && typeId.value == 1) {
  283. getZhangInfoNewYingyu()
  284. } else {
  285. // 之前 旧的岛 数学英语 和新的数学
  286. getZhangInfo()
  287. }
  288. }
  289. function chooseMethodUseCache() {
  290. // 新的英语 (人教版 之类的 新结构)
  291. if (currentProduct.value == 2 && typeId.value == 1) {
  292. translateData(cacheManager.get('zhangInfo'))
  293. zhangList.value = cacheManager.get('zhangInfo').zhangList[0].zList
  294. zhangName.value = cacheManager.get('zhangInfo').zhangList[0].zhangName
  295. current.value = cacheManager.get('auth').currentZhang
  296. zid.value = cacheManager.get('zhangInfo').zhangList[0].zList[cacheManager.get('auth').currentZhang].zhangZid
  297. infoData.zhangId = cacheManager.get('zhangInfo').zhangList[0].zhangId
  298. recordZhangJie()
  299. } else {
  300. // 之前 旧的岛 数学英语 和新的数学
  301. const curZhangId = res.data.curZhangId;
  302. const resZhangList = res.data.zhangList;
  303. const index = resZhangList.findIndex(item => item.zhangId == curZhangId)
  304. console.log('index', index);
  305. cacheManager.updateObject('auth', {
  306. currentZhang: index
  307. })
  308. translateData(cacheManager.get('zhangInfo'))
  309. zhangList.value = cacheManager.get('zhangInfo').zhangList
  310. current.value = cacheManager.get('auth').currentZhang
  311. infoData.zhangId = cacheManager.get('zhangInfo').zhangList[current.value].zhangId
  312. recordZhangJie()
  313. }
  314. }
  315. function chooseMethodYouke(options) {
  316. subjectId.value = options.subjectId
  317. typeId.value = options.typeId
  318. levelId.value = options.levelId
  319. tipFlag.value = options.tipFlag;
  320. currentProduct.value = options.subjectId
  321. youkeZhangId.value = options.youkeZhangId
  322. if (subjectId.value == 2 && typeId.value == 1) {
  323. // 新英语
  324. getCommonZhangNewYingyu(options)
  325. } else {
  326. // 未登录 游客 旧的数学 英语 新数学
  327. getCommonZhang(options)
  328. }
  329. getProjectImg()
  330. }
  331. // 新的英语 (人教版 之类的 新结构)
  332. function getZhangInfoNewYingyu(data) {
  333. const arr = localAuth.value.levelId.split(",");
  334. let req = {
  335. levelId: arr[0],
  336. zhangId: arr[1]
  337. }
  338. userZhangInfo(req).then(res => {
  339. cacheManager.set('zhangInfo', res.data)
  340. const curZid = res.data.curZid;
  341. const resZList = res.data.zhangList[0].zList;
  342. const index = resZList.findIndex(item => item.zid == curZid)
  343. console.log('index', index);
  344. cacheManager.updateObject('auth', {
  345. currentZhang: index
  346. })
  347. nextTick(() => {
  348. translateData(res.data)
  349. zhangList.value = res.data.zhangList[0].zList
  350. zhangName.value = res.data.zhangList[0].zhangName
  351. current.value = cacheManager.get('auth').currentZhang
  352. zid.value = res.data.zhangList[0].zList[cacheManager.get('auth').currentZhang].zhangZid
  353. infoData.zhangId = res.data.zhangList[0].zhangId
  354. recordZhangJie()
  355. })
  356. }).catch((err) => {
  357. toast('数据异常,请重新登录!')
  358. // cacheManager.clearAll();
  359. // uni.reLaunch({
  360. // url: '/pages/login/index'
  361. // });
  362. })
  363. }
  364. function findZhangindex(data) {
  365. console.log('data', data);
  366. for (let zhangIndex = 0; zhangIndex < data.zhangList.length; zhangIndex++) {
  367. const zhang = data.zhangList[zhangIndex];
  368. for (let jieIndex = 0; jieIndex < zhang.jieList.length; jieIndex++) {
  369. if (zhang.jieList[jieIndex].studyFlag == 0) {
  370. return zhangIndex; // 返回所在zhang的索引
  371. }
  372. }
  373. }
  374. return -1; // 如果没有找到
  375. }
  376. function getZhangInfo(data) {
  377. let req = {
  378. levelId: localAuth.value.levelId
  379. }
  380. userZhangInfo(req).then(res => {
  381. cacheManager.set('zhangInfo', res.data)
  382. const curZhangId = res.data.curZhangId;
  383. const resZhangList = res.data.zhangList;
  384. const index = resZhangList.findIndex(item => item.zhangId == curZhangId)
  385. console.log('index', index);
  386. cacheManager.updateObject('auth', {
  387. currentZhang: index
  388. })
  389. nextTick(() => {
  390. translateData(res.data)
  391. zhangList.value = res.data.zhangList
  392. current.value = cacheManager.get('auth').currentZhang
  393. infoData.zhangId = res.data.zhangList[current.value].zhangId
  394. recordZhangJie()
  395. })
  396. }).catch((err) => {
  397. toast('数据异常,请重新登录!')
  398. // cacheManager.clearAll();
  399. // uni.reLaunch({
  400. // url: '/pages/login/index'
  401. // });
  402. })
  403. }
  404. function getCommonZhangNewYingyu(data) {
  405. let req = {
  406. levelId: data.levelId,
  407. zhangId: data.youkeZhangId
  408. }
  409. getCommonZhangInfo(req).then(res => {
  410. translateData(res.data)
  411. youkeImage.value = res.data.icon
  412. youkeImageBook.value = res.data.zhangIcon
  413. zhangList.value = res.data.zhangList[0].zList
  414. zhangName.value = res.data.zhangList[0].zhangName
  415. current.value = 0
  416. }).catch((err) => {
  417. toast('数据异常,请重新登录!')
  418. // cacheManager.clearAll();
  419. // uni.reLaunch({
  420. // url: '/pages/login/index'
  421. // });
  422. })
  423. }
  424. function getCommonZhang(data) {
  425. let req = {
  426. levelId: data.levelId,
  427. }
  428. getCommonZhangInfo(req).then(res => {
  429. translateData(res.data)
  430. youkeImage.value = res.data.icon
  431. zhangList.value = res.data.zhangList
  432. current.value = 0
  433. }).catch((err) => {
  434. toast('数据异常,请重新登录!')
  435. cacheManager.clearAll();
  436. uni.reLaunch({
  437. url: '/pages/login/index'
  438. });
  439. })
  440. }
  441. function recordZhangJie() {
  442. let req = {
  443. levelId: localAuth.value.levelId,
  444. userId: localAuth.value.userId,
  445. zhangId: infoData.zhangId,
  446. subjectId: currentProduct.value,
  447. zhangZid: zid.value
  448. }
  449. userLocate(req).then(res => {
  450. })
  451. }
  452. function goPayPage() {
  453. let zhangInfoLocal = cacheManager.get('zhangInfo')
  454. if (!zhangInfoLocal.cardId) {
  455. toast("cardId 丢失请重新选择学科LevelId");
  456. return false
  457. }
  458. uni.redirectTo({
  459. url: '/pages/mall/mallPage?cardId=' + zhangInfoLocal.cardId + '&from=daoPage' + '&subjectId=' +
  460. zhangInfoLocal.subjectId
  461. })
  462. }
  463. function handleChangeZhang(data) {
  464. console.log(data);
  465. const authCode = getUserIdentity();
  466. if (authCode !== 'Visitor') {
  467. cacheManager.updateObject('auth', {
  468. zhangId: data.zhangId,
  469. currentZhang: zhangList.value.findIndex(citem => citem.zhangId == data.zhangId),
  470. })
  471. }
  472. currentDuration.value = 0
  473. setTimeout(() => {
  474. current.value = data.number - 1
  475. nextTick(() => {
  476. currentDuration.value = 500
  477. })
  478. }, 100)
  479. if (currentProduct.value == 2 && typeId.value == 1) {
  480. cacheManager.remove('zhangInfo')
  481. }
  482. init()
  483. }
  484. function goKaoshi(data) {
  485. uni.redirectTo({
  486. // url: `/pages/unitTest/index?jieNumber=` + data.number
  487. url: `/pages/unitTest/index?jieId=` + data.jieId
  488. })
  489. }
  490. function goDanciList(data, index) {
  491. if (!cacheManager.get('auth')) {
  492. getWordListYk({
  493. jieId: data.jieId
  494. }).then(res => {
  495. if (res.code == 0 && res.data.wordList.length > 0) {
  496. let youkeData = {
  497. subjectId: subjectId.value,
  498. typeId: typeId.value,
  499. levelId: levelId.value,
  500. tipFlag: tipFlag.value,
  501. youkeZhangId: youkeZhangId.value,
  502. jieId: data.jieId
  503. }
  504. uni.redirectTo({
  505. url: '/pages/wordList/wordList?youkePageData=' + JSON.stringify(youkeData)
  506. })
  507. } else {
  508. toast("该单元没有学习内容!");
  509. return false
  510. }
  511. })
  512. } else {
  513. getWordList({
  514. jieId: data.jieId
  515. }).then(res => {
  516. if (res.code == 0 && res.data.wordList.length > 0) {
  517. uni.redirectTo({
  518. url: '/pages/wordList/wordList?jieId=' + data.jieId
  519. })
  520. } else {
  521. toast("该单元没有学习内容!");
  522. console.log('data,jieId', data.jieId);
  523. wordXuewan({
  524. jieId: data.jieId
  525. }).then(res => {
  526. getZhangInfoNewYingyu()
  527. // 更新缓存 备用 现在是 直接调用接口
  528. // const result = updateStudyFlag(responseData, data.jieId, 1);
  529. // if (result) {
  530. // cacheManager.set('zhangInfo', result)
  531. // }
  532. })
  533. return false
  534. }
  535. })
  536. }
  537. }
  538. // 更新缓存 备用 现在是 直接调用接口
  539. const updateStudyFlag = (data, jieIdToUpdate, newValue) => {
  540. // 检查data和必要的数据结构是否存在
  541. if (!data || !Array.isArray(data.zhangList)) {
  542. console.warn('无效的数据结构');
  543. return false;
  544. }
  545. // 遍历zhangList
  546. data.zhangList.forEach(zhang => {
  547. // 检查zList是否存在且是数组
  548. if (zhang && Array.isArray(zhang.zList)) {
  549. zhang.zList.forEach(z => {
  550. // 检查jieList是否存在且是数组
  551. if (z && Array.isArray(z.jieList)) {
  552. z.jieList.forEach(jie => {
  553. // 检查jie对象和jieId是否存在
  554. if (jie && jie.jieId == jieIdToUpdate) {
  555. jie.studyFlag = newValue;
  556. }
  557. });
  558. }
  559. });
  560. }
  561. });
  562. return data;
  563. };
  564. function goLookShipin(data, index) {
  565. if (!cacheManager.get('auth')) {
  566. console.log('zhangList.value[0].jieList', zhangList.value[0].jieList);
  567. console.log('zhangList.value[0].jieList.index', zhangList.value[0].jieList[index]);
  568. let youkeData = {
  569. levelId: levelId.value,
  570. typeId: typeId.value,
  571. subjectId: subjectId.value,
  572. tipFlag: tipFlag.value,
  573. jieList: zhangList.value[0].jieList[index],
  574. jieName: zhangList.value[0].jieList[index].jieName
  575. }
  576. if (youkeData.typeId == 1) {
  577. if (!data.videoId) {
  578. toast("videoId 丢失!");
  579. return false
  580. }
  581. uni.redirectTo({
  582. url: '/pages/study/lookShipinNew?youkePageData=' + JSON.stringify(youkeData)
  583. })
  584. } else {
  585. if (!data.videoId) {
  586. toast("videoId 丢失!");
  587. return false
  588. }
  589. uni.redirectTo({
  590. url: '/pages/study/lookShipin?youkePageData=' + JSON.stringify(youkeData)
  591. })
  592. }
  593. } else {
  594. if (typeId.value == 1) {
  595. // 1新 2旧
  596. if (!data.videoId) {
  597. toast("videoId 丢失!");
  598. return false
  599. }
  600. uni.redirectTo({
  601. url: '/pages/study/lookShipinNew?jieId=' + data.jieId
  602. })
  603. } else {
  604. if (!data.videoId) {
  605. toast("videoId 丢失!");
  606. return false
  607. }
  608. uni.redirectTo({
  609. url: '/pages/study/lookShipin?jieId=' + data.jieId
  610. })
  611. }
  612. }
  613. }
  614. function translateData(data) {
  615. // gradeTerm.value = termMapping[data.subjectId] +' · '+ data.levelName
  616. gradeTerm.value = data.levelName
  617. }
  618. function listClick(data, data2, index) {
  619. //console.log('data', data); // 节内容
  620. // console.log('data2', data2); //章内容
  621. chooseMethodListClick(data, data2, index)
  622. }
  623. function chooseMethodListClick(data, data2, index) {
  624. console.log('data', data); // 节内容
  625. console.log('data2', data2); //章内容
  626. const authCode = getUserIdentity();
  627. if (currentProduct.value == 2 && typeId.value == 1) {
  628. // const isFirst = data.jieName == data2.jieList[0].jieName
  629. if (!cacheManager.get('auth') && data.number != 1) {
  630. youkeDialogRef.value.handleShow();
  631. return false;
  632. }
  633. // console.log('authCode', authCode);
  634. if (!(authCode == 'VIP' || data.number == 1)) {
  635. goPayDialogRef.value.handleShow();
  636. return false
  637. }
  638. goDanciList(data, index)
  639. } else {
  640. if (!cacheManager.get('auth') && data.firstFlag != 1) {
  641. youkeDialogRef.value.handleShow();
  642. return;
  643. }
  644. console.log('authCode', authCode);
  645. if (!(authCode == 'VIP' || data.firstFlag == 1)) {
  646. // debugger
  647. goPayDialogRef.value.handleShow();
  648. return false
  649. }
  650. if (data.type == 2) {
  651. // 最后一项
  652. goKaoshi(data, index)
  653. } else {
  654. goLookShipin(data, index)
  655. }
  656. }
  657. }
  658. function handleCheckCatalogue(item) {
  659. catalogueRef.value.showPopup(item);
  660. }
  661. function clickGradeTerm() {
  662. // if(cacheManager.get('auth')){
  663. // cacheManager.updateObject('auth', {
  664. // currentZhang: 0
  665. // })
  666. // }
  667. uni.navigateTo({
  668. url: `/pages/selectGradesTerms/index?tipFlag=${tipFlag.value}&from=daoPage&productId=${levelId.value}&xuekeId=${subjectId.value}`
  669. })
  670. }
  671. // 游客弹窗---确定
  672. function ykConfirm() {
  673. uni.redirectTo({
  674. url: '/pages/login/index'
  675. });
  676. }
  677. function eggBtn() {
  678. console.log('点击:开启提分之旅');
  679. getProjectImg();
  680. cacheManager.updateObject('auth', {
  681. firstLogin: false
  682. })
  683. }
  684. </script>
  685. <style>
  686. </style>