index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="lli-index-page">
  3. <customNavbarVue title="首页"></customNavbarVue>
  4. <!-- banner -->
  5. <view class="index-imgbox">
  6. <img :src="banners||defaultbanners" class="index-banner-img" />
  7. </view>
  8. <!-- meul-box -->
  9. <view class="index-meul-box">
  10. <view v-for="(item ,index) in menuList" :index="index" :key="index"
  11. @click="gridClick(index)" 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">{{item.badge}}</view>
  15. </view>
  16. </view>
  17. <!-- 课程list -->
  18. <view class="lli-index-title-box">
  19. <text class="index-title">最热课程</text>
  20. <text class="index-sub-title" @click="developClick">查看更多 ></text>
  21. </view>
  22. <view class="lli-card-box">
  23. <uni-card padding="0" margin="0" spacing="0" :is-shadow="false" :border="false"
  24. v-for="(item ,index) in courseCardList" :index="index" :key="index" class="lli-card-item"
  25. @click="developClick(index)">
  26. <view class="custom-cover">
  27. <image class="lli-card-image" mode="aspectFill" :src="item.pic || defultKcImg"></image>
  28. <view class="cover-content" v-if="item.status">
  29. <text>{{statusCodeKc[item.status]}}</text>
  30. </view>
  31. </view>
  32. <text class="lli-card-name">{{item.name}}</text>
  33. </uni-card>
  34. </view>
  35. <!-- 考试list -->
  36. <view class="lli-index-title-box">
  37. <text class="index-title">最热考试</text>
  38. <text class="index-sub-title" @click="handleCheckMoreKs">查看更多 ></text>
  39. </view>
  40. <view class="lli-card-box">
  41. <uni-card padding="0" margin="0" spacing="0" :is-shadow="false" :border="false"
  42. v-for="(item ,index) in examCardList" :index="index" :key="index" class="lli-card-item"
  43. @click="handleClickKs(item)">
  44. <view class="custom-cover">
  45. <image class="lli-card-image" mode="aspectFill" :src="item.pic || defultKsImg"></image>
  46. <view class="cover-content" v-if="item.status">
  47. <text>{{statusCodeKs[item.status]}}</text>
  48. </view>
  49. </view>
  50. <text class="lli-card-name">{{item.ksName}}</text>
  51. </uni-card>
  52. </view>
  53. <!-- 考试须知 -->
  54. <kaoshixuzhi ref="ksxzRef" @confirm="handleConfirm"></kaoshixuzhi>
  55. </view>
  56. </template>
  57. <script setup>
  58. import customNavbarVue from "@/components/custom-navbar/custom-navbar.vue";
  59. import {
  60. kaoShiApply,
  61. getClientKaoshiInfo
  62. } from "@/api/exam.js";
  63. import kaoshixuzhi from "@/components/kaoshixuzhi/kaoshixuzhi.vue"
  64. import {
  65. ref,
  66. reactive
  67. } from "vue";
  68. import {
  69. getCourseList,
  70. getNoticeCount,
  71. getExamList
  72. } from '@/api/index.js';
  73. import {
  74. onLoad
  75. } from "@dcloudio/uni-app"
  76. import cacheManager from '@/utils/cacheManager.js'
  77. const banners = ref('');
  78. const defaultbanners = ref('');
  79. const defultKsImg = ref('');
  80. const defultKcImg = ref('');
  81. const statusCodeKc = ref(['未开始', '可以学习', '已学完', '学习中', '已结束']);
  82. const statusCodeKs = ref(['未开始', '可以考试', '再次考试', '考试中', '已结束', '未报名', '报名审核中', '审核未通过', '等待人工评分']);
  83. let menuList = ref([
  84. {
  85. url: '',
  86. text: '我的考试',
  87. },
  88. {
  89. url: '',
  90. text: '我的成绩',
  91. },
  92. {
  93. url: '',
  94. text: '每日一练',
  95. },
  96. {
  97. url: '',
  98. text: '公告',
  99. badge: 0,
  100. },
  101. ]);
  102. let courseCardList = ref([]);
  103. let examCardList = ref([]);
  104. let noticeCount = ref(0);
  105. const examNoticeInfo = ref(null); // 考试须知数据
  106. const ksxzRef = ref(null);
  107. const activeKs = ref(null);
  108. onLoad(() => {
  109. uni.showLoading({
  110. title: '加载中'
  111. });
  112. defaultbanners.value = cacheManager.get('projectImg').index_banner
  113. defultKsImg.value = cacheManager.get('projectImg').index_ks_default
  114. defultKcImg.value = cacheManager.get('projectImg').index_kc_default
  115. menuList.value[0].url = cacheManager.get('projectImg').index_kc_img
  116. menuList.value[1].url = cacheManager.get('projectImg').index_ks_img
  117. menuList.value[2].url = cacheManager.get('projectImg').index_lx_img
  118. menuList.value[3].url = cacheManager.get('projectImg').index_gg_img
  119. getNoticeCountData();
  120. getCourseListData();
  121. getExamListData();
  122. uni.hideLoading();
  123. });
  124. function getNoticeCountData() {
  125. let req = {
  126. 'page': 1,
  127. 'size': 4,
  128. 'status': 1,
  129. };
  130. getNoticeCount(req).then(res => {
  131. menuList.value[3].badge = res.data.noticeCount || 0;
  132. });
  133. };
  134. function getCourseListData() {
  135. let req = {
  136. 'page': 1,
  137. 'size': 4,
  138. 'status': 1,
  139. };
  140. getCourseList(req).then(res => {
  141. courseCardList.value = res.data.data || [];
  142. });
  143. };
  144. function getExamListData() {
  145. let req = {
  146. 'page': 1,
  147. 'size': 4,
  148. 'status': 1,
  149. };
  150. getExamList(req).then(res => {
  151. examCardList.value = res.data.data || [];
  152. });
  153. };
  154. function gridClick(index) {
  155. switch (index) {
  156. case 0:
  157. /* uni.switchTab({
  158. url: '/pages/course/index'
  159. }); */
  160. uni.switchTab({
  161. url: '/pages/exam/index'
  162. });
  163. break;
  164. case 1:
  165. uni.switchTab({
  166. url: '/pages/score/index'
  167. });
  168. return false
  169. break;
  170. case 2:
  171. uni.showToast({
  172. icon: 'none',
  173. title: '开发中,敬请期侍!',
  174. })
  175. return false
  176. /* uni.navigateTo({
  177. url: '/pages/lianxi/index'
  178. }) */
  179. break;
  180. case 3:
  181. /* uni.navigateTo({
  182. url: '/pages/my/mesList?from=indexPeixun'
  183. }) */
  184. uni.showToast({
  185. icon: 'none',
  186. title: '开发中,敬请期侍!',
  187. })
  188. return false
  189. break;
  190. }
  191. }
  192. function developClick() {
  193. uni.showToast({
  194. icon: 'none',
  195. title: '开发中,敬请期侍!',
  196. });
  197. }
  198. function goKaoshiPage(data) {
  199. uni.navigateTo({
  200. url: `/subpkgExam/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  201. })
  202. }
  203. function handleConfirm() {
  204. goKaoshiPage(activeKs.value)
  205. }
  206. function showKaoshiXuzhi() {
  207. const option = {
  208. ksId: activeKs.value.ksId
  209. }
  210. getClientKaoshiInfo(option).then(res => {
  211. examNoticeInfo.value = res.data;
  212. // 校验抓拍
  213. doCheckZhuapai()
  214. })
  215. }
  216. function doCheckZhuapai() {
  217. if (examNoticeInfo.value.zhuapai) {
  218. // 存在抓拍
  219. } else {
  220. // 不存在抓拍
  221. ksxzRef.value.showDialog(examNoticeInfo.value)
  222. }
  223. }
  224. function handleClickKs(data) {
  225. activeKs.value = data;
  226. console.log('ddddd', data)
  227. if (data.status == 0) {
  228. // 未开始
  229. showKaoshiXuzhi()
  230. }
  231. if (data.status == 1) {
  232. // 可以考试
  233. showKaoshiXuzhi()
  234. }
  235. if (data.status == 2) {
  236. // 再次考试
  237. showKaoshiXuzhi()
  238. }
  239. if (data.status == 3) {
  240. // 考试中
  241. showKaoshiXuzhi()
  242. }
  243. if (data.status == 4) {
  244. // 已结束
  245. uni.showToast({
  246. title: '考试已结束',
  247. icon: 'none'
  248. })
  249. }
  250. if (data.status == 5) {
  251. // 未报名
  252. kaoShiApply({
  253. ksId: data.ksId
  254. }).then(res => {
  255. uni.showToast({
  256. title: '报名成功',
  257. icon: 'none'
  258. })
  259. scrollRef.value.onRefresh()
  260. })
  261. }
  262. }
  263. function handleCheckMoreKs() {
  264. uni.switchTab({
  265. url: '/pages/exam/index'
  266. })
  267. }
  268. </script>