index.vue 22 KB

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