index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <!-- 教育考试首页 -->
  2. <template>
  3. <view class="safetyEducationExamination-home">
  4. <scroll-view scroll-y @scrolltolower="scrollGet" class="for-max-box">
  5. <!-- 用户信息 -->
  6. <user-info-card></user-info-card>
  7. <!-- 学年数据统计 -->
  8. <academic-year-stats></academic-year-stats>
  9. <!-- 实验室绑定 -->
  10. <lab-binding></lab-binding>
  11. <!-- 考试任务 -->
  12. <exam-task></exam-task>
  13. <!-- 特殊考试 -->
  14. <special-exam></special-exam>
  15. <!-- 模拟练习 -->
  16. <mock-practice></mock-practice>
  17. <!-- 培训任务 -->
  18. <training-task></training-task>
  19. <!-- 文档资源 -->
  20. <doc-resource></doc-resource>
  21. <!-- 视频资源 -->
  22. <view class="videoResource-component">
  23. <view class="card">
  24. <view class="card-header">
  25. <view class="header-left">
  26. <view class="card-title">视频学习资源</view>
  27. </view>
  28. <text class="header-link" @click="goToPage('1')">更多 ›</text>
  29. </view>
  30. <view class="card-body">
  31. <view class="top-table-box">
  32. <view @click="checkTable(index)"
  33. :class="topCheckIndex == index ? 'check-table-p':''"
  34. v-for="(item,index) in tableList" :key="index">
  35. {{item.disciplineName}}
  36. </view>
  37. </view>
  38. <view class="for-video-courseware" v-for="(item,index) in videoList" :key="index">
  39. <img :src="baseUrl+item.exampleImg">
  40. <view class="bottom-text-box">
  41. <view>{{item.coursewareName}}</view>
  42. <view>{{secondsToMinutes(item.minLearningDuration)}}分钟 丨 {{item.creditHours}}学时 丨 {{item.points}}积分</view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </scroll-view>
  49. </view>
  50. </template>
  51. <script>
  52. import {
  53. config
  54. } from '@/api/request/config.js'
  55. import { userInfoCard } from './component/userInfoCard'
  56. import { academicYearStats } from './component/academicYearStats'
  57. import { labBinding } from './component/labBinding'
  58. import { examTask } from './component/examTask'
  59. import { specialExam } from './component/specialExam'
  60. import { mockPractice } from './component/mockPractice'
  61. import { trainingTask } from './component/trainingTask'
  62. import { docResource } from './component/docResource'
  63. import {
  64. examElDisciplineTypeList,
  65. examUserCoursewareLearningList,
  66. } from '@/pages_safetyEducationExamination/api/index.js'
  67. export default {
  68. components: {
  69. userInfoCard,
  70. academicYearStats,
  71. labBinding,
  72. examTask,
  73. specialExam,
  74. mockPractice,
  75. trainingTask,
  76. docResource,
  77. },
  78. data() {
  79. return {
  80. baseUrl: config.base_url,
  81. topCheckIndex:0,
  82. tableList:[],
  83. // 查询参数
  84. queryParams: {
  85. page: 1,
  86. pageSize: 4,
  87. materialType:1,
  88. },
  89. videoList:[],
  90. total:0,
  91. getDataType:false,
  92. }
  93. },
  94. created() {
  95. },
  96. mounted() {
  97. this.examElDisciplineTypeList();
  98. },
  99. methods: {
  100. //滚动加载
  101. scrollGet(){
  102. console.log('123')
  103. let self = this;
  104. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  105. this.$set(this, 'getDataType', true);
  106. } else {
  107. this.queryParams.page += 1;
  108. this.$nextTick(() => {
  109. this.examElDisciplineTypeList();
  110. })
  111. }
  112. },
  113. //选项卡切换
  114. checkTable(index){
  115. if(this.topCheckIndex!=index){
  116. this.$set(this,'topCheckIndex',index);
  117. this.$set(this.queryParams,'page',1);
  118. this.examUserCoursewareLearningList();
  119. }
  120. },
  121. async examElDisciplineTypeList() {
  122. try {
  123. const { data } = await examElDisciplineTypeList({});
  124. if (data.code === 200) {
  125. this.$set(this, 'tableList', data.data)
  126. this.examUserCoursewareLearningList();
  127. }
  128. } catch (e) { console.error('获取考试任务失败', e); }
  129. },
  130. async examUserCoursewareLearningList() {
  131. let self = this;
  132. try {
  133. let obj = JSON.parse(JSON.stringify(this.queryParams))
  134. obj.disciplineTypeId = this.tableList[this.topCheckIndex].id;
  135. const { data } = await examUserCoursewareLearningList(obj);
  136. if (data.code === 200) {
  137. if(self.queryParams.page == 1){
  138. this.videoList = data.data.records;
  139. this.total = data.data.total;
  140. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  141. this.$set(this, 'getDataType', true);
  142. }
  143. }else{
  144. this.videoList = [...this.videoList, ...data.data.records]
  145. this.total = data.data.total;
  146. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  147. this.$set(this, 'getDataType', true);
  148. }
  149. }
  150. }
  151. } catch (e) { console.error('获取文章失败', e); }
  152. },
  153. //换算分钟
  154. secondsToMinutes(totalSeconds) {
  155. if (typeof totalSeconds !== 'number' || totalSeconds <= 0) {
  156. return 1;
  157. }
  158. return Math.ceil(totalSeconds / 60);
  159. },
  160. },
  161. }
  162. </script>
  163. <style lang="stylus" scoped>
  164. .safetyEducationExamination-home {
  165. height: 100%;
  166. display: flex;
  167. flex-direction: column;
  168. background-color: #f0f4fb;
  169. overflow-y: hidden;
  170. .for-max-box{
  171. flex: 1;
  172. display: flex;
  173. flex-direction: column;
  174. overflow-y scroll;
  175. padding:0 0 100rpx 0;
  176. }
  177. .videoResource-component {
  178. margin: 0 32rpx 32rpx;
  179. .card {
  180. background: #fff;
  181. border-radius: 24rpx;
  182. overflow: hidden;
  183. margin-bottom: 24rpx;
  184. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  185. border: 1px solid #dde3ed;
  186. }
  187. .card-header {
  188. padding: 20rpx 28rpx;
  189. display: flex;
  190. justify-content: space-between;
  191. align-items: center;
  192. .card-title {
  193. font-size: 28rpx;
  194. color: #333;
  195. }
  196. .header-subtitle{
  197. margin-top:10rpx;
  198. font-size:22rpx;
  199. color:#8896a7;
  200. }
  201. .header-link {
  202. padding:10rpx 20rpx;
  203. font-size: 24rpx;
  204. color: #1857d4;
  205. }
  206. }
  207. .card-body{
  208. padding-bottom:30rpx;
  209. .top-table-box{
  210. padding:0 28rpx;
  211. display: flex;
  212. view{
  213. flex:1;
  214. text-align: center;
  215. line-height:50rpx;
  216. padding:0 10rpx;
  217. font-size:24rpx;
  218. border-bottom:4rpx solid #dedede;
  219. }
  220. .check-table-p{
  221. font-weight:600;
  222. color:#1857d4;
  223. border-bottom: 4rpx solid #1857d4;
  224. }
  225. }
  226. .for-video-courseware{
  227. margin:30rpx 28rpx 0;
  228. img{
  229. display: inline-block;
  230. width:630rpx;
  231. height: 160px;
  232. border-radius: 16rpx
  233. background: linear-gradient(135deg, #1e3a5f, #2d6a9f);
  234. }
  235. .bottom-text-box{
  236. view:nth-child(1){
  237. font-size:26rpx;
  238. height:26rpx;
  239. line-height:26rpx;
  240. margin:6rpx 0 10rpx;
  241. }
  242. view:nth-child(2){
  243. color:#8896a7;
  244. font-size:22rpx;
  245. height:22rpx;
  246. line-height:22rpx;
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. </style>