index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. console.log('sfhdsofhsoh-----onshow', this.itemIndex, this.nowTime)
  213. // if(this.itemIndex !== '') {
  214. // this.refreshByIndex();
  215. // }
  216. this.recordList = []
  217. this.mockSubscribeListSubscribe();
  218. },
  219. methods: {
  220. mockApplyListApplyName() {
  221. let param = JSON.parse(JSON.stringify(this.param));
  222. if(param.endTime) {
  223. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  224. }
  225. if(param.startTime) {
  226. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  227. }
  228. console.log(param,'param')
  229. this.$api.mockApplyListApplyName(param).then((res) => {
  230. this.listApplyName = res.data.rows;
  231. console.log(this.listApplyName,'listApplyName')
  232. this.param.applyName = "";
  233. this.mockSubscribeListSubscribe();
  234. });
  235. },
  236. reApply(item){
  237. uni.redirectTo({
  238. url:'/pages5/examAppointList/index'
  239. })
  240. },
  241. report(item) {
  242. uni.navigateTo({
  243. url:
  244. "/pages5/examReport/index?&examId=" +
  245. item.examId +
  246. "&id=" +
  247. item.recordId+
  248. "&eachExamId="+item.eachExamId+
  249. "&subscribeId="+item.subscribeId
  250. });
  251. },
  252. doQuestion(item) {
  253. if(item.canDo === 0) {
  254. uni.showToast({
  255. icon:'none',
  256. msg:'请等待所有科目考试结束后再进入刷题'
  257. })
  258. return;
  259. }
  260. uni.navigateTo({
  261. url:'../examBank/index?examId='+item.examId+'&eachExamId='+item.eachExamId+'&subscribeId='+item.subscribeId
  262. })
  263. },
  264. goTest(item) {
  265. if (item.mockActivity && item.mockActivity == 1) {
  266. return false
  267. }
  268. let startTime = this.$method.TimeTotimestamp(this.$method.timestampToTime(item.applySiteExamTime) + ' ' + item.applySiteStartTime)
  269. let canGo = (startTime-this.nowTime) <= (600) && (startTime-this.nowTime) >= (-(item.timeLimit * 60) || 0)
  270. return !canGo
  271. },
  272. isStart(item) {
  273. let startTime = this.$method.TimeTotimestamp(
  274. this.$method.timestampToTime(item.applySiteExamTime) +
  275. " " +
  276. item.applySiteStartTime
  277. );
  278. return startTime - this.nowTime <= 600;
  279. },
  280. mockSubscribeListSubscribe() {
  281. let param = JSON.parse(JSON.stringify(this.param))
  282. if(param.endTime) {
  283. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  284. }
  285. if(param.startTime) {
  286. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  287. }
  288. // mock/subscribe/listSubscribe
  289. this.$api.mockSubscribeListSubscribe(param).then(res => {
  290. console.log('请求请求')
  291. this.recordList.push(...res.data.rows)
  292. this.total = res.data.total
  293. })
  294. },
  295. refreshByIndex() {
  296. let param = JSON.parse(JSON.stringify(this.param))
  297. if(param.endTime) {
  298. param.endTime = this.$method.TimeTotimestamp(param.endTime)
  299. }
  300. if(param.startTime) {
  301. param.startTime = this.$method.TimeTotimestamp(param.startTime)
  302. }
  303. param.pageNum = this.itemIndex+1;
  304. param.pageSize = 1
  305. this.$api.mockSubscribeListSubscribe(param).then(res => {
  306. console.log('res.data.rows[0]', res.data.rows[0])
  307. this.$set(this.recordList,this.itemIndex,res.data.rows[0])
  308. this.itemIndex = ''
  309. })
  310. },
  311. goLive(item) {
  312. let uuid = new Date().valueOf() + ""
  313. // buyCourse 是否购买课程:1是 0否
  314. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='
  315. +item.liveUrl+'&buyCourse=1'+'&ident='+uuid)
  316. uni.navigateTo({
  317. url:`../../pages/webview/index?url=`+encode
  318. })
  319. },
  320. async goExamCount(item,index) {
  321. console.log('item', item)
  322. if (item.mockActivity && item.mockActivity == 1) {
  323. if (!(item.activityStartTime < this.nowTime)) {
  324. return
  325. }
  326. await this.$http({
  327. url: '/mock/apply/addMockTime',
  328. method: 'post',
  329. data: {
  330. applyId: item.applyId,
  331. duration: item.duration,
  332. majorId: item.majorId,
  333. subjectId: item.subjectId
  334. },
  335. }).then((res) => {
  336. const { examTime, startTime, endTime, eachExamId} = res.data.data
  337. item.applySiteExamTime = examTime // 当前时间的时间戳
  338. item.applySiteStartTime = startTime
  339. item.applySiteEndTime = endTime
  340. item.eachExamId = eachExamId
  341. // item.applySiteExamTime = parseInt(new Date().getTime()/1000) // 当前时间的时间戳
  342. // item.applySiteStartTime = this.$method.timestampToTime(new Date().getTime()/1000, false, false, true)
  343. // let min = item.duration * 60 *1000 + new Date().getTime()
  344. // item.applySiteEndTime = this.$method.timestampToTime(min/1000, false, false, true)
  345. console.log('item', item)
  346. })
  347. }
  348. if(this.goTest(item)) {
  349. uni.showToast({
  350. icon:'none',
  351. title:'不在考试时间'
  352. })
  353. return;
  354. }
  355. this.itemIndex = index;
  356. uni.navigateTo({
  357. 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)
  358. })
  359. },
  360. sort() {
  361. },
  362. appoint(item) {
  363. this.appointModal = true;
  364. },
  365. tab(state) {
  366. if(this.param.mockStatus == state) {
  367. return;
  368. }
  369. this.recordList = [];
  370. this.param.endTime = '';
  371. this.param.startTime = '';
  372. this.param.applyName = '';
  373. this.param.pageNum = 1;
  374. this.param.mockStatus = state;
  375. this.mockSubscribeListSubscribe()
  376. },
  377. bindDateFromChange(e) {
  378. this.param.startTime = e.detail.value
  379. this.param.pageNum = 1;
  380. this.param.applyName = '';
  381. this.recordList = []
  382. this.mockApplyListApplyName();
  383. },
  384. bindDateToChange(e) {
  385. this.param.endTime = e.detail.value
  386. this.param.pageNum = 1;
  387. this.param.applyName = '';
  388. this.recordList = []
  389. this.mockApplyListApplyName();
  390. },
  391. bindTitleChange(e) {
  392. if (this.listApplyName.length) {
  393. let index = e.detail.value;
  394. this.param.applyName = this.listApplyName[index].applyName
  395. } else {
  396. this.param.applyName =''
  397. }
  398. this.param.pageNum = 1;
  399. this.recordList = []
  400. this.mockSubscribeListSubscribe();
  401. }
  402. }
  403. };
  404. </script>
  405. <style>
  406. page {
  407. background: #eaeef1;
  408. }
  409. </style>
  410. <style lang="scss" scope>
  411. .animals{
  412. transition: all 0.3s;
  413. transform: rotate(180deg);
  414. }
  415. .tabs {
  416. position: fixed;
  417. left: 0;
  418. width: 100%;
  419. display: flex;
  420. z-index: 10;
  421. background: #ffffff;
  422. padding:18rpx 0;
  423. border-bottom:1px solid #eee;
  424. .tab {
  425. padding:0 18rpx;
  426. flex: 1;
  427. background: #ffffff;
  428. font-size: 32rpx;
  429. color: #999999;
  430. text-align: center;
  431. position:relative;
  432. &:nth-of-type(2) {
  433. border-right:1px solid #EEEEEE;
  434. }
  435. &.active {
  436. color: #333333;
  437. &::before{
  438. content:'';
  439. position:absolute;
  440. width: 24px;
  441. height: 4px;
  442. background: #007AFF;
  443. border-radius: 2px;
  444. left:50%;
  445. margin-left:-12px;
  446. bottom:-18rpx;
  447. }
  448. }
  449. }
  450. .sort {
  451. width:160rpx;
  452. text-align: center;
  453. font-size: 32rpx;
  454. font-weight: 500;
  455. color: #999999;
  456. }
  457. }
  458. .record {
  459. margin-top:80rpx;
  460. padding: 16rpx 16rpx;
  461. .examList {
  462. .main {
  463. background: #ffffff;
  464. border-radius: 16rpx;
  465. margin: 20rpx 0;
  466. }
  467. .top {
  468. height: 80rpx;
  469. text-align: center;
  470. line-height: 80rpx;
  471. font-size: 30rpx;
  472. color:#333333;
  473. font-weight: bold;
  474. border-bottom: 1px solid #eeeeee;
  475. }
  476. .item {
  477. display: flex;
  478. justify-content: space-between;
  479. align-items: center;
  480. margin-left: 31rpx;
  481. height: 80rpx;
  482. padding-right: 24rpx;
  483. border-bottom: 1px solid #eeeeee;
  484. font-size: 24rpx;
  485. color: #666666;
  486. .right {
  487. font-size: 28rpx;
  488. }
  489. }
  490. .btn-wrap {
  491. padding:24rpx 16rpx ;
  492. border-bottom:1px solid #EEEEEE;
  493. .btn-line {
  494. display: flex;
  495. align-items: center;
  496. justify-content: center;
  497. flex-wrap: wrap;
  498. }
  499. .text {
  500. width:100%;
  501. color:#F5222D;
  502. font-size: 24rpx;
  503. text-align: center;
  504. }
  505. .text-half {
  506. color:#666666;
  507. font-size: 24rpx;
  508. width:320rpx;
  509. margin:8rpx;
  510. }
  511. .btn {
  512. margin:8rpx;
  513. width: 528rpx;
  514. height: 64rpx;
  515. background: #007AFF;
  516. border-radius: 16rpx;
  517. text-align: center;
  518. line-height: 64rpx;
  519. color:#fff;
  520. &--half {
  521. width:320rpx;
  522. }
  523. &.border {
  524. background:#fff;
  525. color:#007AFF;
  526. border:1px solid #007AFF;
  527. }
  528. &.disabled {
  529. color:#D9D9D9;
  530. border-color:#D9D9D9;
  531. }
  532. &.test-disabled {
  533. color:#fff;
  534. background:#D9D9D9;
  535. }
  536. }
  537. }
  538. }
  539. }
  540. .modal {
  541. bottom:0;
  542. z-index: 199999999;
  543. position: fixed;
  544. left: 0;
  545. width: 100%;
  546. .content {
  547. overflow: hidden;
  548. position: relative;
  549. z-index: 10;
  550. background: #fff;
  551. padding: 20rpx 12rpx 16rpx;
  552. .item {
  553. &__title {
  554. padding:16rpx 0;
  555. font-size: 28rpx;
  556. color: #999999;
  557. }
  558. &__box {
  559. padding:0 16rpx;
  560. display: flex;
  561. width: 718rpx;
  562. height: 80rpx;
  563. background: #FFFFFF;
  564. border: 1px solid #EEEEEE;
  565. border-radius: 16rpx;
  566. align-items: center;
  567. .text {
  568. flex:1;
  569. display: flex;
  570. align-items: center;
  571. }
  572. }
  573. }
  574. }
  575. .modal_wrap {
  576. position: absolute;
  577. left: 0;
  578. width: 100%;
  579. top: 0;
  580. height: 100%;
  581. background: rgba(0, 0, 0, 0.3);
  582. }
  583. }
  584. .activesty {
  585. background: #007aff !important;
  586. color: #fff !important;
  587. }
  588. </style>