index.vue 8.8 KB

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