index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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()">更多 ›</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. goToPage(){
  101. //跳转资源学习列表
  102. uni.navigateTo({
  103. url: '/pages_safetyEducationExamination/views/study/index',
  104. });
  105. },
  106. //滚动加载
  107. scrollGet(){
  108. console.log('123')
  109. let self = this;
  110. if (self.total / self.queryParams.pageSize <= self.queryParams.page) {
  111. this.$set(this, 'getDataType', true);
  112. } else {
  113. this.queryParams.page += 1;
  114. this.$nextTick(() => {
  115. this.examElDisciplineTypeList();
  116. })
  117. }
  118. },
  119. //选项卡切换
  120. checkTable(index){
  121. if(this.topCheckIndex!=index){
  122. this.$set(this,'topCheckIndex',index);
  123. this.$set(this.queryParams,'page',1);
  124. this.examUserCoursewareLearningList();
  125. }
  126. },
  127. async examElDisciplineTypeList() {
  128. try {
  129. const { data } = await examElDisciplineTypeList({});
  130. if (data.code === 200) {
  131. this.$set(this, 'tableList', data.data)
  132. this.examUserCoursewareLearningList();
  133. }
  134. } catch (e) { console.error('获取考试任务失败', e); }
  135. },
  136. async examUserCoursewareLearningList() {
  137. let self = this;
  138. try {
  139. let obj = JSON.parse(JSON.stringify(this.queryParams))
  140. obj.disciplineTypeId = this.tableList[this.topCheckIndex].id;
  141. const { data } = await examUserCoursewareLearningList(obj);
  142. if (data.code === 200) {
  143. if(self.queryParams.page == 1){
  144. 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. }else{
  150. this.videoList = [...this.videoList, ...data.data.records]
  151. this.total = data.data.total;
  152. if (data.data.total / self.queryParams.pageSize <= self.queryParams.page) {
  153. this.$set(this, 'getDataType', true);
  154. }
  155. }
  156. }
  157. } catch (e) { console.error('获取文章失败', e); }
  158. },
  159. //换算分钟
  160. secondsToMinutes(totalSeconds) {
  161. if (typeof totalSeconds !== 'number' || totalSeconds <= 0) {
  162. return 1;
  163. }
  164. return Math.ceil(totalSeconds / 60);
  165. },
  166. },
  167. }
  168. </script>
  169. <style lang="stylus" scoped>
  170. .safetyEducationExamination-home {
  171. height: 100%;
  172. display: flex;
  173. flex-direction: column;
  174. background-color: #f0f4fb;
  175. overflow-y: hidden;
  176. .for-max-box{
  177. flex: 1;
  178. display: flex;
  179. flex-direction: column;
  180. overflow-y scroll;
  181. padding:0 0 100rpx 0;
  182. }
  183. .videoResource-component {
  184. margin: 0 32rpx 32rpx;
  185. .card {
  186. background: #fff;
  187. border-radius: 24rpx;
  188. overflow: hidden;
  189. margin-bottom: 24rpx;
  190. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  191. border: 1px solid #dde3ed;
  192. }
  193. .card-header {
  194. padding: 20rpx 28rpx;
  195. display: flex;
  196. justify-content: space-between;
  197. align-items: center;
  198. .card-title {
  199. font-size: 28rpx;
  200. color: #333;
  201. }
  202. .header-subtitle{
  203. margin-top:10rpx;
  204. font-size:22rpx;
  205. color:#8896a7;
  206. }
  207. .header-link {
  208. padding:10rpx 20rpx;
  209. font-size: 24rpx;
  210. color: #1857d4;
  211. }
  212. }
  213. .card-body{
  214. padding-bottom:30rpx;
  215. .top-table-box{
  216. padding:0 28rpx;
  217. display: flex;
  218. view{
  219. flex:1;
  220. text-align: center;
  221. line-height:50rpx;
  222. padding:0 10rpx;
  223. font-size:24rpx;
  224. border-bottom:4rpx solid #dedede;
  225. }
  226. .check-table-p{
  227. font-weight:600;
  228. color:#1857d4;
  229. border-bottom: 4rpx solid #1857d4;
  230. }
  231. }
  232. .for-video-courseware{
  233. margin:30rpx 28rpx 0;
  234. img{
  235. display: inline-block;
  236. width:630rpx;
  237. height: 160px;
  238. border-radius: 16rpx
  239. background: linear-gradient(135deg, #1e3a5f, #2d6a9f);
  240. }
  241. .bottom-text-box{
  242. view:nth-child(1){
  243. font-size:26rpx;
  244. height:26rpx;
  245. line-height:26rpx;
  246. margin:6rpx 0 10rpx;
  247. }
  248. view:nth-child(2){
  249. color:#8896a7;
  250. font-size:22rpx;
  251. height:22rpx;
  252. line-height:22rpx;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. }
  259. </style>