index.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. @change="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. url: '',
  85. text: '我的课程',
  86. },
  87. {
  88. url: '',
  89. text: '我的考试',
  90. },
  91. {
  92. url: '',
  93. text: '每日一练',
  94. },
  95. {
  96. url: '',
  97. text: '公告',
  98. badge: 0,
  99. },
  100. ]);
  101. let courseCardList = ref([]);
  102. let examCardList = ref([]);
  103. let noticeCount = ref(0);
  104. const examNoticeInfo = ref(null); // 考试须知数据
  105. const ksxzRef = ref(null);
  106. const activeKs = ref(null);
  107. onLoad(() => {
  108. uni.showLoading({
  109. title: '加载中'
  110. });
  111. defaultbanners.value = cacheManager.get('projectImg').index_banner
  112. defultKsImg.value = cacheManager.get('projectImg').index_ks_default
  113. defultKcImg.value = cacheManager.get('projectImg').index_kc_default
  114. menuList.value[0].url = cacheManager.get('projectImg').index_kc_img
  115. menuList.value[1].url = cacheManager.get('projectImg').index_ks_img
  116. menuList.value[2].url = cacheManager.get('projectImg').index_lx_img
  117. menuList.value[3].url = cacheManager.get('projectImg').index_gg_img
  118. getNoticeCountData();
  119. getCourseListData();
  120. getExamListData();
  121. uni.hideLoading();
  122. });
  123. function getNoticeCountData() {
  124. let req = {
  125. 'page': 1,
  126. 'size': 4,
  127. 'status': 1,
  128. };
  129. getNoticeCount(req).then(res => {
  130. menuList.value[3].badge = res.data.noticeCount || 0;
  131. });
  132. };
  133. function getCourseListData() {
  134. let req = {
  135. 'page': 1,
  136. 'size': 4,
  137. 'status': 1,
  138. };
  139. getCourseList(req).then(res => {
  140. courseCardList.value = res.data.data || [];
  141. });
  142. };
  143. function getExamListData() {
  144. let req = {
  145. 'page': 1,
  146. 'size': 4,
  147. 'status': 1,
  148. };
  149. getExamList(req).then(res => {
  150. examCardList.value = res.data.data || [];
  151. });
  152. };
  153. function gridClick(e) {
  154. let {
  155. index
  156. } = e.detail;
  157. switch (index) {
  158. case 0:
  159. /* uni.switchTab({
  160. url: '/pages/course/index'
  161. }); */
  162. uni.showToast({
  163. icon: 'none',
  164. title: '开发中,敬请期侍!',
  165. })
  166. return false
  167. break;
  168. case 1:
  169. uni.switchTab({
  170. url: '/pages/exam/index'
  171. });
  172. break;
  173. case 2:
  174. uni.showToast({
  175. icon: 'none',
  176. title: '开发中,敬请期侍!',
  177. })
  178. return false
  179. /* uni.navigateTo({
  180. url: '/pages/lianxi/index'
  181. }) */
  182. break;
  183. case 3:
  184. /* uni.navigateTo({
  185. url: '/pages/my/mesList?from=indexPeixun'
  186. }) */
  187. uni.showToast({
  188. icon: 'none',
  189. title: '开发中,敬请期侍!',
  190. })
  191. return false
  192. break;
  193. }
  194. }
  195. function developClick() {
  196. uni.showToast({
  197. icon: 'none',
  198. title: '开发中,敬请期侍!',
  199. });
  200. }
  201. function goKaoshiPage(data) {
  202. uni.navigateTo({
  203. url: `/subpkgExam/pages/exam/exam?ksId=${data.ksId}&zhuapai=${data.zhuapai}`
  204. })
  205. }
  206. function handleConfirm() {
  207. goKaoshiPage(activeKs.value)
  208. }
  209. function showKaoshiXuzhi() {
  210. const option = {
  211. ksId: activeKs.value.ksId
  212. }
  213. getClientKaoshiInfo(option).then(res => {
  214. examNoticeInfo.value = res.data;
  215. // 校验抓拍
  216. doCheckZhuapai()
  217. })
  218. }
  219. function doCheckZhuapai() {
  220. if (examNoticeInfo.value.zhuapai) {
  221. // 存在抓拍
  222. } else {
  223. // 不存在抓拍
  224. ksxzRef.value.showDialog(examNoticeInfo.value)
  225. }
  226. }
  227. function handleClickKs(data) {
  228. activeKs.value = data;
  229. console.log('ddddd', data)
  230. if (data.status == 0) {
  231. // 未开始
  232. showKaoshiXuzhi()
  233. }
  234. if (data.status == 1) {
  235. // 可以考试
  236. showKaoshiXuzhi()
  237. }
  238. if (data.status == 2) {
  239. // 再次考试
  240. showKaoshiXuzhi()
  241. }
  242. if (data.status == 3) {
  243. // 考试中
  244. showKaoshiXuzhi()
  245. }
  246. if (data.status == 4) {
  247. // 已结束
  248. uni.showToast({
  249. title: '考试已结束',
  250. icon: 'none'
  251. })
  252. }
  253. if (data.status == 5) {
  254. // 未报名
  255. kaoShiApply({
  256. ksId: data.ksId
  257. }).then(res => {
  258. uni.showToast({
  259. title: '报名成功',
  260. icon: 'none'
  261. })
  262. scrollRef.value.onRefresh()
  263. })
  264. }
  265. }
  266. function handleCheckMoreKs() {
  267. uni.switchTab({
  268. url: '/pages/exam/index'
  269. })
  270. }
  271. </script>