index.vue 7.6 KB

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