index.vue 22 KB

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