index.vue 24 KB

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