index.vue 7.6 KB

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