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