index.vue 8.6 KB

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