index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="ezy-study-page">
  3. <shuxueZhangjie @clickGradeTerm="clickGradeTerm" @onLeft="onLeft" @onRight="onRight"
  4. @handleCheckCatalogue="handleCheckCatalogue" :options="infoData">
  5. </shuxueZhangjie>
  6. <!-- 蛋 -->
  7. <egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
  8. <catalogue ref="catalogueRef" @change-zhang="handleChangeZhang"></catalogue>
  9. <CustomTabBar :cardId="cardId" :nianji="nianji" :zhangId="zhangId"></CustomTabBar>
  10. </view>
  11. </template>
  12. <script setup>
  13. import {
  14. userZhangInfo,
  15. userLocate,
  16. userZhangForntInfo,
  17. userZhangNextInfo,
  18. getCommonZhangInfo
  19. } from "@/api/learnPlan.js"
  20. import {
  21. reactive,
  22. ref,
  23. getCurrentInstance,
  24. onMounted
  25. } from "vue";
  26. import {
  27. onLoad
  28. } from '@dcloudio/uni-app';
  29. import catalogue from "@/components/catalogue/catalogue.vue";
  30. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  31. import shuxueZhangjie from './product/shuxue.vue';
  32. import {
  33. useTabBarHistory
  34. } from '@/utils/emitEvents.js';
  35. import eggDialog from './eggDialog.vue'
  36. import {
  37. toast,getUserIdentity
  38. } from "@/utils/common";
  39. import cacheManager from "@/utils/cacheManager.js";
  40. const eggDialogRef = ref(null);
  41. const zhangId = ref(null);
  42. const nianji = ref(null);
  43. const cardId = ref(null);
  44. const catalogueRef = ref(null);
  45. const selectZhang = ref(null);
  46. let infoData = reactive({
  47. jieList: [],
  48. haveFlag: '',
  49. nianji: '',
  50. number: '',
  51. cardId: '',
  52. zhangId: '',
  53. zhangName: '',
  54. numberStr: '',
  55. });
  56. onLoad((options) => {
  57. // 获取路由参数
  58. if(options){
  59. zhangId.value = options.zhangId
  60. nianji.value = options.nianji
  61. cardId.value = options.cardId
  62. }
  63. init(options)
  64. })
  65. function init(options){
  66. if (cacheManager.get('auth')) {
  67. //会员 取auth
  68. selectZhang.value = cacheManager.get('auth');
  69. console.log(selectZhang.value);
  70. // 已登录
  71. // 选择年级进入调用此接口
  72. //options.flag == 'selectGrades'
  73. getZhangInfo()
  74. // 蛋
  75. // eggDialogRef.value.eggShow();
  76. } else {
  77. console.log(options);
  78. // 未登录 游客
  79. getCommonZhang(options)
  80. }
  81. }
  82. function getZhangInfo(data) {
  83. let req = {
  84. nianji: selectZhang.value.nianji,
  85. cardId: selectZhang.value.cardId,
  86. zhangId: selectZhang.value.zhangId,
  87. }
  88. userZhangInfo(req).then(res => {
  89. cacheManager.set('zhangInfo', res.data)
  90. infoData.jieList = res.data.jieList
  91. infoData.haveFlag = res.data.haveFlag
  92. infoData.nianji = res.data.nianji
  93. infoData.number = res.data.number
  94. infoData.numberStr = res.data.numberStr
  95. infoData.cardId = res.data.cardId
  96. infoData.zhangId = res.data.zhangId
  97. infoData.zhangName = res.data.zhangName
  98. recordZhangJie()
  99. getNewData()
  100. // if (cacheManager.get('zhangInfo')) {
  101. // cacheManager.remove('zhangInfo')
  102. // cacheManager.set('zhangInfo', res.data)
  103. // } else {
  104. // cacheManager.set('zhangInfo', res.data)
  105. // }
  106. })
  107. }
  108. function getCommonZhang(data) {
  109. let req = {
  110. nianji: data.nianji,
  111. cardId: data.cardId,
  112. zhangId:data.zhangId,
  113. }
  114. getCommonZhangInfo(req).then(res => {
  115. infoData.jieList = res.data.jieList
  116. infoData.haveFlag = res.data.haveFlag
  117. infoData.nianji = res.data.nianji
  118. infoData.number = res.data.number
  119. infoData.numberStr = res.data.numberStr
  120. infoData.cardId = res.data.cardId
  121. infoData.zhangId = res.data.zhangId
  122. infoData.zhangName = res.data.zhangName
  123. //getNewData()
  124. })
  125. }
  126. function onLeft(event) {
  127. console.log('用户左滑了');
  128. let req = {
  129. nianji: selectZhang.value.nianji,
  130. zhangId: selectZhang.value.zhangId,
  131. cardId: selectZhang.value.cardId,
  132. }
  133. userZhangForntInfo(req).then(res => {
  134. cacheManager.set('zhangInfo', res.data)
  135. infoData.jieList = res.data.jieList
  136. infoData.haveFlag = res.data.haveFlag
  137. infoData.nianji = res.data.nianji
  138. infoData.number = res.data.number
  139. infoData.numberStr = res.data.numberStr
  140. infoData.cardId = res.data.cardId
  141. infoData.zhangId = res.data.zhangId
  142. infoData.zhangName = res.data.zhangName
  143. recordZhangJie()
  144. getNewData()
  145. })
  146. }
  147. function onRight(event) {
  148. console.log('用户又滑了');
  149. let req = {
  150. nianji: selectZhang.value.nianji,
  151. zhangId: selectZhang.value.zhangId,
  152. cardId: selectZhang.value.cardId,
  153. }
  154. userZhangNextInfo(req).then(res => {
  155. cacheManager.set('zhangInfo', res.data)
  156. infoData.jieList = res.data.jieList
  157. infoData.haveFlag = res.data.haveFlag
  158. infoData.nianji = res.data.nianji
  159. infoData.number = res.data.number
  160. infoData.numberStr = res.data.numberStr
  161. infoData.cardId = res.data.cardId
  162. infoData.zhangId = res.data.zhangId
  163. infoData.zhangName = res.data.zhangName
  164. recordZhangJie()
  165. getNewData()
  166. })
  167. }
  168. function getNewData() {
  169. selectZhang.value.zhangId = cacheManager.get('zhangInfo').zhangId;
  170. selectZhang.value.cardId = cacheManager.get('zhangInfo').cardId;
  171. selectZhang.value.nianji = cacheManager.get('zhangInfo').nianji;
  172. }
  173. function recordZhangJie() {
  174. let req = {
  175. nianji: selectZhang.value.nianji,
  176. userId: cacheManager.get('auth').userId,
  177. zhangId: infoData.zhangId,
  178. cardId: selectZhang.value.cardId,
  179. }
  180. userLocate(req).then(res => {
  181. })
  182. }
  183. function handleChangeZhang(data) {
  184. selectZhang.value = data;
  185. const authCode = getUserIdentity();
  186. if (authCode !== 'Visitor') {
  187. cacheManager.updateObject('auth', {
  188. zhangId: data.zhangId
  189. })
  190. }
  191. init()
  192. }
  193. function goKaoshi(data) {
  194. let zhangId = selectZhang.value ? selectZhang.value.zhangId : infoData.zhangId;
  195. let nianji = selectZhang.value.nianji;
  196. let cardId = selectZhang.value.cardId;
  197. uni.navigateTo({
  198. url: `/pages/unitTest/index?jieId=${data.jieId}&zhangId=${zhangId}&nianji=${nianji}&cardId=${cardId}`
  199. })
  200. }
  201. function goLookShipin(data) {
  202. data.progressMarkers = [{
  203. offset: 30,
  204. isCustomized: true,
  205. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  206. title: '变式1',
  207. time: '00:00:30',
  208. describe: 'test string',
  209. }, {
  210. offset: 120,
  211. isCustomized: true,
  212. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  213. title: '变式2',
  214. time: '00:02:00',
  215. describe: 'test string',
  216. }, {
  217. offset: 300,
  218. isCustomized: true,
  219. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  220. title: '变式3',
  221. time: '00:05:00',
  222. describe: 'test string',
  223. }]
  224. data.zhangId = infoData.zhangId
  225. data.nianji = infoData.nianji
  226. data.cardId = infoData.cardId
  227. uni.navigateTo({
  228. //url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
  229. url: '/pages/study/lookShipin?studyData=' + JSON.stringify(data)
  230. })
  231. }
  232. function listClick(data, index) {
  233. if (!cacheManager.get('auth')) {
  234. toast("当前为游客模式请登录!")
  235. uni.redirectTo({
  236. url: '/pages/login/index'
  237. })
  238. return;
  239. }
  240. // if(index !=0&&data.jieId!=79){
  241. // toast("付费章节!")
  242. // return false
  243. // }
  244. if (!data.vipFlag) {
  245. toast("付费章节!")
  246. return false
  247. }
  248. if (index == infoData.jieList.length - 1) {
  249. // 最后一项
  250. goKaoshi(data)
  251. } else {
  252. goLookShipin(data)
  253. }
  254. }
  255. function handleCheckCatalogue() {
  256. catalogueRef.value.showPopup();
  257. }
  258. function clickGradeTerm() {
  259. uni.navigateTo({
  260. url: `/pages/selectGradesTerms/index`,
  261. })
  262. }
  263. function eggBtn() {
  264. console.log('点击:开启提分之旅');
  265. }
  266. </script>
  267. <style>
  268. </style>