index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. dateFrom:'',
  159. dateTo:'',
  160. isRepeat:false,
  161. total: 0,
  162. activeIndex: 0,
  163. typeIndex:0,
  164. itemIndex:'',
  165. modalTop:0,
  166. endDate:'',
  167. titleName:3,
  168. listApplyName:[],
  169. };
  170. },
  171. computed:{
  172. ...mapGetters(['userInfo'])
  173. },
  174. onLoad(option) {
  175. console.log('查看返回的onloaddddd')
  176. this.param.mockStatus = option.state || 0
  177. this.endDate = this.$method.timestampToTime(new Date().getTime() / 1000).replace(/-/g,'/');
  178. // this.mockSubscribeListSubscribe();
  179. uni.getSystemInfo({
  180. success:(e) => {
  181. let info = uni.createSelectorQuery().select(".nav");
  182. info.boundingClientRect((navData) => { //data - 各种参数
  183. let info = uni.createSelectorQuery().select(".tabs");
  184. info.boundingClientRect((tabData) => { //data - 各种参数
  185. this.modalTop = navData.height + tabData.height
  186. console.log(navData) // 获取元素宽度
  187. console.log(tabData) // 获取元素宽度
  188. }).exec()
  189. }).exec()
  190. }
  191. })
  192. },
  193. onPullDownRefresh() {
  194. let that = this;
  195. this.param.pageNum = 1;
  196. this.mockSubscribeListSubscribe();
  197. setTimeout(function() {
  198. uni.stopPullDownRefresh();
  199. }, 500);
  200. },
  201. onReachBottom() {
  202. console.log(this.total,'total');
  203. console.log(this.recordList.length,'length')
  204. if (this.recordList.length < this.total) {
  205. this.param.pageNum++;
  206. this.mockSubscribeListSubscribe();
  207. }
  208. },
  209. onShow() {
  210. console.log('sfhdsofhsoh-----onshow', this.itemIndex)
  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
  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. console.log('请求请求')
  290. this.recordList.push(...res.data.rows)
  291. this.total = res.data.total
  292. })
  293. },
  294. refreshByIndex() {
  295. let param = JSON.parse(JSON.stringify(this.param))
  296. if(param.endTime) {
  297. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  298. }
  299. if(param.startTime) {
  300. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  301. }
  302. param.pageNum = this.itemIndex+1;
  303. param.pageSize = 1
  304. this.$api.mockSubscribeListSubscribe(param).then(res => {
  305. console.log('res.data.rows[0]', res.data.rows[0])
  306. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  307. this.itemIndex = ''
  308. })
  309. },
  310. goLive(item) {
  311. let uuid = new Date().valueOf() + ""
  312. // buyCourse 是否购买课程:1是 0否
  313. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='
  314. +item.liveUrl+'&buyCourse=1'+'&ident='+uuid)
  315. uni.navigateTo({
  316. url:`../../pages/webview/index?url=`+encode
  317. })
  318. },
  319. async goExamCount(item,index) {
  320. console.log('item', item)
  321. if (item.mockActivity && item.mockActivity == 1) {
  322. if (item.activityStartTime < this.nowTime) {
  323. return
  324. }
  325. await this.$http({
  326. url: '/mock/apply/addMockTime',
  327. method: 'post',
  328. data: {
  329. applyId: item.applyId,
  330. duration: item.duration,
  331. majorId: item.majorId,
  332. subjectId: item.subjectId
  333. },
  334. }).then((res) => {
  335. const { examTime, startTime, endTime, eachExamId} = res.data.data
  336. item.applySiteExamTime = examTime // 当前时间的时间戳
  337. item.applySiteStartTime = startTime
  338. item.applySiteEndTime = endTime
  339. item.eachExamId = eachExamId
  340. // item.applySiteExamTime = parseInt(new Date().getTime()/1000) // 当前时间的时间戳
  341. // item.applySiteStartTime = this.$method.timestampToTime(new Date().getTime()/1000, false, false, true)
  342. // let min = item.duration * 60 *1000 + new Date().getTime()
  343. // item.applySiteEndTime = this.$method.timestampToTime(min/1000, false, false, true)
  344. console.log('item', item)
  345. })
  346. }
  347. if(this.goTest(item)) {
  348. uni.showToast({
  349. icon:'none',
  350. title:'不在考试时间'
  351. })
  352. return;
  353. }
  354. this.itemIndex = index;
  355. uni.navigateTo({
  356. 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)
  357. })
  358. },
  359. sort() {
  360. },
  361. appoint(item) {
  362. this.appointModal = true;
  363. },
  364. tab(state) {
  365. if(this.param.mockStatus == state) {
  366. return;
  367. }
  368. this.recordList = [];
  369. this.param.endTime = '';
  370. this.param.startTime = '';
  371. this.param.applyName = '';
  372. this.param.pageNum = 1;
  373. this.param.mockStatus = state;
  374. this.mockSubscribeListSubscribe()
  375. },
  376. bindDateFromChange(e) {
  377. this.param.startTime = e.detail.value
  378. this.param.pageNum = 1;
  379. this.param.applyName = '';
  380. this.recordList = []
  381. this.mockApplyListApplyName();
  382. },
  383. bindDateToChange(e) {
  384. this.param.endTime = e.detail.value
  385. this.param.pageNum = 1;
  386. this.param.applyName = '';
  387. this.recordList = []
  388. this.mockApplyListApplyName();
  389. },
  390. bindTitleChange(e) {
  391. if (this.listApplyName.length) {
  392. let index = e.detail.value;
  393. this.param.applyName = this.listApplyName[index].applyName
  394. } else {
  395. this.param.applyName =''
  396. }
  397. this.param.pageNum = 1;
  398. this.recordList = []
  399. this.mockSubscribeListSubscribe();
  400. }
  401. }
  402. };
  403. </script>
  404. <style>
  405. page {
  406. background: #eaeef1;
  407. }
  408. </style>
  409. <style lang="scss" scope>
  410. .animals{
  411. transition: all 0.3s;
  412. transform: rotate(180deg);
  413. }
  414. .tabs {
  415. position: fixed;
  416. left: 0;
  417. width: 100%;
  418. display: flex;
  419. z-index: 10;
  420. background: #ffffff;
  421. padding:18rpx 0;
  422. border-bottom:1px solid #eee;
  423. .tab {
  424. padding:0 18rpx;
  425. flex: 1;
  426. background: #ffffff;
  427. font-size: 32rpx;
  428. color: #999999;
  429. text-align: center;
  430. position:relative;
  431. &:nth-of-type(2) {
  432. border-right:1px solid #EEEEEE;
  433. }
  434. &.active {
  435. color: #333333;
  436. &::before{
  437. content:'';
  438. position:absolute;
  439. width: 24px;
  440. height: 4px;
  441. background: #007AFF;
  442. border-radius: 2px;
  443. left:50%;
  444. margin-left:-12px;
  445. bottom:-18rpx;
  446. }
  447. }
  448. }
  449. .sort {
  450. width:160rpx;
  451. text-align: center;
  452. font-size: 32rpx;
  453. font-weight: 500;
  454. color: #999999;
  455. }
  456. }
  457. .record {
  458. margin-top:80rpx;
  459. padding: 16rpx 16rpx;
  460. .examList {
  461. .main {
  462. background: #ffffff;
  463. border-radius: 16rpx;
  464. margin: 20rpx 0;
  465. }
  466. .top {
  467. height: 80rpx;
  468. text-align: center;
  469. line-height: 80rpx;
  470. font-size: 30rpx;
  471. color:#333333;
  472. font-weight: bold;
  473. border-bottom: 1px solid #eeeeee;
  474. }
  475. .item {
  476. display: flex;
  477. justify-content: space-between;
  478. align-items: center;
  479. margin-left: 31rpx;
  480. height: 80rpx;
  481. padding-right: 24rpx;
  482. border-bottom: 1px solid #eeeeee;
  483. font-size: 24rpx;
  484. color: #666666;
  485. .right {
  486. font-size: 28rpx;
  487. }
  488. }
  489. .btn-wrap {
  490. padding:24rpx 16rpx ;
  491. border-bottom:1px solid #EEEEEE;
  492. .btn-line {
  493. display: flex;
  494. align-items: center;
  495. justify-content: center;
  496. flex-wrap: wrap;
  497. }
  498. .text {
  499. width:100%;
  500. color:#F5222D;
  501. font-size: 24rpx;
  502. text-align: center;
  503. }
  504. .text-half {
  505. color:#666666;
  506. font-size: 24rpx;
  507. width:320rpx;
  508. margin:8rpx;
  509. }
  510. .btn {
  511. margin:8rpx;
  512. width: 528rpx;
  513. height: 64rpx;
  514. background: #007AFF;
  515. border-radius: 16rpx;
  516. text-align: center;
  517. line-height: 64rpx;
  518. color:#fff;
  519. &--half {
  520. width:320rpx;
  521. }
  522. &.border {
  523. background:#fff;
  524. color:#007AFF;
  525. border:1px solid #007AFF;
  526. }
  527. &.disabled {
  528. color:#D9D9D9;
  529. border-color:#D9D9D9;
  530. }
  531. &.test-disabled {
  532. color:#fff;
  533. background:#D9D9D9;
  534. }
  535. }
  536. }
  537. }
  538. }
  539. .modal {
  540. bottom:0;
  541. z-index: 199999999;
  542. position: fixed;
  543. left: 0;
  544. width: 100%;
  545. .content {
  546. overflow: hidden;
  547. position: relative;
  548. z-index: 10;
  549. background: #fff;
  550. padding: 20rpx 12rpx 16rpx;
  551. .item {
  552. &__title {
  553. padding:16rpx 0;
  554. font-size: 28rpx;
  555. color: #999999;
  556. }
  557. &__box {
  558. padding:0 16rpx;
  559. display: flex;
  560. width: 718rpx;
  561. height: 80rpx;
  562. background: #FFFFFF;
  563. border: 1px solid #EEEEEE;
  564. border-radius: 16rpx;
  565. align-items: center;
  566. .text {
  567. flex:1;
  568. display: flex;
  569. align-items: center;
  570. }
  571. }
  572. }
  573. }
  574. .modal_wrap {
  575. position: absolute;
  576. left: 0;
  577. width: 100%;
  578. top: 0;
  579. height: 100%;
  580. background: rgba(0, 0, 0, 0.3);
  581. }
  582. }
  583. .activesty {
  584. background: #007aff !important;
  585. color: #fff !important;
  586. }
  587. </style>