index.vue 22 KB

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