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