index.vue 16 KB

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