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