index.vue 8.6 KB

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