index - 副本.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <view class="lli-index-page">
  3. </view>
  4. </template>
  5. <script setup>
  6. import {
  7. kaoShiApply,
  8. getClientKaoshiInfo
  9. } from "@/api/exam.js";
  10. import kaoshixuzhi from "@/components/kaoshixuzhi/kaoshixuzhi.vue"
  11. import {ref,reactive} from "vue";
  12. import {getCourseList, getNoticeCount,getExamList} from '@/api/index.js';
  13. import {onLoad} from "@dcloudio/uni-app"
  14. const banners= ref('');
  15. const defaultbanners= ref('/static/images/index/index-banner.png');
  16. const defultKsImg= ref('/static/images/index/index-ks-default.png');
  17. const defultKcImg= ref('/static/images/index/index-kc-default.png');
  18. const statusCodeKc= ref(['未开始', '可以学习', '已学完', '学习中', '已结束']);
  19. const statusCodeKs= ref(['未开始', '可以考试', '再次考试', '考试中', '已结束', '未报名', '报名审核中', '审核未通过', '等待人工评分']);
  20. let menuList = ref([{
  21. url: '/static/images/index/index-kc-img.png',
  22. text: '我的课程',
  23. },
  24. {
  25. url: '/static/images/index/index-ks-img.png',
  26. text: '我的考试',
  27. },
  28. {
  29. url: '/static/images/index/index-lx-img.png',
  30. text: '每日一练',
  31. },
  32. {
  33. url: '/static/images/index/index-gg-img.png',
  34. text: '公告',
  35. badge:0,
  36. },
  37. ]);
  38. let courseCardList = ref([]);
  39. let examCardList = ref([]);
  40. let noticeCount = ref(0);
  41. const examNoticeInfo = ref(null); // 考试须知数据
  42. const ksxzRef = ref(null);
  43. const activeKs = ref(null);
  44. onLoad(() => {
  45. getNoticeCountData();
  46. getCourseListData();
  47. getExamListData();
  48. });
  49. function getNoticeCountData() {
  50. let req = {
  51. 'page': 1,
  52. 'size': 4,
  53. 'status': 1,
  54. };
  55. getNoticeCount(req).then(res => {
  56. menuList.value[3].badge = res.data.noticeCount || 0;
  57. });
  58. };
  59. function getCourseListData() {
  60. let req = {
  61. 'page': 1,
  62. 'size': 4,
  63. 'status': 1,
  64. };
  65. getCourseList(req).then(res => {
  66. courseCardList.value = res.data.data || [];
  67. });
  68. };
  69. function getExamListData() {
  70. let req = {
  71. 'page': 1,
  72. 'size': 4,
  73. 'status': 1,
  74. };
  75. getExamList(req).then(res => {
  76. examCardList.value = res.data.data || [];
  77. });
  78. };
  79. function gridClick(e){
  80. let {index} = e.detail;
  81. switch (index) {
  82. case 0:
  83. uni.switchTab({
  84. url: '/pages/course/index'
  85. });
  86. break;
  87. case 1:
  88. uni.switchTab({
  89. url: '/pages/exam/index'
  90. });
  91. break;
  92. case 2:
  93. uni.navigateTo({
  94. url: '/pages/lianxi/index'
  95. })
  96. break;
  97. case 3:
  98. uni.navigateTo({
  99. url:'/pages/my/mesList?from=indexPeixun'
  100. })
  101. break;
  102. }
  103. }
  104. function developClick(){
  105. uni.showToast({
  106. icon: 'none',
  107. title: '开发中,敬请期侍!',
  108. });
  109. }
  110. function goKaoshiPage(data) {
  111. /* uni.redirectTo({
  112. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  113. }) */
  114. uni.navigateTo({
  115. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  116. })
  117. }
  118. function handleConfirm() {
  119. goKaoshiPage(activeKs.value)
  120. }
  121. function showKaoshiXuzhi() {
  122. const option = {
  123. ksId: activeKs.value.ksId
  124. }
  125. getClientKaoshiInfo(option).then(res => {
  126. examNoticeInfo.value = res.data;
  127. // 校验抓拍
  128. doCheckZhuapai()
  129. })
  130. }
  131. function doCheckZhuapai() {
  132. if (examNoticeInfo.value.zhuapai) {
  133. // 存在抓拍
  134. } else {
  135. // 不存在抓拍
  136. ksxzRef.value.showDialog(examNoticeInfo.value)
  137. }
  138. }
  139. function handleClickKs(data) {
  140. activeKs.value = data;
  141. console.log('ddddd',data)
  142. if (data.status == 0) {
  143. // 未开始
  144. showKaoshiXuzhi()
  145. }
  146. if (data.status == 1) {
  147. // 可以考试
  148. showKaoshiXuzhi()
  149. }
  150. if (data.status == 2) {
  151. // 再次考试
  152. showKaoshiXuzhi()
  153. }
  154. if (data.status == 3) {
  155. // 考试中
  156. showKaoshiXuzhi()
  157. }
  158. if (data.status == 4) {
  159. // 已结束
  160. uni.showToast({
  161. title: '考试已结束',
  162. icon: 'none'
  163. })
  164. }
  165. if (data.status == 5) {
  166. // 未报名
  167. kaoShiApply({
  168. ksId: data.ksId
  169. }).then(res => {
  170. uni.showToast({
  171. title: '报名成功',
  172. icon: 'none'
  173. })
  174. scrollRef.value.onRefresh()
  175. })
  176. }
  177. }
  178. function handleCheckMoreKs() {
  179. uni.switchTab({
  180. url: '/pages/exam/index'
  181. })
  182. }
  183. </script>
  184. <style lang="scss">
  185. .lli-index-page{
  186. padding: 24rpx;
  187. background: #FCFBFC;
  188. min-height: 100vh;
  189. // banner
  190. .index-imgbox {
  191. text-align: center;width: 100%;
  192. .index-banner-img {
  193. width: 702rpx;
  194. height: 242rpx;
  195. display: inline-block;
  196. border-radius: 4px;
  197. }
  198. }
  199. //meul-box
  200. .index-meul-box{
  201. .lli-grid-item {
  202. flex: 1;
  203. /* #ifndef APP-NVUE */
  204. display: flex;
  205. /* #endif */
  206. flex-direction: column;
  207. align-items: center;
  208. justify-content: center;
  209. padding: 15px 0;
  210. }
  211. .grid-item-image {width: 99rpx;height: 113rpx;}
  212. .grid-item-text {font-size: 24rpx;color: $uni-text-color;}
  213. .grid-dot {position: absolute;top: 5px;right: 15px;}
  214. }
  215. // title-box
  216. .lli-index-title-box{
  217. margin: 44rpx 0 32rpx;display: flex;justify-content: space-between;align-items: center;
  218. .index-title{font-size: 32rpx;color: #333;font-weight: 800;display: inline-flex;align-items: center;}
  219. .index-title:before{content:'';width: 3px;height: 30rpx;background: $uni-primary;margin-right: 8px;display: block;}
  220. .index-sub-title{font-size: 24rpx;color: #9c9c9c;font-weight: normal;cursor: pointer;}
  221. }
  222. // card
  223. .lli-card-box{width: 100%;display: flex;justify-content: space-between;flex-wrap: wrap;margin-bottom: 8px;cursor: pointer;}
  224. .lli-card-item{
  225. width: 49%;flex: unset;border-radius: 20rpx;background-color: #ffffff;
  226. padding: 12rpx 12rpx 0;box-sizing: border-box;margin-bottom: 20rpx;
  227. .lli-card-image{max-width: 100%;height: 180rpx;border-radius: 8rpx;}
  228. .custom-cover {max-width: 100%;height: 180rpx;border-radius: 8rpx;overflow: hidden;position: relative;}
  229. .cover-content {
  230. position: absolute;bottom: 0;left: 0;padding: 4rpx 12rpx;background: rgba(0, 0, 0, 0.29);
  231. color: #fff;font-size: 22rpx;border-radius: 0 10rpx 0 10rpx;
  232. }
  233. .lli-card-name{
  234. font-size: 28rpx;line-height: 36rpx;color: #565656;margin: 20rpx 0;
  235. display: -webkit-box;-webkit-line-clamp: 2;overflow: hidden;
  236. text-overflow: ellipsis;-webkit-box-orient: vertical;
  237. }
  238. }
  239. }
  240. </style>