index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  1. <template>
  2. <view>
  3. <!--#ifdef APP-PLUS-->
  4. <view class="lz-status_bar">
  5. <view class="lz-top_view"></view>
  6. </view>
  7. <!--#endif-->
  8. <!-- #ifndef MP-WEIXIN -->
  9. <view class="kaoshi-head">
  10. <view class="kaoshi-head-top">
  11. <view class="kaoshi-head-left"></view>
  12. <view class="kaoshi-head-m">考试</view>
  13. </view>
  14. </view>
  15. <!--#endif-->
  16. <view class="kaoshi-head-nav">
  17. <view class="kaoshi-head-nav-flex">
  18. <view @tap="navTo('/pages/examination/examinationList/index?from_type=2')">
  19. <image :src="static_media.img01" class="kaoshi-head-nav-img"></image>
  20. <view>模拟考试</view>
  21. </view>
  22. </view>
  23. <view class="kaoshi-head-nav-flex">
  24. <view @tap="navTo('/pages/examination/examinationList/index?from_type=1')">
  25. <image :src="static_media.img02" class="kaoshi-head-nav-img"></image>
  26. <view>正式考试</view>
  27. </view>
  28. </view>
  29. <view class="kaoshi-head-nav-flex">
  30. <view @tap="navTo('/pages/my/examWrongQuestion/index')">
  31. <image :src="static_media.img03" class="kaoshi-head-nav-img"></image>
  32. <view>考试错题</view>
  33. </view>
  34. </view>
  35. <view class="kaoshi-head-nav-flex">
  36. <view @tap="navTo('/pages/my/recording/index')">
  37. <image :src="static_media.img04" class="kaoshi-head-nav-img"></image>
  38. <view>考试记录</view>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="kaoshi-tiku-title" v-if="mockList.length > 0">
  43. <view class="kaoshi-tiku-title-l">模拟考试</view>
  44. <navigator open-type="navigate" url="/pages/examination/examinationList/index?from_type=2"
  45. hover-class="none" class="kaoshi-tiku-title-r">
  46. 查看全部
  47. </navigator>
  48. </view>
  49. <view class="kaoshi-tiku">
  50. <block v-for="(item, index) in mockList" :key="index">
  51. <view class="kaoshi-tiku-content" @tap="choice_exam(item)">
  52. <view class="kaoshi-tiku-content-flex">
  53. <view class="kaoshi-tiku-content-top">
  54. <view>{{ item.exam_name }}
  55. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  56. <image src="../../static/img/vip.png" mode=""></image>
  57. <view>VIP</view>
  58. </view></view>
  59. </view>
  60. </view>
  61. <view class="kaoshi-tiku-content-flex">
  62. <view class="kaoshi-tiku-content-bottom">
  63. <view class="iconfont icon-shijian1"></view>
  64. <view class="pub-gray">{{item.start_date}} - {{item.end_date}}</view>
  65. </view>
  66. </view>
  67. </view>
  68. </block>
  69. </view>
  70. <view class="kaoshi-tiku-title" v-if="examList.length > 0">
  71. <view class="kaoshi-tiku-title-l">正式考试</view>
  72. <navigator open-type="navigate" url="/pages/examination/examinationList/index?from_type=1"
  73. hover-class="none" class="kaoshi-tiku-title-r">
  74. 查看全部
  75. </navigator>
  76. </view>
  77. <view class="kaoshi-tiku">
  78. <block v-for="(item, index) in examList" :key="index">
  79. <view class="kaoshi-tiku-content" @tap="choice_exam(item)">
  80. <view class="kaoshi-tiku-content-flex">
  81. <view class="kaoshi-tiku-content-top">
  82. <view>{{ item.exam_name }}
  83. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  84. <image src="../../static/img/vip.png" mode=""></image>
  85. <view>VIP</view>
  86. </view></view>
  87. </view>
  88. </view>
  89. <view class="kaoshi-tiku-content-flex">
  90. <view class="kaoshi-tiku-content-bottom">
  91. <view class="iconfont icon-shijian1"></view>
  92. <view class="pub-gray">{{item.start_date}} - {{item.end_date}}</view>
  93. </view>
  94. </view>
  95. </view>
  96. </block>
  97. </view>
  98. <view class="tan" v-if="showModal">
  99. <view class="tan-mask" @tap="isShowModal"></view>
  100. <view class="tan-modal">
  101. <view class="tan-title">
  102. <view>{{current_exam.exam_name}}</view>
  103. </view>
  104. <view class="tan-content">
  105. <view class="exam-tan-content">
  106. <view class="exam-tan-content-flex">
  107. <span>题数</span>
  108. <view>{{current_exam.num}}</view>
  109. </view>
  110. <view class="exam-tan-content-flex">
  111. <span>总分</span>
  112. <view>{{current_exam.score}}</view>
  113. </view>
  114. <view class="exam-tan-content-flex">
  115. <span>参考时间</span>
  116. <view>{{current_exam.givetime}}分钟</view>
  117. </view>
  118. <view class="exam-tan-content-flex">
  119. <span>模式</span>
  120. <view>{{current_exam.type_text}}</view>
  121. </view>
  122. </view>
  123. <view class="exam-tan-button" @tap="examBegin(current_exam)">开始答题
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. <authVip v-if="showAuthVip" @hideAuthVip="showAuthVip = false"></authVip>
  129. </view>
  130. </template>
  131. <script>
  132. import {
  133. mapState
  134. } from 'vuex';
  135. import Error from '@/core/untils/error/index';
  136. import authVip from '@/components/authVip.vue'
  137. export default {
  138. data() {
  139. return {
  140. mockList: [],
  141. examList: [],
  142. showModal: false,
  143. current_exam: [],
  144. showAuthVip: false,
  145. };
  146. },
  147. async onShow() {
  148. if (this.userinfo.token) {
  149. this.get_mock_list();
  150. this.get_exam_list();
  151. await this.$myUserLogin.getSubvip(this.subject.id)
  152. }
  153. },
  154. onLoad() {
  155. // #ifdef MP-WEIXIN
  156. wx.showShareMenu({
  157. withShareTicket: true,
  158. menus: ["shareAppMessage", "shareTimeline"]
  159. })
  160. // #endif
  161. },
  162. computed: {
  163. ...mapState(['subject', 'userinfo', 'subjectVip']),
  164. static_media() {
  165. return {
  166. img01: this.$myConfig.localMedia + '/static/img/kaoshi-icon1.png',
  167. img02: this.$myConfig.localMedia + '/static/img/kaoshi-icon2.png',
  168. img03: this.$myConfig.localMedia + '/static/img/kaoshi-icon3.png',
  169. img04: this.$myConfig.localMedia + '/static/img/kaoshi-icon4.png'
  170. };
  171. },
  172. },
  173. components: {
  174. authVip
  175. },
  176. methods: {
  177. isShowModal: function() {
  178. this.showModal = !this.showModal
  179. },
  180. //跳转前需要登录
  181. navTo(url) {
  182. if (this.$myUserLogin.getToken()) {
  183. this.$openrul(url)
  184. } else {
  185. Error.errorNotLoggedIn();
  186. }
  187. },
  188. //点击考试项目,弹窗显示相关信息
  189. choice_exam(item) {
  190. if (!this.subjectVip && item.is_vip) {
  191. this.showAuthVip = true
  192. return
  193. }
  194. if (item.is_allow == 1) {
  195. this.current_exam = item
  196. this.$nextTick(() => {
  197. this.isShowModal()
  198. })
  199. } else if (item.is_allow == 0) {
  200. uni.showToast({
  201. icon: 'none',
  202. title: '您已参加过本场考试,不能重复考试'
  203. })
  204. return;
  205. }
  206. },
  207. async get_mock_list() {
  208. let res = await this.$myHttp.post({
  209. url: this.$myHttp.urlMap.mockExaminationList,
  210. data: {
  211. subject_id: this.subject.id,
  212. page: 1,
  213. limit: 4
  214. },
  215. needLogin: true
  216. });
  217. if (res.code === 1) {
  218. this.mockList = res.data.data
  219. }
  220. },
  221. async get_exam_list() {
  222. let res = await this.$myHttp.post({
  223. url: this.$myHttp.urlMap.examinationList,
  224. data: {
  225. subject_id: this.subject.id,
  226. page: 1,
  227. limit: 4
  228. },
  229. needLogin: true
  230. });
  231. if (res.code === 1) {
  232. this.examList = res.data.data
  233. }
  234. },
  235. // 考试开始,向后台发送开始考试的考试id,返回当前考试结束时间
  236. async examBegin(item) {
  237. let res = await this.$myHttp.post({
  238. url: this.$myHttp.urlMap.exam_begin,
  239. data: {
  240. exam_id: item.id
  241. },
  242. needLogin: true
  243. });
  244. if (res.code == 1) {
  245. let end_time = res.data.endtime
  246. this.goto_detail(item, end_time)
  247. }
  248. },
  249. goto_detail(item, end_time) {
  250. this.showModal = !this.showModal
  251. this.$openrul('/pages/examination/examinationList/detail?id=' + item.id + '&from_type=' + item.type +
  252. '&exam_name=' + item.exam_name + '&title=' + item.type_text + '&end_time=' + end_time)
  253. },
  254. }
  255. };
  256. </script>
  257. <style>
  258. page {
  259. background: #f6f6f6;
  260. }
  261. .kaoshi-head-nav {
  262. display: flex;
  263. justify-content: center;
  264. text-align: center;
  265. font-size: 14px;
  266. color: #605d70;
  267. padding: 16px 0;
  268. z-index: 10000;
  269. background: #fff;
  270. width: 93%;
  271. margin: 11px auto;
  272. border-radius: 6px;
  273. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  274. }
  275. .kaoshi-head-nav .kaoshi-head-nav-flex {
  276. flex: 1;
  277. }
  278. .kaoshi-head-nav-img {
  279. width: 38px;
  280. height: 38px;
  281. }
  282. .kaoshi-tiku-title {
  283. width: 92%;
  284. margin: 0 auto;
  285. padding: 12px 0;
  286. display: flex;
  287. align-items: center;
  288. justify-content: space-between;
  289. }
  290. .kaoshi-tiku-title-l {
  291. display: flex;
  292. font-weight: bold;
  293. font-size: 17px;
  294. }
  295. .kaoshi-tiku-title-r {
  296. color: #000;
  297. border: solid 1px #d8d8d8;
  298. padding: 5px 13px;
  299. border-radius: 35px;
  300. font-size: 12px;
  301. }
  302. .kaoshi-tiku {
  303. background: #fff;
  304. width: 93%;
  305. margin: 0 auto 8px;
  306. border-radius: 6px;
  307. box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
  308. }
  309. .kaoshi-tiku-content {
  310. width: 92%;
  311. margin: 0 auto;
  312. display: flex;
  313. align-items: center;
  314. flex-direction: column;
  315. font-size: 14px;
  316. padding: 10px 0;
  317. border-bottom: solid 1px #f5f5f5;
  318. }
  319. .kaoshi-tiku-content .icon-arrow {
  320. padding-left: 13px;
  321. color: #b3b3b3;
  322. }
  323. .kaoshi-tiku-content-flex {
  324. width: 100%;
  325. display: flex;
  326. justify-content: space-between;
  327. align-items: inherit;
  328. }
  329. .kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
  330. padding-bottom: 6px;
  331. }
  332. .kaoshi-tiku-content .kaoshi-tiku-content:last-child {
  333. font-size: 14px;
  334. }
  335. .kaoshi-tiku .kaoshi-tiku-content:last-child {
  336. border-bottom: none;
  337. }
  338. .icon-shijian1 {
  339. color: #3c7bfc;
  340. font-size: 18px;
  341. padding-right: 2px;
  342. }
  343. .kaoshi-tiku-content-top {
  344. display: flex;
  345. align-items: center;
  346. flex: 1;
  347. font-size: 16px;
  348. }
  349. .kaoshi-tiku-content-top img {
  350. width: 20px;
  351. height: 22px;
  352. margin-right: 10px;
  353. }
  354. .kaoshi-tiku-content-bottom {
  355. font-size: 13px;
  356. display: flex;
  357. align-items: center;
  358. }
  359. /*弹窗*/
  360. .tan-mask {
  361. position: fixed;
  362. z-index: 999;
  363. top: 0;
  364. right: 0;
  365. left: 0;
  366. bottom: 0;
  367. background: rgba(0, 0, 0, 0.6);
  368. }
  369. .tan-modal {
  370. position: fixed;
  371. z-index: 999;
  372. width: 80%;
  373. max-width: 300px;
  374. top: 50%;
  375. left: 50%;
  376. -webkit-transform: translate(-50%, -50%);
  377. transform: translate(-50%, -50%);
  378. background-color: #fff;
  379. text-align: center;
  380. border-radius: 3px;
  381. overflow: hidden;
  382. }
  383. .tan-title {
  384. padding: 15px 0;
  385. border-bottom: solid 1px #f4f4f4;
  386. }
  387. .tan-title view {
  388. font-weight: 400;
  389. font-size: 17px;
  390. word-wrap: break-word;
  391. word-break: break-all;
  392. overflow: hidden;
  393. text-overflow: ellipsis;
  394. display: -webkit-box;
  395. -webkit-line-clamp: 2;
  396. -webkit-box-orient: vertical;
  397. }
  398. .tan-content {
  399. width: 90%;
  400. margin: 0 auto;
  401. font-size: 14px;
  402. }
  403. .exam-tan-content-flex {
  404. display: flex;
  405. width: 91%;
  406. margin: 0 auto;
  407. padding: 13px 0;
  408. border-bottom: solid 1px #f4f4f4;
  409. }
  410. .exam-tan-content-flex span {
  411. color: #767676;
  412. width: 42%;
  413. text-align: left;
  414. }
  415. .exam-tan-button {
  416. background: #3c7bfc;
  417. color: #fff;
  418. padding: 10px;
  419. margin: 15px 0;
  420. border-radius: 4px;
  421. font-size: 16px;
  422. display: block !important;
  423. }
  424. </style>