index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view class="ezy-study-page">
  3. <view class="study-school-year" @click="clickGradeTerm">{{gradeTerm}}</view>
  4. <view class="ezy-study-wrap">
  5. <view class="chapter-box" @click="handleCheckCatalogue">{{infoData.numberStr}}</view>
  6. <view class="chapter-title-box">{{infoData.zhangName}}</view>
  7. <view>
  8. <view class="brand-item" v-for="(item,index) in infoData.jieList" :key="index" @click="listClick(item,index)"
  9. :class="index ==0?'brand-active':''">
  10. <!-- <view class="brand-icon" v-if="index ==0">1</view>
  11. <view class="brand-lock" v-else></view>
  12. <view class="brand-content">{{item.jieName}}</view> -->
  13. <view class="brand-icon" v-if="index === 0">1</view>
  14. <view class="brand-lock" v-else></view>
  15. <view class="brand-content" v-if="index !== infoData.jieList.length - 1">{{ item.jieName }}</view>
  16. <view class="brand-content" v-if="index === infoData.jieList.length - 1">{{ item.jieName }}</view>
  17. </view>
  18. </view>
  19. </view>
  20. <!-- <uni-button style="margin-top: 200px;display: block;" @click="goKaoshi">goKaoshi</uni-button>
  21. -->
  22. <!-- <uni-button @click="handleCheckCatalogue">go catalogue</uni-button>
  23. <uni-button @click="goKaoshi">goKaoshi</uni-button>
  24. <!-- 蛋 -->
  25. <egg-dialog ref="eggDialogRef" @eggBtn="eggBtn"></egg-dialog>
  26. <catalogue ref="catalogueRef" :nianji="routeParams.nianji" :xueqi="routeParams.xueqi"
  27. @change-zhang="handleChangeZhang"></catalogue>
  28. <CustomTabBar></CustomTabBar>
  29. </view>
  30. </template>
  31. <script setup>
  32. import {
  33. userZhangFirstInfo,
  34. userZhangInfo,
  35. userLocate
  36. } from "@/api/learnPlan.js"
  37. import {
  38. reactive,
  39. ref,
  40. getCurrentInstance,
  41. onMounted
  42. } from "vue";
  43. import {
  44. onLoad,
  45. } from '@dcloudio/uni-app';
  46. import catalogue from "@/components/catalogue/catalogue.vue";
  47. import CustomTabBar from '@/components/custom-tabbar/custom-tabbar.vue';
  48. import {
  49. getAuth
  50. } from '@/utils/auth.js';
  51. import {
  52. useTabBarHistory
  53. } from '@/utils/emitEvents.js';
  54. import eggDialog from './eggDialog.vue'
  55. const eggDialogRef = ref(null);
  56. const catalogueRef = ref(null);
  57. let gradeTerm = ref('');
  58. const selectZhang = ref(null);
  59. let infoData = reactive({
  60. jieList: [],
  61. haveFlag: '',
  62. nianji: '',
  63. number: '',
  64. xueqi: '',
  65. zhangId: '',
  66. zhangName: '',
  67. numberStr: '',
  68. });
  69. // 来自单元测试的路由参数缓存
  70. const gradeMapping = {
  71. 1: '一年级',
  72. 2: '二年级',
  73. 3: '三年级',
  74. 4: '四年级',
  75. 5: '五年级',
  76. 6: '六年级'
  77. };
  78. const termMapping = {
  79. 1: '上',
  80. 2: '下'
  81. };
  82. const routeParams = ref(null);
  83. onLoad((options) => {
  84. // appContext.config.globalProperties.$state
  85. // const state = appContext.config.globalProperties.$state;
  86. console.log(options)
  87. // 获取路由参数
  88. routeParams.value = options;
  89. // 选择年级进入调用此接口
  90. if (options.flag == 'selectGrades') {
  91. getZhangFirst()
  92. } else {
  93. getZhangInfo()
  94. }
  95. // 设置全局变量
  96. // 蛋
  97. // eggDialogRef.value.eggShow();
  98. })
  99. function recordZhangJie() {
  100. let req = {
  101. nianji: routeParams.value.nianji,
  102. userId: JSON.parse(getAuth()).userId,
  103. zhangId: infoData.zhangId,
  104. xueqi: routeParams.value.xueqi,
  105. }
  106. userLocate(req).then(res => {
  107. })
  108. }
  109. function getZhangFirst() {
  110. let req = {
  111. nianji: routeParams.value.nianji,
  112. xueqi: routeParams.value.xueqi,
  113. }
  114. userZhangFirstInfo(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.xueqi = res.data.xueqi
  121. infoData.zhangId = res.data.zhangId
  122. infoData.zhangName = res.data.zhangName
  123. gradeTerm.value = translateData(res.data);
  124. recordZhangJie()
  125. console.log(useTabBarHistory());
  126. useTabBarHistory().setTabBarStorage({nianji:res.data.nianji,zhangId:res.data.zhangId,xueqi:res.data.xueqi})
  127. })
  128. }
  129. function getZhangInfo(data) {
  130. let req = data ? {
  131. nianji: selectZhang.value.nianji,
  132. xueqi: selectZhang.value.xueqi,
  133. zhangId: selectZhang.value.zhangId,
  134. } : {
  135. nianji: routeParams.value.nianji,
  136. xueqi: routeParams.value.xueqi,
  137. zhangId: routeParams.value.zhangId,
  138. };
  139. userZhangInfo(req).then(res => {
  140. infoData.jieList = res.data.jieList
  141. infoData.haveFlag = res.data.haveFlag
  142. infoData.nianji = res.data.nianji
  143. infoData.number = res.data.number
  144. infoData.numberStr = res.data.numberStr
  145. infoData.xueqi = res.data.xueqi
  146. infoData.zhangId = res.data.zhangId
  147. infoData.zhangName = res.data.zhangName
  148. gradeTerm.value = translateData(res.data);
  149. recordZhangJie()
  150. useTabBarHistory().setTabBarStorage({nianji:res.data.nianji,zhangId:res.data.zhangId,xueqi:res.data.xueqi})
  151. })
  152. }
  153. function translateData(data) {
  154. return gradeMapping[data.nianji] + termMapping[data.xueqi]
  155. }
  156. function handleChangeZhang(data) {
  157. console.log("章", data);
  158. selectZhang.value = data;
  159. getZhangInfo(true)
  160. }
  161. function goKaoshi(data) {
  162. let zhangId = selectZhang.value ? selectZhang.value.zhangId : infoData.zhangId;
  163. let nianji = routeParams.value.nianji;
  164. let xueqi = routeParams.value.xueqi;
  165. uni.navigateTo({
  166. url: `/pages/unitTest/index?jieId=${data.jieId}&zhangId=${zhangId}&nianji=${nianji}&xueqi=${xueqi}`
  167. })
  168. }
  169. function goLookShipin(data) {
  170. data.videoId = 'b997f16cb9cb474cb93526cff77d8801'
  171. data.progressMarkers = [{
  172. offset: 30,
  173. isCustomized: true,
  174. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  175. title: 'test title',
  176. time: '04:01-07:50',
  177. describe: 'test string',
  178. }, {
  179. offset: 150,
  180. isCustomized: true,
  181. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  182. title: 'test title',
  183. time: '04:05-07:50',
  184. describe: 'test string',
  185. }, {
  186. offset: 250,
  187. isCustomized: true,
  188. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  189. title: 'test title',
  190. time: '04:07-07:50',
  191. describe: 'test string',
  192. }, {
  193. offset: 550,
  194. isCustomized: true,
  195. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  196. title: 'test title',
  197. time: '04:09-07:50',
  198. describe: 'test string',
  199. }, {
  200. offset: 320,
  201. isCustomized: true,
  202. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  203. title: 'test title',
  204. time: '04:11-07:50',
  205. describe: 'test string',
  206. }, {
  207. offset: 650,
  208. isCustomized: true,
  209. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  210. title: 'test title',
  211. time: '04:15-07:50',
  212. describe: 'test string',
  213. }]
  214. data.zhangId = infoData.zhangId
  215. data.nianji = infoData.nianji
  216. data.xueqi = infoData.xueqi
  217. const pageData = {
  218. // videoId:data.videoId,
  219. videoId: 'b997f16cb9cb474cb93526cff77d8801',
  220. progressMarkers: [{
  221. offset: 30,
  222. isCustomized: true,
  223. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  224. title: 'test title',
  225. describe: 'test string',
  226. }, {
  227. offset: 150,
  228. isCustomized: true,
  229. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  230. title: 'test title',
  231. describe: 'test string',
  232. }, {
  233. offset: 250,
  234. isCustomized: true,
  235. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  236. title: 'test title',
  237. describe: 'test string',
  238. }, {
  239. offset: 550,
  240. isCustomized: true,
  241. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  242. title: 'test title',
  243. describe: 'test string',
  244. }, {
  245. offset: 320,
  246. isCustomized: true,
  247. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  248. title: 'test title',
  249. describe: 'test string',
  250. }, {
  251. offset: 650,
  252. isCustomized: true,
  253. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  254. title: 'test title',
  255. describe: 'test string',
  256. }],
  257. }
  258. uni.navigateTo({
  259. //url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
  260. url: '/pages/study/lookShipin?studyData=' + JSON.stringify(data)
  261. })
  262. }
  263. function listClick(data,index) {
  264. if(index ==infoData.jieList.length-1){
  265. // 最后一项
  266. goKaoshi(data)
  267. }else{
  268. goLookShipin(data)
  269. }
  270. }
  271. function handleCheckCatalogue() {
  272. catalogueRef.value.showPopup();
  273. }
  274. function clickGradeTerm() {
  275. uni.navigateTo({
  276. url: '/pages/selectGradesTerms/index'
  277. })
  278. }
  279. function eggBtn() {
  280. console.log('点击:开启提分之旅');
  281. }
  282. </script>
  283. <style>
  284. </style>