index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. <template>
  2. <view>
  3. <nav-bar title="模考预约" class="nav"></nav-bar>
  4. <view class="tabs">
  5. <view class="tab" :class="{ active: param.mockStatus == 0 }" data-index="1" @click="tab(0)">
  6. <view>未考试</view>
  7. </view>
  8. <view class="tab" :class="{ active: param.mockStatus == 1 }" data-index="2" @click="tab(1)">
  9. <view>已结束</view>
  10. </view>
  11. <view class="sort" @click="showSort = true">
  12. 筛选
  13. </view>
  14. </view>
  15. <view class="record">
  16. <template v-if=" param.mockStatus == 0">
  17. <view class="examList" v-for="(item,index) in recordList" :key="index">
  18. <view class="main">
  19. <view class="top" @click="showDetails(item)">
  20. <view class="subject">{{item.applyName}}</view>
  21. </view>
  22. <view class="item">
  23. <view class="left">项目</view>
  24. <view class="right">{{ item.businessName }} {{item.projectName}}</view>
  25. </view>
  26. <view class="item">
  27. <view class="left">专业</view>
  28. <view class="right">{{item.categoryName}}</view>
  29. </view>
  30. <view class="item">
  31. <view class="left">科目</view>
  32. <view class="right">{{item.subjectName}}</view>
  33. </view>
  34. <view class="item">
  35. <view class="left">考试时间</view>
  36. <view v-if="item.mockActivity == 0" class="right">
  37. {{ $method.timestampToTime(item.applySiteExamTime) }}
  38. {{ item.applySiteStartTime }} - {{ item.applySiteEndTime }}
  39. </view>
  40. </view>
  41. <view class="btn-wrap">
  42. <view class="btn-line">
  43. <!-- mockActivity 1是活动模考,0否 && (!item.handStatus || item.handStatus == 0)-->
  44. <view v-if="item.mockActivity == 1 " class="btn" @click="goExamCount(item,index)">去考试</view>
  45. <view v-else>
  46. <view class="btn test-disabled" v-if="goTest(item)" @click="goExamCount(item,index)">去考试</view>
  47. <view class="btn test-disabled" v-else-if="item.handStatus">已考试</view>
  48. <view class="btn" v-else @click="goExamCount(item,index)">去考试</view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. </view>
  54. </template>
  55. <template v-if=" param.mockStatus == 1">
  56. <view class="examList" v-for="(item,index) in recordList" :key="index">
  57. <view class="main">
  58. <view class="top" @click="showDetails(item)">
  59. <view class="subject">{{item.applyName}}</view>
  60. </view>
  61. <view class="item">
  62. <view class="left">项目</view>
  63. <view class="right">{{ item.businessName }} {{item.projectName}}</view>
  64. </view>
  65. <view class="item">
  66. <view class="left">专业</view>
  67. <view class="right">{{item.categoryName}}</view>
  68. </view>
  69. <view class="item">
  70. <view class="left">科目</view>
  71. <view class="right">{{item.subjectName}}</view>
  72. </view>
  73. <view class="item">
  74. <view class="left">考试时间</view>
  75. <view class="right">
  76. {{ $method.timestampToTime(item.applySiteExamTime) }}
  77. {{ item.applySiteStartTime }} - {{ item.applySiteEndTime }}
  78. </view>
  79. </view>
  80. <view class="btn-wrap">
  81. <view class="btn-line" v-if="item.reSubscribe == 1">
  82. <view class="btn border" @click="reApply(item)">重新预约</view>
  83. </view>
  84. <template v-else>
  85. <view class="btn-line">
  86. <view class="text" v-if="item.handStatus">当前报告含主观题需人工阅卷,阅卷完成后显示完整报告</view>
  87. <view class="text" v-if="!item.handStatus">由于未按时参加考试,主观题将不会提交至后台进行人工阅卷</view>
  88. <view class="btn border" :class="{disabled : item.canDo === 0,'btn--half':item.handStatus}" @click="doQuestion(item)">去做题</view>
  89. <view class="btn btn--half border" @click="report(item)" v-if="item.handStatus">查看报告</view>
  90. </view>
  91. <view class="btn-line" v-if="item.liveEndTime && item.liveStartTime && item.liveUrl">
  92. <view class="text-half">
  93. <view>模考讲解直播时间</view>
  94. <view>{{$method.timestampToTime(item.liveStartTime,false)}} - {{$method.timestampToTime(item.liveEndTime,false)}}</view>
  95. </view>
  96. <view class="btn btn--half border" @click="goLive(item)">去查看</view>
  97. </view>
  98. </template>
  99. </view>
  100. </view>
  101. </view>
  102. </template>
  103. </view>
  104. <view class="modal" :style="{top:modalTop+'px'}" v-if="showSort">
  105. <view class="content">
  106. <view class="item">
  107. <view class="item__title">考试时间</view>
  108. <view class="item__box">
  109. <view class="text">
  110. <picker mode="date" :value="param.startTime" :end="endDate" @change="bindDateFromChange">
  111. <view class="uni-input">{{param.startTime || '开始时间'}}</view>
  112. </picker>
  113. -
  114. <picker mode="date" :value="param.endTime" :end="endDate" @change="bindDateToChange">
  115. <view class="uni-input">{{param.endTime || '结束时间'}}</view>
  116. </picker>
  117. </view>
  118. <u-icon class="icon" name="calendar"></u-icon>
  119. </view>
  120. </view>
  121. <view class="item">
  122. <view class="item__title">考试标题</view>
  123. <view class="item__box">
  124. <picker class="picker" mode="selector" :range="listApplyName" range-key="applyName" :value="param.applyName" @change="bindTitleChange">
  125. <view style="width:650rpx;height:40rpx;">{{param.applyName}}</view>
  126. </picker>
  127. <u-icon class="icon" name="arrow-down"></u-icon>
  128. </view>
  129. </view>
  130. </view>
  131. <view class="modal_wrap" @click="showSort = false"></view>
  132. </view>
  133. </view>
  134. </template>
  135. <script>
  136. import { mapGetters } from 'vuex';
  137. import {WEBVIEW_URL} from '@/common/request.js'
  138. export default {
  139. data() {
  140. return {
  141. showSort:false,
  142. index: 0,
  143. list: [],
  144. list1: [],
  145. recordList: [],
  146. goodsData: {},
  147. param: {
  148. pageNum: 1,
  149. pageSize: 10,
  150. mockStatus:0,
  151. endTime:'',
  152. startTime:'',
  153. applyName:''
  154. },
  155. nowTime:0,
  156. dateFrom:'',
  157. dateTo:'',
  158. isRepeat:false,
  159. total: 0,
  160. activeIndex: 0,
  161. typeIndex:0,
  162. itemIndex:'',
  163. modalTop:0,
  164. endDate:'',
  165. titleName:3,
  166. listApplyName:[],
  167. };
  168. },
  169. computed:{
  170. ...mapGetters(['userInfo'])
  171. },
  172. onLoad(option) {
  173. this.param.mockStatus = option.state || 0
  174. this.endDate = this.$method.timestampToTime(new Date().getTime() / 1000).replace(/-/g,'/');
  175. this.mockSubscribeListSubscribe();
  176. uni.getSystemInfo({
  177. success:(e) => {
  178. let info = uni.createSelectorQuery().select(".nav");
  179. info.boundingClientRect((navData) => { //data - 各种参数
  180. let info = uni.createSelectorQuery().select(".tabs");
  181. info.boundingClientRect((tabData) => { //data - 各种参数
  182. this.modalTop = navData.height + tabData.height
  183. console.log(navData) // 获取元素宽度
  184. console.log(tabData) // 获取元素宽度
  185. }).exec()
  186. }).exec()
  187. }
  188. })
  189. },
  190. onPullDownRefresh() {
  191. let that = this;
  192. this.param.pageNum = 1;
  193. this.mockSubscribeListSubscribe();
  194. setTimeout(function() {
  195. uni.stopPullDownRefresh();
  196. }, 500);
  197. },
  198. onReachBottom() {
  199. console.log(this.total,'total');
  200. console.log(this.recordList.length,'length')
  201. if (this.recordList.length < this.total) {
  202. this.param.pageNum++;
  203. this.mockSubscribeListSubscribe();
  204. }
  205. },
  206. onShow() {
  207. this.nowTime = +this.$method.timest();
  208. if(this.itemIndex !== '') {
  209. this.refreshByIndex();
  210. }
  211. },
  212. methods: {
  213. mockApplyListApplyName() {
  214. let param = JSON.parse(JSON.stringify(this.param));
  215. if(param.endTime) {
  216. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  217. }
  218. if(param.startTime) {
  219. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  220. }
  221. console.log(param,'param')
  222. this.$api.mockApplyListApplyName(param).then((res) => {
  223. this.listApplyName = res.data.rows;
  224. console.log(this.listApplyName,'listApplyName')
  225. this.param.applyName = "";
  226. this.mockSubscribeListSubscribe();
  227. });
  228. },
  229. reApply(item){
  230. uni.redirectTo({
  231. url:'/pages5/examAppointList/index'
  232. })
  233. },
  234. report(item) {
  235. uni.navigateTo({
  236. url:
  237. "/pages5/examReport/index?&examId=" +
  238. item.examId +
  239. "&id=" +
  240. item.recordId+
  241. "&eachExamId="+item.eachExamId+
  242. "&subscribeId="+item.subscribeId
  243. });
  244. },
  245. doQuestion(item) {
  246. if(item.canDo === 0) {
  247. uni.showToast({
  248. icon:'none',
  249. msg:'请等待所有科目考试结束后再进入刷题'
  250. })
  251. return;
  252. }
  253. uni.navigateTo({
  254. url:'../examBank/index?examId='+item.examId+'&eachExamId='+item.eachExamId
  255. })
  256. },
  257. goTest(item) {
  258. if (item.mockActivity && item.mockActivity == 1) {
  259. return false
  260. }
  261. let startTime = this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteStartTime)
  262. let canGo = (startTime-this.nowTime) <= (600) && (startTime-this.nowTime) >= (-(item.timeLimit * 60) || 0)
  263. return !canGo
  264. },
  265. isStart(item) {
  266. let startTime = this.$method.TimeTotimestamp(
  267. this.$method.timestampToTime(item.applySiteExamTime) +
  268. " " +
  269. item.applySiteStartTime
  270. );
  271. return startTime - this.nowTime <= 600;
  272. },
  273. mockSubscribeListSubscribe() {
  274. let param = JSON.parse(JSON.stringify(this.param))
  275. if(param.endTime) {
  276. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  277. }
  278. if(param.startTime) {
  279. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  280. }
  281. this.$api.mockSubscribeListSubscribe(param).then(res => {
  282. this.recordList.push(...res.data.rows)
  283. this.total = res.data.total
  284. })
  285. },
  286. refreshByIndex() {
  287. let param = JSON.parse(JSON.stringify(this.param))
  288. if(param.endTime) {
  289. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  290. }
  291. if(param.startTime) {
  292. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  293. }
  294. param.pageNum = this.itemIndex+1;
  295. param.pageSize = 1
  296. this.$api.mockSubscribeListSubscribe(param).then(res => {
  297. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  298. this.itemIndex = ''
  299. })
  300. },
  301. goLive(item) {
  302. let uuid = new Date().valueOf() + ""
  303. // buyCourse 是否购买课程:1是 0否
  304. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='
  305. +item.liveUrl+'&buyCourse=1'+'&ident='+uuid)
  306. uni.navigateTo({
  307. url:`../../pages/webview/index?url=`+encode
  308. })
  309. },
  310. async goExamCount(item,index) {
  311. console.log('item', item)
  312. if (item.mockActivity && item.mockActivity == 1) {
  313. await this.$http({
  314. url: '/mock/apply/addMockTime',
  315. method: 'post',
  316. data: {
  317. applyId: item.applyId,
  318. duration: item.duration,
  319. majorId: item.majorId,
  320. subjectId: item.subjectId
  321. },
  322. }).then((res) => {
  323. const { examTime, startTime, endTime, eachExamId} = res.data.data
  324. item.applySiteExamTime = examTime // 当前时间的时间戳
  325. item.applySiteStartTime = startTime
  326. item.applySiteEndTime = endTime
  327. item.eachExamId = eachExamId
  328. // item.applySiteExamTime = parseInt(new Date().getTime()/1000) // 当前时间的时间戳
  329. // item.applySiteStartTime = this.$method.timestampToTime(new Date().getTime()/1000, false, false, true)
  330. // let min = item.duration * 60 *1000 + new Date().getTime()
  331. // item.applySiteEndTime = this.$method.timestampToTime(min/1000, false, false, true)
  332. console.log('item', item)
  333. })
  334. }
  335. if(this.goTest(item)) {
  336. uni.showToast({
  337. icon:'none',
  338. title:'不在考试时间'
  339. })
  340. return;
  341. }
  342. this.itemIndex = index;
  343. uni.navigateTo({
  344. url:'../examCount/index?start='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteStartTime)+'&limit='+item.timeLimit+'&examId='+item.examId+'&eachExamId='+item.eachExamId+'&subscribeId='+item.subscribeId+'&mockName='+item.applyName +'&examEndTime='+this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteEndTime)
  345. })
  346. },
  347. sort() {
  348. },
  349. appoint(item) {
  350. this.appointModal = true;
  351. },
  352. tab(state) {
  353. if(this.param.mockStatus == state) {
  354. return;
  355. }
  356. this.recordList = [];
  357. this.param.endTime = '';
  358. this.param.startTime = '';
  359. this.param.applyName = '';
  360. this.param.pageNum = 1;
  361. this.param.mockStatus = state;
  362. this.mockSubscribeListSubscribe()
  363. },
  364. bindDateFromChange(e) {
  365. this.param.startTime = e.detail.value
  366. this.param.pageNum = 1;
  367. this.param.applyName = '';
  368. this.recordList = []
  369. this.mockApplyListApplyName();
  370. },
  371. bindDateToChange(e) {
  372. this.param.endTime = e.detail.value
  373. this.param.pageNum = 1;
  374. this.param.applyName = '';
  375. this.recordList = []
  376. this.mockApplyListApplyName();
  377. },
  378. bindTitleChange(e) {
  379. if (this.listApplyName.length) {
  380. let index = e.detail.value;
  381. this.param.applyName = this.listApplyName[index].applyName
  382. } else {
  383. this.param.applyName =''
  384. }
  385. this.param.pageNum = 1;
  386. this.recordList = []
  387. this.mockSubscribeListSubscribe();
  388. }
  389. }
  390. };
  391. </script>
  392. <style>
  393. page {
  394. background: #eaeef1;
  395. }
  396. </style>
  397. <style lang="scss" scope>
  398. .animals{
  399. transition: all 0.3s;
  400. transform: rotate(180deg);
  401. }
  402. .tabs {
  403. position: fixed;
  404. left: 0;
  405. width: 100%;
  406. display: flex;
  407. z-index: 10;
  408. background: #ffffff;
  409. padding:18rpx 0;
  410. border-bottom:1px solid #eee;
  411. .tab {
  412. padding:0 18rpx;
  413. flex: 1;
  414. background: #ffffff;
  415. font-size: 32rpx;
  416. color: #999999;
  417. text-align: center;
  418. position:relative;
  419. &:nth-of-type(2) {
  420. border-right:1px solid #EEEEEE;
  421. }
  422. &.active {
  423. color: #333333;
  424. &::before{
  425. content:'';
  426. position:absolute;
  427. width: 24px;
  428. height: 4px;
  429. background: #007AFF;
  430. border-radius: 2px;
  431. left:50%;
  432. margin-left:-12px;
  433. bottom:-18rpx;
  434. }
  435. }
  436. }
  437. .sort {
  438. width:160rpx;
  439. text-align: center;
  440. font-size: 32rpx;
  441. font-weight: 500;
  442. color: #999999;
  443. }
  444. }
  445. .record {
  446. margin-top:80rpx;
  447. padding: 16rpx 16rpx;
  448. .examList {
  449. .main {
  450. background: #ffffff;
  451. border-radius: 16rpx;
  452. margin: 20rpx 0;
  453. }
  454. .top {
  455. height: 80rpx;
  456. text-align: center;
  457. line-height: 80rpx;
  458. font-size: 30rpx;
  459. color:#333333;
  460. font-weight: bold;
  461. border-bottom: 1px solid #eeeeee;
  462. }
  463. .item {
  464. display: flex;
  465. justify-content: space-between;
  466. align-items: center;
  467. margin-left: 31rpx;
  468. height: 80rpx;
  469. padding-right: 24rpx;
  470. border-bottom: 1px solid #eeeeee;
  471. font-size: 24rpx;
  472. color: #666666;
  473. .right {
  474. font-size: 28rpx;
  475. }
  476. }
  477. .btn-wrap {
  478. padding:24rpx 16rpx ;
  479. border-bottom:1px solid #EEEEEE;
  480. .btn-line {
  481. display: flex;
  482. align-items: center;
  483. justify-content: center;
  484. flex-wrap: wrap;
  485. }
  486. .text {
  487. width:100%;
  488. color:#F5222D;
  489. font-size: 24rpx;
  490. text-align: center;
  491. }
  492. .text-half {
  493. color:#666666;
  494. font-size: 24rpx;
  495. width:320rpx;
  496. margin:8rpx;
  497. }
  498. .btn {
  499. margin:8rpx;
  500. width: 528rpx;
  501. height: 64rpx;
  502. background: #007AFF;
  503. border-radius: 16rpx;
  504. text-align: center;
  505. line-height: 64rpx;
  506. color:#fff;
  507. &--half {
  508. width:320rpx;
  509. }
  510. &.border {
  511. background:#fff;
  512. color:#007AFF;
  513. border:1px solid #007AFF;
  514. }
  515. &.disabled {
  516. color:#D9D9D9;
  517. border-color:#D9D9D9;
  518. }
  519. &.test-disabled {
  520. color:#fff;
  521. background:#D9D9D9;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. .modal {
  528. bottom:0;
  529. z-index: 199999999;
  530. position: fixed;
  531. left: 0;
  532. width: 100%;
  533. .content {
  534. overflow: hidden;
  535. position: relative;
  536. z-index: 10;
  537. background: #fff;
  538. padding: 20rpx 12rpx 16rpx;
  539. .item {
  540. &__title {
  541. padding:16rpx 0;
  542. font-size: 28rpx;
  543. color: #999999;
  544. }
  545. &__box {
  546. padding:0 16rpx;
  547. display: flex;
  548. width: 718rpx;
  549. height: 80rpx;
  550. background: #FFFFFF;
  551. border: 1px solid #EEEEEE;
  552. border-radius: 16rpx;
  553. align-items: center;
  554. .text {
  555. flex:1;
  556. display: flex;
  557. align-items: center;
  558. }
  559. }
  560. }
  561. }
  562. .modal_wrap {
  563. position: absolute;
  564. left: 0;
  565. width: 100%;
  566. top: 0;
  567. height: 100%;
  568. background: rgba(0, 0, 0, 0.3);
  569. }
  570. }
  571. .activesty {
  572. background: #007aff !important;
  573. color: #fff !important;
  574. }
  575. </style>