index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424
  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. uni.showToast({
  154. icon: 'none',
  155. title: '开发中,敬请期侍!',
  156. })
  157. return false
  158. break;
  159. case 1:
  160. uni.switchTab({
  161. url: '/pages/exam/index'
  162. });
  163. break;
  164. case 2:
  165. uni.showToast({
  166. icon: 'none',
  167. title: '开发中,敬请期侍!',
  168. })
  169. return false
  170. /* uni.navigateTo({
  171. url: '/pages/lianxi/index'
  172. }) */
  173. break;
  174. case 3:
  175. /* uni.navigateTo({
  176. url: '/pages/my/mesList?from=indexPeixun'
  177. }) */
  178. uni.showToast({
  179. icon: 'none',
  180. title: '开发中,敬请期侍!',
  181. })
  182. return false
  183. break;
  184. }
  185. }
  186. function developClick() {
  187. uni.showToast({
  188. icon: 'none',
  189. title: '开发中,敬请期侍!',
  190. });
  191. }
  192. function goKaoshiPage(data) {
  193. /* uni.redirectTo({
  194. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  195. }) */
  196. uni.navigateTo({
  197. url: `/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  198. })
  199. }
  200. function handleConfirm() {
  201. goKaoshiPage(activeKs.value)
  202. }
  203. function showKaoshiXuzhi() {
  204. const option = {
  205. ksId: activeKs.value.ksId
  206. }
  207. getClientKaoshiInfo(option).then(res => {
  208. examNoticeInfo.value = res.data;
  209. // 校验抓拍
  210. doCheckZhuapai()
  211. })
  212. }
  213. function doCheckZhuapai() {
  214. if (examNoticeInfo.value.zhuapai) {
  215. // 存在抓拍
  216. } else {
  217. // 不存在抓拍
  218. ksxzRef.value.showDialog(examNoticeInfo.value)
  219. }
  220. }
  221. function handleClickKs(data) {
  222. activeKs.value = data;
  223. console.log('ddddd', data)
  224. if (data.status == 0) {
  225. // 未开始
  226. showKaoshiXuzhi()
  227. }
  228. if (data.status == 1) {
  229. // 可以考试
  230. showKaoshiXuzhi()
  231. }
  232. if (data.status == 2) {
  233. // 再次考试
  234. showKaoshiXuzhi()
  235. }
  236. if (data.status == 3) {
  237. // 考试中
  238. showKaoshiXuzhi()
  239. }
  240. if (data.status == 4) {
  241. // 已结束
  242. uni.showToast({
  243. title: '考试已结束',
  244. icon: 'none'
  245. })
  246. }
  247. if (data.status == 5) {
  248. // 未报名
  249. kaoShiApply({
  250. ksId: data.ksId
  251. }).then(res => {
  252. uni.showToast({
  253. title: '报名成功',
  254. icon: 'none'
  255. })
  256. scrollRef.value.onRefresh()
  257. })
  258. }
  259. }
  260. function handleCheckMoreKs() {
  261. uni.switchTab({
  262. url: '/pages/exam/index'
  263. })
  264. }
  265. </script>
  266. <style lang="scss">
  267. .lli-index-page {
  268. padding: 24rpx;
  269. background: #FCFBFC;
  270. min-height: 100vh;
  271. // banner
  272. .index-imgbox {
  273. text-align: center;
  274. width: 100%;
  275. .index-banner-img {
  276. width: 702rpx;
  277. height: 242rpx;
  278. display: inline-block;
  279. border-radius: 4px;
  280. }
  281. }
  282. //meul-box
  283. .index-meul-box {
  284. .lli-grid-item {
  285. flex: 1;
  286. /* #ifndef APP-NVUE */
  287. display: flex;
  288. /* #endif */
  289. flex-direction: column;
  290. align-items: center;
  291. justify-content: center;
  292. padding: 15px 0;
  293. }
  294. .grid-item-image {
  295. width: 99rpx;
  296. height: 113rpx;
  297. }
  298. .grid-item-text {
  299. font-size: 24rpx;
  300. color: $uni-text-color;
  301. }
  302. .grid-dot {
  303. position: absolute;
  304. top: 5px;
  305. right: 15px;
  306. }
  307. }
  308. // title-box
  309. .lli-index-title-box {
  310. margin: 44rpx 0 32rpx;
  311. display: flex;
  312. justify-content: space-between;
  313. align-items: center;
  314. .index-title {
  315. font-size: 32rpx;
  316. color: #333;
  317. font-weight: 800;
  318. display: inline-flex;
  319. align-items: center;
  320. }
  321. .index-title:before {
  322. content: '';
  323. width: 3px;
  324. height: 30rpx;
  325. background: $uni-primary;
  326. margin-right: 8px;
  327. display: block;
  328. }
  329. .index-sub-title {
  330. font-size: 24rpx;
  331. color: #9c9c9c;
  332. font-weight: normal;
  333. cursor: pointer;
  334. }
  335. }
  336. // card
  337. .lli-card-box {
  338. width: 100%;
  339. display: flex;
  340. justify-content: space-between;
  341. flex-wrap: wrap;
  342. margin-bottom: 8px;
  343. cursor: pointer;
  344. }
  345. .lli-card-item {
  346. width: 49%;
  347. flex: unset;
  348. border-radius: 20rpx;
  349. background-color: #ffffff;
  350. padding: 12rpx 12rpx 0!important;
  351. box-sizing: border-box;
  352. margin-bottom: 20rpx!important;
  353. .lli-card-image {
  354. max-width: 100%;
  355. height: 180rpx;
  356. border-radius: 8rpx;
  357. }
  358. .custom-cover {
  359. max-width: 100%;
  360. height: 180rpx;
  361. border-radius: 8rpx;
  362. overflow: hidden;
  363. position: relative;
  364. }
  365. .cover-content {
  366. position: absolute;
  367. bottom: 0;
  368. left: 0;
  369. padding: 0 12rpx;
  370. background: rgba(0, 0, 0, 0.29);
  371. color: #fff;
  372. font-size: 22rpx;
  373. border-radius: 0 12rpx 0 12rpx;
  374. }
  375. .lli-card-name {
  376. font-size: 28rpx;
  377. line-height: 36rpx;
  378. color: #565656;
  379. margin: 20rpx 0;
  380. display: -webkit-box;
  381. -webkit-line-clamp: 2;
  382. overflow: hidden;
  383. text-overflow: ellipsis;
  384. -webkit-box-orient: vertical;
  385. }
  386. }
  387. }
  388. </style>