index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <template>
  2. <view class="content">
  3. <view class="top-box">
  4. <van-row>
  5. <van-col span="24">
  6. <view class="timingBox">
  7. <view class="classHourStatistics">
  8. <view class="unbind" v-if="unbindFlag">
  9. <text>未绑定身份证\n前往我的页面绑定</text>
  10. </view>
  11. <view class="timing-item">
  12. <text>科一学时</text>
  13. <text class="timing-time">{{infoData.km1+0}}/{{info[0].ration+0}}</text>
  14. </view>
  15. <view class="timing-item">
  16. <text>科二学时</text>
  17. <text class="timing-time">{{infoData.km2+0}}/{{info[1].ration+info[2].ration}}</text>
  18. </view>
  19. <view class="timing-item">
  20. <text>科三学时</text>
  21. <text class="timing-time">{{infoData.km3+0}}/{{info[3].ration+info[4].ration}}</text>
  22. </view>
  23. <view class="timing-item">
  24. <text>科四学时</text>
  25. <text class="timing-time">{{infoData.km4+0}}/{{info[5].ration+0}}</text>
  26. </view>
  27. </view>
  28. <view class="jsbox">
  29. <view class="bt">
  30. <van-icon name="/static/imgs/我要计时.png" />
  31. <text>我要计时</text>
  32. </view>
  33. <view :class="['js',{dh:dhfalg}]">
  34. <van-button :loading='btnLoading' :loading-text='loadingText' custom-class="jsbtn" @click='timeBtn'>{{timeTitle}}</van-button>
  35. <text class="timeText">{{timeText}}</text>
  36. </view>
  37. <text class="ts">注:退出即停止计时,不满60s不计入学时</text>
  38. </view>
  39. </view>
  40. </van-col>
  41. <!-- <van-col span="6">
  42. <square icon='/static/imgs/包过保证icon.png' title='包过保证' @tap='go()' />
  43. <square icon='/static/imgs/模拟考试icon.png' title='模拟考试' @tap="go('/pages/question/mockExam')" />
  44. </van-col> -->
  45. </van-row>
  46. <van-row>
  47. <van-col span="6">
  48. <!-- <square icon='/static/imgs/图标练习icon.png' title='图标练习' @tap='go()' /> -->
  49. <square icon='/static/imgs/模拟考试icon.png' title='模拟考试' @tap="go('/pages/question/mockExam')" />
  50. </van-col>
  51. <van-col span="6">
  52. <square icon='/static/imgs/顺序测试icon.png' title='顺序测试' @tap="go('/pages/question/sequential')" />
  53. </van-col>
  54. <van-col span="6">
  55. <square icon='/static/imgs/随机测试icon.png' title='随机测试' @tap="go('/pages/question/random')" />
  56. </van-col>
  57. <van-col span="6">
  58. <square icon='/static/imgs/错题收藏icon.png' title='错题收藏' @tap="go('/pages/question/wrongTitle')" />
  59. </van-col>
  60. </van-row>
  61. </view>
  62. <view class="item-box">
  63. <view class="item-titBox">
  64. <text class="item-tit">新手上路</text>
  65. <text class="item-tit-right" @tap='go()'>更多视频 ></text>
  66. </view>
  67. <view class="video-box">
  68. <video class="myVideo" id="myVideo" src="http://image.jppt.com.cn/zzjs/2021-03-18/media/1616051225707.mp4"
  69. object-fit='fill' controls @play='videoPlay'></video>
  70. <view class="tit-box">
  71. <text class="video-box-tit">考点视频</text>
  72. <button class="video-box-btn" @tap='go()'>去观看</button>
  73. </view>
  74. <video class="myVideo" id="myVideo2" src="http://image.jppt.com.cn/zzjs/2021-03-18/media/1616051225707.mp4"
  75. object-fit='fill' controls @play='videoPlay2'></video>
  76. <view class="tit-box">
  77. <text class="video-box-tit">3D模拟练车</text>
  78. <button class="video-box-btn" @tap='go()'>去练习</button>
  79. </view>
  80. </view>
  81. </view>
  82. <!-- <view class="item-box">
  83. <view class="item-titBox">
  84. <text class="item-tit">驾考学堂</text>
  85. </view>
  86. <view class="video-box">
  87. <van-row>
  88. <van-col span="6">
  89. <square icon='/static/img/home/三力测试@3x.png' title='三力测试' @tap='go()' />
  90. </van-col>
  91. <van-col span="6">
  92. <square icon='/static/img/home/驾驶许可@3x.png' title='驾驶许可' @tap='go()' />
  93. </van-col>
  94. <van-col span="6">
  95. <square icon='/static/img/home/驾照种类@3x.png' title='驾照种类' @tap='go()' />
  96. </van-col>
  97. <van-col span="6">
  98. <square icon='/static/img/home/驾照有效期@3x.png' title='驾照有效期' @tap='go()' />
  99. </van-col>
  100. <van-col span="6">
  101. <square icon='/static/img/home/年龄条件@3x.png' title='年龄条件' @tap='go()' />
  102. </van-col>
  103. <van-col span="6">
  104. <square icon='/static/img/home/身体条件@3x.png' title='身体条件' @tap='go()' />
  105. </van-col>
  106. <van-col span="6">
  107. <square icon='/static/img/home/身体条件@3x.png' title='预约考试' @tap='go()' />
  108. </van-col>
  109. <van-col span="6">
  110. <square icon='/static/img/home/身体条件@3x.png' title='成绩查询' @tap='go()' />
  111. </van-col>
  112. </van-row>
  113. </view>
  114. </view> -->
  115. </view>
  116. </template>
  117. <script>
  118. import square from '@/components/square/index.vue'
  119. import {
  120. addTime,
  121. getTime,
  122. getTimeInfo
  123. } from '@/api/studytime.js'
  124. import {
  125. getInfo
  126. } from '@/api/login.js'
  127. export default {
  128. components: {
  129. square
  130. },
  131. data() {
  132. return {
  133. dhfalg: false,
  134. timeText: "00:00:00",
  135. timeTitle: '开始',
  136. info: [],
  137. infoData: {},
  138. unbindFlag: false,
  139. timeStatus: 0,
  140. timeFn: this.timeStart(),
  141. btnLoading: false,
  142. loadingText: ''
  143. }
  144. },
  145. mounted() {
  146. this.initInfo()
  147. },
  148. methods: {
  149. async initInfo() {
  150. if (uni.getStorageSync('time')) {
  151. this.timeText = new Date(uni.getStorageSync('time')).toJSON().slice(11, -5)
  152. this.timeTitle = '继续'
  153. }
  154. let studentInfo = await getInfo()
  155. if (studentInfo.data.student.gzptUserId) {
  156. let info = await getTimeInfo()
  157. this.info = info.rows
  158. let infoData = await getTime()
  159. this.infoData = infoData.rows[0]
  160. } else {
  161. //未绑定身份证
  162. this.unbindFlag = true
  163. }
  164. },
  165. videoPlay(e) {
  166. uni.createVideoContext('myVideo2', this).pause();
  167. },
  168. videoPlay2(e) {
  169. uni.createVideoContext('myVideo', this).pause();
  170. },
  171. go(url) {
  172. uni.navigateTo({
  173. url
  174. });
  175. },
  176. timeBtn(e) {
  177. let timeObj = this.timeFn();
  178. console.log(timeObj)
  179. if (timeObj.timeStatus == 1) {
  180. this.dhfalg = true;
  181. this.loadingText = '计时中'
  182. this.btnLoading = true;
  183. setTimeout(() => {
  184. this.btnLoading = false;
  185. this.timeTitle = '上传学时'
  186. }, 1000)
  187. }
  188. if (timeObj.timeStatus == 2) {
  189. this.dhfalg = false;
  190. this.loadingText = '上传中'
  191. this.btnLoading = true;
  192. try {
  193. let sysInfo = uni.getStorageSync('sysInfo')
  194. addTime({
  195. beginTime: new Date(timeObj.start).toISOString().slice(0, -5).replace('T', ' '),
  196. endTime: new Date(timeObj.end).toISOString().slice(0, -5).replace('T', ' '),
  197. isSubmit: 6,
  198. pxkm: this.infoData.km1 >= this.info[5].ration ? 4 : 1,
  199. classid: '小程序',
  200. reason: `小程序&${sysInfo.platform}&${sysInfo.model}`,
  201. source: 1,
  202. trainType: `小程序`,
  203. trainTime: ~~(timeObj.time / 60 / 1000)
  204. }).then(res => {
  205. if (res.code == 200) {
  206. this.btnLoading = false;
  207. this.timeText = "上传成功"
  208. uni.removeStorageSync('timeStart')
  209. uni.removeStorageSync('time')
  210. this.timeTitle = '开始'
  211. } else {
  212. this.btnLoading = false;
  213. console.log('上传学时异常!!')
  214. this.timeTitle = '恢复'
  215. }
  216. }, err => {
  217. this.btnLoading = false;
  218. console.log('上传学时异常!!')
  219. this.timeTitle = '恢复'
  220. })
  221. } catch (e) {
  222. this.btnLoading = false;
  223. this.timeTitle = '恢复'
  224. }
  225. }
  226. },
  227. timeStart() {
  228. let timerID,
  229. time,
  230. timeStatus = 0,
  231. start,
  232. end
  233. return () => {
  234. timeStatus += 1;
  235. if (timeStatus == 1) {
  236. if (uni.getStorageSync('time')) {
  237. time = uni.getStorageSync('time')
  238. } else {
  239. start = new Date().getTime()
  240. time = 0
  241. uni.setStorageSync('timeStart', start)
  242. }
  243. timerID = setInterval(() => {
  244. time += 100
  245. if (time % 1000 == 0) {
  246. uni.setStorageSync('time', time)
  247. }
  248. this.timeText = new Date(time).toJSON().slice(11, -5)
  249. }, 100)
  250. return {
  251. start: uni.getStorageSync('timeStart'),
  252. time,
  253. timeStatus
  254. }
  255. }
  256. if (timeStatus >= 2) {
  257. timeStatus = 0;
  258. let timeObj = {
  259. start: uni.getStorageSync('timeStart'),
  260. end: new Date().getTime(),
  261. time: uni.getStorageSync('time'),
  262. timeStatus: 2
  263. }
  264. clearInterval(timerID);
  265. // uni.removeStorageSync('timeStart')
  266. // uni.removeStorageSync('time')
  267. return timeObj
  268. }
  269. }
  270. }
  271. }
  272. }
  273. </script>
  274. <style lang="scss">
  275. .dh {
  276. position: relative;
  277. &::after {
  278. content: '';
  279. background-color: red;
  280. left: 0;
  281. top: 0;
  282. width: 0%;
  283. height: 100%;
  284. position: absolute;
  285. animation: go 1s infinite;
  286. z-index: 0;
  287. }
  288. @keyframes go {
  289. to {
  290. width: 100%;
  291. background-color: greenyellow;
  292. }
  293. }
  294. }
  295. .jsbox {
  296. .bt {
  297. width: 140rpx;
  298. margin-bottom: 10rpx;
  299. font-size: 26rpx;
  300. font-family: PingFang SC;
  301. font-weight: 400;
  302. display: flex;
  303. align-items: center;
  304. justify-content: space-between;
  305. }
  306. .ts {
  307. font-size: 22rpx;
  308. font-family: PingFang SC;
  309. font-weight: 400;
  310. color: #E31818;
  311. }
  312. .js {
  313. height: 70rpx;
  314. background: #F5F5F5;
  315. border: 1rpx solid #E8E8E8;
  316. border-radius: 10rpx;
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. font-size: 48rpx;
  321. padding: 0 20rpx;
  322. box-sizing: border-box;
  323. overflow: hidden;
  324. .jsbtn {
  325. height: 50rpx;
  326. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  327. border-radius: 25rpx;
  328. font-size: 24rpx;
  329. color: #FFFFFF;
  330. font-weight: 400;
  331. font-family: PingFang SC;
  332. display: flex;
  333. justify-content: center;
  334. align-items: center;
  335. margin: 0;
  336. z-index: 1;
  337. }
  338. .timeText {
  339. z-index: 1;
  340. }
  341. }
  342. }
  343. .content {
  344. width: 100%;
  345. padding-bottom: 10rpx;
  346. }
  347. .item-box {
  348. background-color: #fff;
  349. border-radius: 10rpx;
  350. margin: 10rpx 30rpx;
  351. .item-titBox {
  352. display: flex;
  353. justify-content: space-between;
  354. align-items: center;
  355. padding: 20rpx;
  356. border-bottom: 1rpx solid #e8e8e8;
  357. .item-tit {
  358. border-left: 8rpx solid #E31818;
  359. font-size: 30rpx;
  360. line-height: 58rpx;
  361. padding: 11rpx;
  362. }
  363. .item-tit-right {
  364. font-size: 26rpx;
  365. color: #666666;
  366. line-height: 58rpx;
  367. padding: 11rpx;
  368. }
  369. }
  370. .video-box {
  371. padding: 30rpx 20rpx;
  372. .myVideo {
  373. width: 650rpx;
  374. height: 360rpx;
  375. border-radius: 10rpx;
  376. }
  377. .tit-box {
  378. width: 100%;
  379. display: flex;
  380. justify-content: space-between;
  381. padding: 10rpx 0 26rpx;
  382. .video-box-tit {
  383. height: 31rpx;
  384. font-size: 20rpx;
  385. border: 1rpx solid #E31A19;
  386. border-radius: 2rpx;
  387. padding: 5rpx 9rpx;
  388. color: #E31818;
  389. display: flex;
  390. justify-content: center;
  391. align-items: center;
  392. }
  393. .video-box-btn {
  394. margin: 0;
  395. height: 40rpx;
  396. background: linear-gradient(90deg, #E31818, #ED3E24, #ED4F24);
  397. border-radius: 20rpx;
  398. display: flex;
  399. justify-content: center;
  400. align-items: center;
  401. color: #FFFFFF;
  402. font-size: 20rpx;
  403. }
  404. }
  405. }
  406. }
  407. .top-box {
  408. margin: 10rpx 20rpx;
  409. }
  410. .unbind {
  411. position: absolute;
  412. width: 100%;
  413. height: 100%;
  414. left: 0;
  415. top: 0;
  416. background-color: rgba(35, 34, 33, 0.2);
  417. z-index: 10;
  418. display: flex;
  419. justify-content: center;
  420. align-items: center;
  421. text-align: center;
  422. color: red;
  423. }
  424. .timingBox {
  425. height: 335rpx;
  426. background-color: #ffffff;
  427. margin: 10rpx;
  428. border-radius: 10rpx;
  429. display: flex;
  430. flex-direction: column;
  431. justify-content: space-between;
  432. padding: 2% 5%;
  433. box-sizing: border-box;
  434. position: relative;
  435. overflow: hidden;
  436. .classHourStatistics {
  437. display: flex;
  438. justify-content: space-between;
  439. .timing-item {
  440. height: 80rpx;
  441. // box-shadow: -2rpx 2rpx 5rpx #5a5a5a;
  442. display: flex;
  443. flex-direction: column;
  444. justify-content: space-between;
  445. align-items: center;
  446. font-size: .8rem;
  447. padding: 25rpx 15rpx;
  448. border-radius: 10rpx;
  449. .timing-time {
  450. font-size: .8rem;
  451. border-radius: 10rpx;
  452. }
  453. }
  454. }
  455. }
  456. </style>