index.vue 24 KB

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