index.vue 11 KB

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