docResource.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <!-- 文档资源 -->
  2. <template>
  3. <view class="docResource-component">
  4. <view class="card">
  5. <view class="card-header">
  6. <view class="header-left">
  7. <view class="card-title">实验室安全素养资源</view>
  8. </view>
  9. </view>
  10. <view class="card-body">
  11. <view class="top-table-box">
  12. <view @click="checkTable(index)"
  13. :class="topCheckIndex == index ? 'check-table-p':''"
  14. v-for="(item,index) in tableList" :key="index">
  15. {{item.disciplineName}}
  16. </view>
  17. </view>
  18. <view class="card-title-box">
  19. <view>学习资料</view>
  20. <view @click="goPage(1)">查看更多</view>
  21. </view>
  22. <view class="card-for-list-box">
  23. <view class="card-for-box" @click="goPage(2,item)"
  24. v-for="(item,index) in topList" :key="index">
  25. <view class="for-left-box">📄</view>
  26. <view class="for-center-box">
  27. <view>{{ item.coursewareName }}</view>
  28. <view>{{ item.materialType == 4?'文章':item.attachmentType.substring(1) }}</view>
  29. </view>
  30. <view class="for-right-box">{{secondsToMinutes(item.minLearningDuration)}}分钟</view>
  31. </view>
  32. <view class="null-p" v-if="!topList[0]">暂无资料</view>
  33. </view>
  34. <view class="card-title-box">
  35. <view>题库</view>
  36. <view @click="goPage(3)">查看更多</view>
  37. </view>
  38. <view class="card-for-list-box-2">
  39. <view class="card-for-box" @click="goPage(4,item)"
  40. v-for="(item,index) in bottomList" :key="index">
  41. <view class="for-left-box">📖</view>
  42. <view class="for-right-box">
  43. <view>{{item.knowledgePointName}}</view>
  44. <view>{{item.questionCount}} 题</view>
  45. </view>
  46. </view>
  47. <view class="null-p" v-if="!bottomList[0]">暂无资料</view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. examElDisciplineTypeList,
  56. examUserCoursewareLearningList,
  57. examElQuestionBankGroupByKnowledgePoint,
  58. examUserCoursewareLearningRestart,
  59. } from '@/pages_safetyEducationExamination/api/index.js'
  60. export default {
  61. // components: {
  62. // workbench,
  63. // },
  64. data() {
  65. return {
  66. topCheckIndex:0,
  67. tableList:[],
  68. topList:[],
  69. bottomList:[],
  70. }
  71. },
  72. created() {
  73. },
  74. mounted() {
  75. // this.examElDisciplineTypeList();
  76. },
  77. methods: {
  78. resetMethod(){
  79. this.$set(this,'topCheckIndex',0);
  80. this.examElDisciplineTypeList();
  81. },
  82. goPage(type,item){
  83. if(type == 1){
  84. //文章列表
  85. uni.navigateTo({
  86. url: '/pages_safetyEducationExamination/views/study/index?pageType=2'
  87. });
  88. }else if(type == 2){
  89. //学习文章
  90. if(item.learnStatus == 2){
  91. uni.showModal({
  92. title: '提示',
  93. content: `该课件已学完,是否重置进度重新学习?`,
  94. success: async (res) => {
  95. if (res.confirm) {
  96. await this.examUserCoursewareLearningRestart(item.coursewareId);
  97. }
  98. }
  99. });
  100. }else{
  101. uni.navigateTo({
  102. url: `/pages_safetyEducationExamination/views/webViewPage/coursewareLearning?coursewareId=${item.coursewareId}`,
  103. });
  104. }
  105. }else if(type == 3){
  106. //知识点刷题列表(带学科类型参数)
  107. uni.navigateTo({
  108. url: `/pages_safetyEducationExamination/views/practice/index?disciplineTypeId=${this.tableList[this.topCheckIndex].id}`
  109. });
  110. }else if(type == 4){
  111. //知识点指向题库(带知识点+学科类型参数)
  112. uni.navigateTo({
  113. url: `/pages_safetyEducationExamination/views/practice/index?knowledgePointId=${item.knowledgePointId}&disciplineTypeId=${this.tableList[this.topCheckIndex].id}`
  114. });
  115. }
  116. },
  117. //重新开始学习课件
  118. async examUserCoursewareLearningRestart(coursewareId) {
  119. try {
  120. const { data } = await examUserCoursewareLearningRestart({coursewareId:coursewareId});
  121. if (data.code === 200) {
  122. uni.navigateTo({
  123. url: `/pages_safetyEducationExamination/views/webViewPage/coursewareLearning?coursewareId=${coursewareId}`,
  124. });
  125. }
  126. } catch (e) { console.error('重新开始学习课件失败', e); }
  127. },
  128. //选项卡切换
  129. checkTable(index){
  130. if(this.topCheckIndex!=index){
  131. this.$set(this,'topCheckIndex',index);
  132. this.examUserCoursewareLearningList();
  133. this.examElQuestionBankGroupByKnowledgePoint();
  134. }
  135. },
  136. async examElDisciplineTypeList() {
  137. try {
  138. const { data } = await examElDisciplineTypeList({});
  139. if (data.code === 200) {
  140. this.$set(this, 'tableList', data.data)
  141. this.examUserCoursewareLearningList();
  142. this.examElQuestionBankGroupByKnowledgePoint();
  143. }
  144. } catch (e) { console.error('获取考试任务失败', e); }
  145. },
  146. async examUserCoursewareLearningList() {
  147. try {
  148. let obj = {
  149. page:1,
  150. pageSize:3,
  151. materialType:2,
  152. disciplineTypeId:this.tableList[this.topCheckIndex].id,
  153. }
  154. const { data } = await examUserCoursewareLearningList(obj);
  155. if (data.code === 200) {
  156. this.$set(this, 'topList', data.data.records)
  157. }
  158. } catch (e) { console.error('获取文章失败', e); }
  159. },
  160. async examElQuestionBankGroupByKnowledgePoint() {
  161. try {
  162. let obj = {
  163. page:1,
  164. pageSize:2,
  165. disciplineTypeId:this.tableList[this.topCheckIndex].id,
  166. }
  167. const { data } = await examElQuestionBankGroupByKnowledgePoint(obj);
  168. if (data.code === 200) {
  169. this.$set(this, 'bottomList', data.data.records)
  170. }
  171. } catch (e) { console.error('获取知识点题库失败', e); }
  172. },
  173. //换算分钟
  174. secondsToMinutes(totalSeconds) {
  175. if (typeof totalSeconds !== 'number' || totalSeconds <= 0) {
  176. return 1;
  177. }
  178. return Math.ceil(totalSeconds / 60);
  179. },
  180. },
  181. }
  182. </script>
  183. <style lang="stylus" scoped>
  184. .docResource-component {
  185. margin: 0 32rpx 32rpx;
  186. .card {
  187. background: #fff;
  188. border-radius: 24rpx;
  189. overflow: hidden;
  190. margin-bottom: 24rpx;
  191. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.03);
  192. border: 1px solid #dde3ed;
  193. }
  194. .card-header {
  195. padding: 20rpx 28rpx;
  196. display: flex;
  197. justify-content: space-between;
  198. align-items: center;
  199. .card-title {
  200. font-size: 28rpx;
  201. color: #333;
  202. }
  203. .header-subtitle{
  204. margin-top:10rpx;
  205. font-size:22rpx;
  206. color:#8896a7;
  207. }
  208. .header-link {
  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. .card-title-box{
  233. display: flex;
  234. padding:0 28rpx 0;
  235. margin-top:10rpx;
  236. view{
  237. height:80rpx;
  238. line-height:80rpx;
  239. }
  240. view:nth-child(1){
  241. font-size:24rpx;
  242. flex:1;
  243. }
  244. view:nth-child(2){
  245. font-size:22rpx;
  246. color:#1857d4;
  247. }
  248. }
  249. .card-for-list-box{
  250. .null-p{
  251. text-align: center;
  252. color:#999;
  253. font-size:24rpx;
  254. line-height:100rpx;
  255. }
  256. .card-for-box:nth-child(1){
  257. margin-top:0;
  258. }
  259. .card-for-box{
  260. margin:20rpx 28rpx;
  261. padding: 20rpx 16rpx;
  262. background-color: #f4f6fa;
  263. border-radius: 12rpx;
  264. display: flex;
  265. .for-left-box{
  266. width:50rpx;
  267. font-size:30rpx;
  268. line-height:56rpx;
  269. text-align: center;
  270. margin-right:10rpx;
  271. }
  272. .for-center-box{
  273. flex:1;
  274. height:56rpx;
  275. view:nth-child(1){
  276. font-size:24rpx;
  277. line-height:24rpx;
  278. margin-bottom:10rpx;
  279. }
  280. view:nth-child(2){
  281. font-size:22rpx;
  282. line-height:22rpx;
  283. color:#8896a7;
  284. }
  285. }
  286. .for-right-box{
  287. font-size:24rpx;
  288. line-height:56rpx;
  289. color:#8896a7;
  290. margin-right:15rpx;
  291. }
  292. }
  293. }
  294. .card-for-list-box-2{
  295. padding:0 28rpx;
  296. .null-p{
  297. text-align: center;
  298. color:#999;
  299. font-size:24rpx;
  300. line-height:100rpx;
  301. }
  302. .card-for-box:nth-child(even) {
  303. margin-left:20rpx;
  304. }
  305. .card-for-box{
  306. width:264rpx;
  307. padding: 20rpx;
  308. border-radius: 12rpx;
  309. background-color: #f4f6fa;
  310. margin-bottom:20rpx;
  311. display: inline-block;
  312. .for-left-box{
  313. width:60rpx;
  314. font-size:40rpx;
  315. line-height:56rpx;
  316. text-align: center;
  317. margin-right:20rpx;
  318. display: inline-block;
  319. overflow: hidden;
  320. margin-top:5rpx;
  321. }
  322. .for-right-box{
  323. display: inline-block;
  324. height:56rpx;
  325. view:nth-child(1){
  326. font-size:24rpx;
  327. line-height:24rpx;
  328. margin-bottom:10rpx;
  329. }
  330. view:nth-child(2){
  331. font-size:22rpx;
  332. line-height:22rpx;
  333. color:#8896a7;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. }
  340. </style>