index.vue 22 KB

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