index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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" @tap="$navigateBack">
  12. <view class="iconfont icon-zuojiantou"></view>
  13. </view>
  14. <view class="kaoshi-head-m">{{type == '1' ? '正式考试' : '模拟考试'}}</view>
  15. </view>
  16. </view>
  17. <!--#endif-->
  18. <view class="kaoshi-tiku">
  19. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  20. :down="downOption" :up="upOption">
  21. <block v-for="(item, index) in list" :key="index">
  22. <view class="kaoshi-tiku-content" @tap="choice_exam(item)">
  23. <view class="pub-flex-1">
  24. <view class="kaoshi-tiku-content-flex">
  25. <view class="kaoshi-tiku-content-top">
  26. <view>{{item.exam_name}}
  27. <view v-if="item.is_vip == 1 && !subjectVip" class="vip">
  28. <image src="../../../static/img/vip.png" mode=""></image>
  29. <view>VIP</view>
  30. </view></view>
  31. </view>
  32. </view>
  33. <view class="kaoshi-tiku-content-flex">
  34. <view class="kaoshi-tiku-content-bottom">
  35. <view class="iconfont icon-shijian1"></view>
  36. <view class="pub-gray">{{item.start_date}} - {{item.end_date}}</view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </block>
  42. </mescroll-body>
  43. </view>
  44. <view class="tan" v-if="showModal">
  45. <view class="tan-mask" @tap="isShowModal"></view>
  46. <view class="tan-modal">
  47. <view class="tan-title">
  48. <view>{{current_exam.exam_name}}</view>
  49. </view>
  50. <view class="tan-content">
  51. <view class="exam-tan-content">
  52. <view class="exam-tan-content-flex">
  53. <span>题数</span>
  54. <view>{{current_exam.num}}题</view>
  55. </view>
  56. <view class="exam-tan-content-flex">
  57. <span>总分</span>
  58. <view>{{current_exam.score}}分</view>
  59. </view>
  60. <view class="exam-tan-content-flex">
  61. <span>参考时间</span>
  62. <view>{{current_exam.givetime}}分钟</view>
  63. </view>
  64. <view class="exam-tan-content-flex">
  65. <span>模式</span>
  66. <view>{{current_exam.type_text}}</view>
  67. </view>
  68. </view>
  69. <view class="exam-tan-button" @tap="examBegin(current_exam)">开始答题
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. <authVip v-if="showAuthVip" @hideAuthVip="showAuthVip = false"></authVip>
  75. </view>
  76. </template>
  77. <script>
  78. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  79. import {
  80. mapState
  81. } from 'vuex'
  82. import authVip from '@/components/authVip.vue'
  83. export default {
  84. mixins: [MescrollMixin], // 使用mixin
  85. data() {
  86. return {
  87. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  88. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  89. downOption: {
  90. use: true, // 是否启用下拉刷新; 默认true
  91. auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
  92. native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
  93. },
  94. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  95. upOption: {
  96. page: {
  97. num: 0,
  98. size: 10 // 每页数据的数量,默认10
  99. },
  100. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  101. empty: {
  102. tip: '暂无相关数据'
  103. }
  104. },
  105. // 列表数据
  106. list: [],
  107. type: 0, //1 考试 2 模拟考试
  108. current_exam: {},
  109. showModal: false,
  110. showAuthVip: false,
  111. }
  112. },
  113. onLoad(opts) {
  114. this.type = opts.from_type
  115. uni.setNavigationBarTitle({
  116. title: this.type == 1 ? '正式考试' : '模拟考试'
  117. });
  118. },
  119. async onShow() {
  120. if (this.userinfo.token) {
  121. await this.$myUserLogin.getSubvip(this.subject.id)
  122. }
  123. },
  124. mounted() {},
  125. computed: {
  126. ...mapState(['subject', 'userinfo', 'subjectVip']),
  127. },
  128. components: {
  129. authVip
  130. },
  131. onShow() {},
  132. methods: {
  133. /*上拉加载的回调*/
  134. async upCallback(page) {
  135. let pageNum = page.num; // 页码, 默认从1开始
  136. let pageSize = page.size; // 页长, 默认每页10条
  137. let res = await this.$myHttp.post({
  138. url: this.type == '1' ? this.$myHttp.urlMap.examinationList : this.$myHttp.urlMap
  139. .mockExaminationList,
  140. data: {
  141. subject_id: this.subject.id,
  142. page: pageNum,
  143. limit: pageSize
  144. },
  145. needLogin: true
  146. })
  147. if (res.code == 1) {
  148. // 接口返回的当前页数据列表 (数组)
  149. let curPageData = res.data.data;
  150. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  151. let curPageLen = curPageData.length;
  152. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  153. // let totalPage = data.xxx;
  154. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  155. let totalSize = res.data.total;
  156. this.mescroll.endBySize(curPageLen, totalSize);
  157. if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
  158. this.list = this.list.concat(curPageData); //追加新数据
  159. } else {
  160. this.mescroll.endErr()
  161. }
  162. // 此处仍可以继续写其他接口请求...
  163. // 调用其他方法...
  164. },
  165. isShowModal: function() {
  166. this.showModal = !this.showModal
  167. },
  168. // 考试开始,向后台发送开始考试的考试id,返回当前考试结束时间
  169. async examBegin(item) {
  170. let res = await this.$myHttp.post({
  171. url: this.$myHttp.urlMap.exam_begin,
  172. data: {
  173. exam_id: item.id
  174. },
  175. needLogin: true
  176. });
  177. if (res.code == 1) {
  178. let end_time = res.data.endtime
  179. this.goto_detail(item, end_time)
  180. }
  181. },
  182. goto_detail(item, end_time) {
  183. this.showModal = !this.showModal
  184. this.$openrul('/pages/examination/examinationList/detail?id=' + item.id + '&from_type=' + item.type +
  185. '&exam_name=' + item.exam_name + '&title=' + item.type_text + '&end_time=' + end_time)
  186. },
  187. choice_exam(item) {
  188. if (!this.subjectVip && item.is_vip) {
  189. this.showAuthVip = true
  190. return
  191. }
  192. if (item.is_allow == 1) {
  193. this.current_exam = item
  194. this.$nextTick(() => {
  195. this.isShowModal()
  196. })
  197. } else if (item.is_allow == 0) {
  198. uni.showToast({
  199. icon: 'none',
  200. title: '您已参加过本场考试,不能重复考试'
  201. })
  202. return;
  203. }
  204. }
  205. }
  206. }
  207. </script>
  208. <style>
  209. page {
  210. background: #f6f7f9;
  211. }
  212. /*考试列表*/
  213. .kaoshi-tiku {
  214. background: #fff;
  215. }
  216. .kaoshi-tiku-content {
  217. width: 92%;
  218. margin: 0 auto;
  219. display: flex;
  220. flex-direction: row;
  221. align-items: center;
  222. justify-content: space-between;
  223. font-size: 16px;
  224. padding: 14px 0;
  225. border-bottom: solid 1px #f5f5f5;
  226. }
  227. .kaoshi-tiku-content-flex {
  228. width: 100%;
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. }
  233. .kaoshi-tiku-content .icon-arrow {
  234. padding-left: 13px;
  235. color: #b3b3b3;
  236. }
  237. .kaoshi-tiku-content .icon-suo {
  238. padding-left: 13px;
  239. font-size: 24px;
  240. color: #d0cfcf;
  241. }
  242. .kaoshi-tiku-content .kaoshi-tiku-content-flex:first-child {
  243. padding-bottom: 6px;
  244. }
  245. .index-tiku-content .kaoshi-tiku-content-flex:last-child {
  246. font-size: 13px;
  247. color: #b4b3b3;
  248. }
  249. .kaoshi-tiku-content-top {
  250. display: flex;
  251. align-items: center;
  252. }
  253. .kaoshi-tiku-content-top img {
  254. width: 20px;
  255. height: 22px;
  256. margin-right: 10px;
  257. }
  258. .kaoshi-tiku-content-bottom {
  259. display: flex;
  260. align-items: center;
  261. font-size: 13px;
  262. }
  263. .kaoshi-tiku-content-flex .icon-renwu-tuandui {
  264. margin: 0 3px 0 0;
  265. color: #d0d0d0;
  266. font-size: 18px;
  267. }
  268. .icon-shijian1 {
  269. color: #3c7bfc;
  270. font-size: 18px;
  271. padding-right: 2px;
  272. }
  273. /*弹窗*/
  274. .tan-mask {
  275. position: fixed;
  276. z-index: 999;
  277. top: 0;
  278. right: 0;
  279. left: 0;
  280. bottom: 0;
  281. background: rgba(0, 0, 0, 0.6);
  282. }
  283. .tan-modal {
  284. position: fixed;
  285. z-index: 999;
  286. width: 80%;
  287. max-width: 300px;
  288. top: 50%;
  289. left: 50%;
  290. -webkit-transform: translate(-50%, -50%);
  291. transform: translate(-50%, -50%);
  292. background-color: #fff;
  293. text-align: center;
  294. border-radius: 3px;
  295. overflow: hidden;
  296. }
  297. .tan-title {
  298. padding: 15px 0;
  299. border-bottom: solid 1px #f4f4f4;
  300. }
  301. .tan-title view {
  302. font-weight: 400;
  303. font-size: 17px;
  304. word-wrap: break-word;
  305. word-break: break-all;
  306. overflow: hidden;
  307. text-overflow: ellipsis;
  308. display: -webkit-box;
  309. -webkit-line-clamp: 2;
  310. -webkit-box-orient: vertical;
  311. }
  312. .tan-content {
  313. width: 90%;
  314. margin: 0 auto;
  315. font-size: 14px;
  316. }
  317. .exam-tan-content-flex {
  318. display: flex;
  319. width: 91%;
  320. margin: 0 auto;
  321. padding: 13px 0;
  322. border-bottom: solid 1px #f4f4f4;
  323. }
  324. .exam-tan-content-flex span {
  325. color: #767676;
  326. width: 42%;
  327. text-align: left;
  328. }
  329. .exam-tan-button {
  330. background: #3c7bfc;
  331. color: #fff;
  332. padding: 10px;
  333. margin: 15px 0;
  334. border-radius: 4px;
  335. font-size: 16px;
  336. display: block !important;
  337. }
  338. </style>