index.vue 7.0 KB

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