index.vue 16 KB

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