index.vue 22 KB

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