index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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 eggDialog from './eggDialog.vue'
  52. const eggDialogRef = ref(null);
  53. const catalogueRef = ref(null);
  54. let gradeTerm = ref('');
  55. const selectZhang = ref(null);
  56. let infoData = reactive({
  57. jieList: [],
  58. haveFlag: '',
  59. nianji: '',
  60. number: '',
  61. xueqi: '',
  62. zhangId: '',
  63. zhangName: '',
  64. numberStr: '',
  65. });
  66. // 来自单元测试的路由参数缓存
  67. const gradeMapping = {
  68. 1: '一年级',
  69. 2: '二年级',
  70. 3: '三年级',
  71. 4: '四年级',
  72. 5: '五年级',
  73. 6: '六年级'
  74. };
  75. const termMapping = {
  76. 1: '上',
  77. 2: '下'
  78. };
  79. const routeParams = ref(null);
  80. onLoad((options) => {
  81. // appContext.config.globalProperties.$state
  82. // const state = appContext.config.globalProperties.$state;
  83. console.log(options)
  84. // 获取路由参数
  85. routeParams.value = options;
  86. // 选择年级进入调用此接口
  87. if (options.flag == 'selectGrades') {
  88. getZhangFirst()
  89. } else {
  90. getZhangInfo()
  91. }
  92. // 设置全局变量
  93. // 蛋
  94. // eggDialogRef.value.eggShow();
  95. })
  96. function recordZhangJie() {
  97. let req = {
  98. nianji: routeParams.value.nianji,
  99. userId: JSON.parse(getAuth()).userId,
  100. zhangId: infoData.zhangId,
  101. xueqi: routeParams.value.xueqi,
  102. }
  103. userLocate(req).then(res => {
  104. })
  105. }
  106. function getZhangFirst() {
  107. let req = {
  108. nianji: routeParams.value.nianji,
  109. xueqi: routeParams.value.xueqi,
  110. }
  111. userZhangFirstInfo(req).then(res => {
  112. infoData.jieList = res.data.jieList
  113. infoData.haveFlag = res.data.haveFlag
  114. infoData.nianji = res.data.nianji
  115. infoData.number = res.data.number
  116. infoData.numberStr = res.data.numberStr
  117. infoData.xueqi = res.data.xueqi
  118. infoData.zhangId = res.data.zhangId
  119. infoData.zhangName = res.data.zhangName
  120. gradeTerm.value = translateData(res.data);
  121. recordZhangJie()
  122. })
  123. }
  124. function getZhangInfo(data) {
  125. let req = data ? {
  126. nianji: selectZhang.value.nianji,
  127. xueqi: selectZhang.value.xueqi,
  128. zhangId: selectZhang.value.zhangId,
  129. } : {
  130. nianji: routeParams.value.nianji,
  131. xueqi: routeParams.value.xueqi,
  132. zhangId: routeParams.value.zhangId,
  133. };
  134. userZhangInfo(req).then(res => {
  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.xueqi = res.data.xueqi
  141. infoData.zhangId = res.data.zhangId
  142. infoData.zhangName = res.data.zhangName
  143. gradeTerm.value = translateData(res.data);
  144. recordZhangJie()
  145. })
  146. }
  147. function translateData(data) {
  148. return gradeMapping[data.nianji] + termMapping[data.xueqi]
  149. }
  150. function handleChangeZhang(data) {
  151. console.log("章", data);
  152. selectZhang.value = data;
  153. getZhangInfo(true)
  154. setGlobalData(data)
  155. }
  156. function goKaoshi(data) {
  157. let zhangId = selectZhang.value ? selectZhang.value.zhangId : infoData.zhangId;
  158. let nianji = routeParams.value.nianji;
  159. let xueqi = routeParams.value.xueqi;
  160. uni.navigateTo({
  161. url: `/pages/unitTest/index?jieId=${data.jieId}&zhangId=${zhangId}&nianji=${nianji}&xueqi=${xueqi}`
  162. })
  163. }
  164. function goLookShipin(data) {
  165. data.videoId = 'b997f16cb9cb474cb93526cff77d8801'
  166. data.progressMarkers = [{
  167. offset: 30,
  168. isCustomized: true,
  169. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  170. title: 'test title',
  171. time: '04:01-07:50',
  172. describe: 'test string',
  173. }, {
  174. offset: 150,
  175. isCustomized: true,
  176. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  177. title: 'test title',
  178. time: '04:05-07:50',
  179. describe: 'test string',
  180. }, {
  181. offset: 250,
  182. isCustomized: true,
  183. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  184. title: 'test title',
  185. time: '04:07-07:50',
  186. describe: 'test string',
  187. }, {
  188. offset: 550,
  189. isCustomized: true,
  190. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  191. title: 'test title',
  192. time: '04:09-07:50',
  193. describe: 'test string',
  194. }, {
  195. offset: 320,
  196. isCustomized: true,
  197. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  198. title: 'test title',
  199. time: '04:11-07:50',
  200. describe: 'test string',
  201. }, {
  202. offset: 650,
  203. isCustomized: true,
  204. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  205. title: 'test title',
  206. time: '04:15-07:50',
  207. describe: 'test string',
  208. }]
  209. data.zhangId = infoData.zhangId
  210. data.nianji = infoData.nianji
  211. data.xueqi = infoData.xueqi
  212. const pageData = {
  213. // videoId:data.videoId,
  214. videoId: 'b997f16cb9cb474cb93526cff77d8801',
  215. progressMarkers: [{
  216. offset: 30,
  217. isCustomized: true,
  218. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  219. title: 'test title',
  220. describe: 'test string',
  221. }, {
  222. offset: 150,
  223. isCustomized: true,
  224. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  225. title: 'test title',
  226. describe: 'test string',
  227. }, {
  228. offset: 250,
  229. isCustomized: true,
  230. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  231. title: 'test title',
  232. describe: 'test string',
  233. }, {
  234. offset: 550,
  235. isCustomized: true,
  236. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  237. title: 'test title',
  238. describe: 'test string',
  239. }, {
  240. offset: 320,
  241. isCustomized: true,
  242. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  243. title: 'test title',
  244. describe: 'test string',
  245. }, {
  246. offset: 650,
  247. isCustomized: true,
  248. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  249. title: 'test title',
  250. describe: 'test string',
  251. }],
  252. }
  253. uni.navigateTo({
  254. //url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
  255. url: '/pages/study/lookShipin?studyData=' + JSON.stringify(data)
  256. })
  257. }
  258. function listClick(data,index) {
  259. if(index ==infoData.jieList.length-1){
  260. // 最后一项
  261. goKaoshi(data)
  262. }else{
  263. goLookShipin(data)
  264. }
  265. }
  266. function handleCheckCatalogue() {
  267. catalogueRef.value.showPopup();
  268. }
  269. function clickGradeTerm() {
  270. uni.navigateTo({
  271. url: '/pages/selectGradesTerms/index'
  272. })
  273. }
  274. function eggBtn() {
  275. console.log('点击:开启提分之旅');
  276. }
  277. </script>
  278. <style>
  279. </style>