index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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. setGlobalData(options)
  94. // 蛋
  95. // eggDialogRef.value.eggShow();
  96. })
  97. function setGlobalData(data){
  98. console.log(data);
  99. const { appContext } = getCurrentInstance();
  100. appContext.config.globalProperties.$state.xueqi = data.xueqi
  101. appContext.config.globalProperties.$state.nianji = data.nianji
  102. appContext.config.globalProperties.$state.zhangId = data.zhangId
  103. }
  104. function recordZhangJie() {
  105. let req = {
  106. nianji: routeParams.value.nianji,
  107. userId: JSON.parse(getAuth()).userId,
  108. zhangId: infoData.zhangId,
  109. xueqi: routeParams.value.xueqi,
  110. }
  111. userLocate(req).then(res => {
  112. })
  113. }
  114. function getZhangFirst() {
  115. let req = {
  116. nianji: routeParams.value.nianji,
  117. xueqi: routeParams.value.xueqi,
  118. }
  119. userZhangFirstInfo(req).then(res => {
  120. infoData.jieList = res.data.jieList
  121. infoData.haveFlag = res.data.haveFlag
  122. infoData.nianji = res.data.nianji
  123. infoData.number = res.data.number
  124. infoData.numberStr = res.data.numberStr
  125. infoData.xueqi = res.data.xueqi
  126. infoData.zhangId = res.data.zhangId
  127. infoData.zhangName = res.data.zhangName
  128. gradeTerm.value = translateData(res.data);
  129. recordZhangJie()
  130. })
  131. }
  132. function getZhangInfo(data) {
  133. let req = data ? {
  134. nianji: selectZhang.value.nianji,
  135. xueqi: selectZhang.value.xueqi,
  136. zhangId: selectZhang.value.zhangId,
  137. } : {
  138. nianji: routeParams.value.nianji,
  139. xueqi: routeParams.value.xueqi,
  140. zhangId: routeParams.value.zhangId,
  141. };
  142. userZhangInfo(req).then(res => {
  143. infoData.jieList = res.data.jieList
  144. infoData.haveFlag = res.data.haveFlag
  145. infoData.nianji = res.data.nianji
  146. infoData.number = res.data.number
  147. infoData.numberStr = res.data.numberStr
  148. infoData.xueqi = res.data.xueqi
  149. infoData.zhangId = res.data.zhangId
  150. infoData.zhangName = res.data.zhangName
  151. gradeTerm.value = translateData(res.data);
  152. recordZhangJie()
  153. })
  154. }
  155. function translateData(data) {
  156. return gradeMapping[data.nianji] + termMapping[data.xueqi]
  157. }
  158. function handleChangeZhang(data) {
  159. console.log("章", data);
  160. selectZhang.value = data;
  161. getZhangInfo(true)
  162. setGlobalData(data)
  163. }
  164. function goKaoshi(data) {
  165. let zhangId = selectZhang.value ? selectZhang.value.zhangId : infoData.zhangId;
  166. let nianji = routeParams.value.nianji;
  167. let xueqi = routeParams.value.xueqi;
  168. uni.navigateTo({
  169. url: `/pages/unitTest/index?jieId=${data.jieId}&zhangId=${zhangId}&nianji=${nianji}&xueqi=${xueqi}`
  170. })
  171. }
  172. function goLookShipin(data) {
  173. data.videoId = 'b997f16cb9cb474cb93526cff77d8801'
  174. data.progressMarkers = [{
  175. offset: 30,
  176. isCustomized: true,
  177. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  178. title: 'test title',
  179. time: '04:01-07:50',
  180. describe: 'test string',
  181. }, {
  182. offset: 150,
  183. isCustomized: true,
  184. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  185. title: 'test title',
  186. time: '04:05-07:50',
  187. describe: 'test string',
  188. }, {
  189. offset: 250,
  190. isCustomized: true,
  191. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  192. title: 'test title',
  193. time: '04:07-07:50',
  194. describe: 'test string',
  195. }, {
  196. offset: 550,
  197. isCustomized: true,
  198. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  199. title: 'test title',
  200. time: '04:09-07:50',
  201. describe: 'test string',
  202. }, {
  203. offset: 320,
  204. isCustomized: true,
  205. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  206. title: 'test title',
  207. time: '04:11-07:50',
  208. describe: 'test string',
  209. }, {
  210. offset: 650,
  211. isCustomized: true,
  212. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  213. title: 'test title',
  214. time: '04:15-07:50',
  215. describe: 'test string',
  216. }]
  217. data.zhangId = infoData.zhangId
  218. data.nianji = infoData.nianji
  219. data.xueqi = infoData.xueqi
  220. const pageData = {
  221. // videoId:data.videoId,
  222. videoId: 'b997f16cb9cb474cb93526cff77d8801',
  223. progressMarkers: [{
  224. offset: 30,
  225. isCustomized: true,
  226. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/9A3F562E595E4764AD1DD546FA52C6E5-6-2.png',
  227. title: 'test title',
  228. describe: 'test string',
  229. }, {
  230. offset: 150,
  231. isCustomized: true,
  232. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/1E7F402241CD4C0F94AD2BBB5CCC3EC7-6-2.png',
  233. title: 'test title',
  234. describe: 'test string',
  235. }, {
  236. offset: 250,
  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: 550,
  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. offset: 320,
  249. isCustomized: true,
  250. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  251. title: 'test title',
  252. describe: 'test string',
  253. }, {
  254. offset: 650,
  255. isCustomized: true,
  256. coverUrl: 'https://alivc-demo-vod.aliyuncs.com/image/cover/553AEA01161342C8A2B1756E83B69B5B-6-2.png',
  257. title: 'test title',
  258. describe: 'test string',
  259. }],
  260. }
  261. uni.navigateTo({
  262. //url: '/pages/study/lookShipin?studyData=' + JSON.stringify(pageData)
  263. url: '/pages/study/lookShipin?studyData=' + JSON.stringify(data)
  264. })
  265. }
  266. function listClick(data,index) {
  267. if(index ==infoData.jieList.length-1){
  268. // 最后一项
  269. goKaoshi(data)
  270. }else{
  271. goLookShipin(data)
  272. }
  273. }
  274. function handleCheckCatalogue() {
  275. catalogueRef.value.showPopup();
  276. }
  277. function clickGradeTerm() {
  278. uni.navigateTo({
  279. url: '/pages/selectGradesTerms/index'
  280. })
  281. }
  282. function eggBtn() {
  283. console.log('点击:开启提分之旅');
  284. }
  285. </script>
  286. <style>
  287. </style>