index.vue 23 KB

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