index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671
  1. <template>
  2. <view>
  3. <nav-bar title="试卷报告"></nav-bar>
  4. <view class="top">
  5. <view class="title">{{ reportdata.examName }}</view>
  6. <view class="desc">交卷时间:{{ $method.timestampToTime(reportdata.updateTime, false) }}</view>
  7. <view class="box">
  8. <view class="left">
  9. <view>
  10. <!-- 考试 -->
  11. {{
  12. ((reportdata.rightQuestionNum /
  13. reportdata.totalQuestionNum || 0).toFixed(0) *
  14. 100)
  15. }}%
  16. <!-- {{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}% -->
  17. </view>
  18. <view>正确率</view>
  19. <view>不含简答/案例题</view>
  20. </view>
  21. <view class="right">
  22. <view class="flex up">
  23. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  24. <image class="right_num" src="/static/right_num.png" mode="widthFix"></image>
  25. <view class="text">正确题数</view>
  26. <text class="green">{{ reportdata.rightQuestionNum }}</text>
  27. </view>
  28. <view class="flex up">
  29. <!-- <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon> -->
  30. <image class="out_num" src="/static/out_num.png" mode="widthFix"></image>
  31. <view class="text">少选题数</view>
  32. <text class="yellow">{{ reportdata.lessQuestionNum }}</text>
  33. </view>
  34. <view class="flex down">
  35. <!-- <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon> -->
  36. <image class="wrong_num" src="/static/wrong_num.png" mode="widthFix"></image>
  37. <view class="text">错误题数</view>
  38. <text class="red">{{ wrongRecordWrongNum }}</text>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="dis_fst">
  43. <navigator
  44. hover-class="none"
  45. :url="
  46. '/pages5/examReport/questionBankWrongExplain?recordId=' + reportdata.recordId+'&id='+examData.examId+'&eachExamId='+eachExamId
  47. "
  48. >
  49. <button hover-class="none" class="btnACs">错题解析</button>
  50. </navigator>
  51. <navigator
  52. hover-class="none"
  53. :url="
  54. '/pages5/examReport/questionBankAllExplain?id=' +
  55. reportdata.examId +
  56. '&recordId='+ reportdata.recordId +
  57. '&eachExamId='+eachExamId
  58. "
  59. >
  60. <button hover-class="none" disabled class="btnACs">全部解析</button>
  61. </navigator>
  62. <navigator
  63. hover-class="none"
  64. :url="
  65. '/pages5/examBank/index?examId=' +
  66. reportdata.examId +
  67. '&eachExamId='+eachExamId
  68. "
  69. >
  70. <button hover-class="none" class="btnACs">去做题</button>
  71. </navigator>
  72. </view>
  73. </view>
  74. <view class="bottom">
  75. <view class="circle-wrap">
  76. <view class="circle-list">
  77. <view class="item" v-show="reportdata.totalScore">
  78. <view class="title">
  79. 试卷得分
  80. <text>(不含简答和案例题)</text>
  81. </view>
  82. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  83. </view>
  84. <view class="item" v-show="reportdata.examTime">
  85. <view class="title">答题时长</view>
  86. <canvas canvas-id="Canvas2"></canvas>
  87. </view>
  88. <view class="item" v-show="reportdata.score != -1">
  89. <view class="title">试卷得分
  90. <text>(含简答和案例题)</text>
  91. </view>
  92. <canvas canvas-id="Canvas3"></canvas>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. <template v-if="subscribeInfo.liveStartTime <= sysTime && subscribeInfo.liveEndTime >= sysTime">
  98. <view class="notice" v-if="subscribeInfo.liveSubscribe == 0">
  99. <image class="img" mode="widthFix" src="../static/notice1.png"></image>
  100. <view class="text">
  101. 模考讲解正在直播中
  102. </view>
  103. <view class="btn" @click="goLive()">立即前往查看直播</view>
  104. </view>
  105. </template>
  106. <template v-else>
  107. <view class="notice" v-if="subscribeInfo.liveSubscribe == 0">
  108. <image class="img" mode="widthFix" src="../static/notice1.png"></image>
  109. <view class="text">
  110. 模考讲解直播将在<text class="blue">{{$method.timestampToTime(subscribeInfo.liveStartTime,false,true)}}</text>开始 开启模考讲解直播提醒,不错过每一个考点
  111. </view>
  112. <view class="btn" @click="noticeModal = true">开启模考讲解直播提醒</view>
  113. </view>
  114. <view class="notice" v-if="subscribeInfo.liveSubscribe == 1">
  115. <image class="img" mode="widthFix" src="../static/notice2.png"></image>
  116. <view class="text">
  117. 模考讲解直播将在<text class="blue">{{$method.timestampToTime(subscribeInfo.liveStartTime,false,true)}}</text>开始
  118. </view>
  119. </view>
  120. </template>
  121. <u-popup class="notice__modal" v-model="noticeModal" mode="center" border-radius="24" :mask-close-able="false">
  122. <view class="notice__content">
  123. <view class="body">
  124. <image class="img" src="/pages5/static/notice4.png" mode="widthFix"></image>
  125. <view class="content">
  126. <view class="bold center">开启模考讲解直播提醒</view>
  127. <view class="center text">
  128. 此科目模考分析将在<text class="blue">{{$method.timestampToTime(subscribeInfo.liveStartTime,false,true)}}</text>进行直播讲解,开启直播提醒,不错过名师讲解
  129. </view>
  130. </view>
  131. </view>
  132. <view class="footer">
  133. <view class="btn close" @click="noticeModal = false">暂不开启</view>
  134. <view class="btn" @click="openRemind">开启提醒</view>
  135. </view>
  136. </view>
  137. </u-popup>
  138. </view>
  139. </template>
  140. <script>
  141. import { mapGetters,mapActions } from 'vuex';
  142. import {WEBVIEW_URL} from '@/common/request.js'
  143. export default {
  144. data() {
  145. return {
  146. id: '',
  147. noticeModal:false,
  148. recordId:'',
  149. reportdata: {},
  150. examData:{},
  151. examId:'',
  152. chapterId:'',
  153. context1: null,
  154. context2: null,
  155. eachExamId:'',
  156. wrongRecordWrongNum:0,
  157. subscribeInfo:{}
  158. };
  159. },
  160. onUnload() {},
  161. computed: { ...mapGetters(['userInfo','sysTime']) },
  162. async onShow() {
  163. },
  164. async onLoad(option) {
  165. console.log(option)
  166. this.recordId = option.id;
  167. this.examId = option.examId;
  168. this.eachExamId = option.eachExamId
  169. this.subscribeId = option.subscribeId;
  170. await this.setSystemTime();
  171. this.mockSubscribeInfo();
  172. this.mockWrongRecordWrongNum();
  173. await this.bankExam();
  174. await this.mockReport();
  175. uni.getSystemInfo({
  176. success: res => {
  177. var winW = res.screenWidth;
  178. var winH = res.screenHeight;
  179. uni.createSelectorQuery()
  180. .in(this)
  181. .select('.canvas')
  182. .boundingClientRect()
  183. .exec(async newRes => {
  184. var width = newRes[0].width;
  185. var height = newRes[0].height;
  186. var caculateX = winW / 750;
  187. var caculateY = winH / 1334;
  188. console.log(caculateX);
  189. if(this.reportdata.totalScore) {
  190. var context1 = uni.createCanvasContext('Canvas1');
  191. this.context1 = context1;
  192. context1.setStrokeStyle('#EEEEEE');
  193. context1.setLineWidth(caculateX * 20);
  194. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  195. context1.stroke();
  196. context1.beginPath();
  197. context1.setStrokeStyle('#32D74B');
  198. context1.setFillStyle('#32D74B');
  199. context1.setTextAlign('center');
  200. context1.setTextBaseline('middle');
  201. context1.setLineCap('round');
  202. context1.setFontSize(caculateX * 64);
  203. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  204. context1.setFillStyle('#999999');
  205. context1.setFontSize(caculateX * 20);
  206. context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  207. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  208. context1.stroke();
  209. context1.draw();
  210. }
  211. if(this.reportdata.examTime) {
  212. var context2 = uni.createCanvasContext('Canvas2');
  213. this.context2 = context2;
  214. context2.setStrokeStyle('#EEEEEE');
  215. context2.setLineWidth(caculateX * 20);
  216. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  217. context2.stroke();
  218. context2.beginPath();
  219. context2.setStrokeStyle('#007AFF');
  220. context2.setFillStyle('#007AFF');
  221. context2.setTextAlign('center');
  222. context2.setTextBaseline('middle');
  223. context2.setLineCap('round');
  224. context2.setFontSize(caculateX * 64);
  225. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  226. context2.setFillStyle('#999999');
  227. context2.setFontSize(caculateX * 20);
  228. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  229. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  230. context2.stroke();
  231. context2.draw();
  232. }
  233. if(this.reportdata.score != -1) {
  234. var context3 = uni.createCanvasContext('Canvas3');
  235. this.context3 = context3;
  236. context3.setStrokeStyle('#EEEEEE');
  237. context3.setLineWidth(caculateX * 20);
  238. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  239. context3.stroke();
  240. context3.beginPath();
  241. context3.setStrokeStyle('#32D74B');
  242. context3.setFillStyle('#32D74B');
  243. context3.setTextAlign('center');
  244. context3.setTextBaseline('middle');
  245. context3.setLineCap('round');
  246. context3.setFontSize(caculateX * 64);
  247. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  248. context3.setFillStyle('#999999');
  249. context3.setFontSize(caculateX * 20);
  250. context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  251. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + ((this.reportdata.performance + this.reportdata.score) / this.reportdata.totalScore) * 2 * Math.PI, false);
  252. context3.stroke();
  253. context3.draw();
  254. }
  255. });
  256. }
  257. });
  258. },
  259. methods: {
  260. ...mapActions(['setSystemTime']),
  261. goLive() {
  262. let encode = encodeURIComponent(WEBVIEW_URL+'pages/live/index?token='+uni.getStorageSync('token')+'&userInfo='+JSON.stringify(this.userInfo)+'&channelId='+this.subscribeInfo.liveUrl)
  263. uni.navigateTo({
  264. url:`../../pages/webview/index?url=`+encode
  265. })
  266. },
  267. mockSubscribeInfo(){
  268. this.$api.mockSubscribeInfo(this.subscribeId).then(res => {
  269. this.subscribeInfo = res.data.data
  270. })
  271. },
  272. openRemind() {
  273. this.noticeModal = false
  274. this.$api.mockSubscribeEdit({
  275. subscribeId:this.subscribeId,
  276. liveSubscribe:1,
  277. }).then(res => {
  278. if(res.data.code == 200) {
  279. this.mockSubscribeInfo()
  280. uni.showToast({
  281. icon:'none',
  282. title:'开启成功'
  283. })
  284. }
  285. })
  286. },
  287. bankExam(){
  288. return new Promise(resolve =>{
  289. this.$api.bankExam(this.examId).then(res => {
  290. this.examData = res.data.data;
  291. resolve()
  292. })
  293. })
  294. },
  295. /**
  296. * 去做题
  297. */
  298. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  299. // await this.getDetail(goodsId);
  300. let count = await this.examRecordCount(id, goodsId);
  301. let answerNum = await this.getExamDetail(id);
  302. //超过答题次数
  303. if (answerNum > 0 && count >= answerNum) {
  304. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  305. return;
  306. }
  307. var pages = getCurrentPages();
  308. var prepage = pages[pages.length - 2]; //上一个页面
  309. prepage.$vm.isRepeat = true;
  310. uni.redirectTo({
  311. url: '/pages5/examReport/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  312. });
  313. },
  314. /**
  315. * @param {Object} exam_id
  316. * 获取试卷可以做的次数
  317. */
  318. getExamDetail(exam_id) {
  319. return new Promise(resolve => {
  320. this.$api.getExamDetail(exam_id).then(res => {
  321. resolve(res.data.data.answerNum);
  322. });
  323. });
  324. },
  325. mockWrongRecordWrongNum() {
  326. return new Promise(resolve => {
  327. this.$api.mockWrongRecordWrongNum(this.recordId).then(res => {
  328. this.wrongRecordWrongNum = res.data.data || 0;
  329. resolve();
  330. });
  331. });
  332. },
  333. /**
  334. * 查询试卷历史做题次数
  335. */
  336. examRecordCount(examId, goodsId) {
  337. return new Promise(resolve => {
  338. this.$api
  339. .examRecordCount({
  340. examId: examId,
  341. orderGoodsId: this.orderGoodsId,
  342. })
  343. .then(res => {
  344. resolve(res.data.data);
  345. });
  346. });
  347. },
  348. getDetail(id) {
  349. return new Promise(resolve => {
  350. this.$api.goodsDetail(id).then(res => {
  351. this.goodsData = res.data.data;
  352. resolve();
  353. });
  354. });
  355. },
  356. mockReport() {
  357. return new Promise(resolve => {
  358. this.$api.mockReport(this.recordId).then(res => {
  359. this.reportdata = res.data.data;
  360. resolve()
  361. });
  362. })
  363. }
  364. }
  365. };
  366. </script>
  367. <style>
  368. page {
  369. background-color: #eaeef1;
  370. }
  371. </style>
  372. <style lang="scss" scope>
  373. .disNone {
  374. display: none;
  375. }
  376. .dis_fst {
  377. margin-top: 40rpx;
  378. display: flex;
  379. align-items: center;
  380. justify-content: space-around;
  381. }
  382. .btnACs {
  383. height: 48rpx;
  384. width: 160rpx;
  385. text-align: center;
  386. line-height: 48rpx;
  387. border: 1rpx solid #007aff;
  388. border-radius: 16rpx;
  389. color: #007aff;
  390. font-size: 24rpx;
  391. }
  392. .top {
  393. margin: 16rpx 16rpx 0;
  394. border-radius: 16rpx;
  395. padding: 40rpx 24rpx 16rpx;
  396. background: #fff;
  397. .title {
  398. font-size: 32rpx;
  399. font-weight: bold;
  400. color: #333333;
  401. }
  402. .desc {
  403. margin-top: 20rpx;
  404. font-size: 24rpx;
  405. color: #999999;
  406. }
  407. .box {
  408. margin-top: 30rpx;
  409. display: flex;
  410. .left {
  411. width: 250rpx;
  412. height: 272rpx;
  413. background: #f5f5f5;
  414. border-radius: 16rpx;
  415. display: flex;
  416. align-items: center;
  417. justify-content: center;
  418. flex-direction: column;
  419. margin-right: 16rpx;
  420. view {
  421. text-align: center;
  422. &:nth-of-type(1) {
  423. font-size: 60rpx;
  424. font-weight: bold;
  425. color: #007aff;
  426. }
  427. &:nth-of-type(2) {
  428. font-size: 32rpx;
  429. font-weight: bold;
  430. color: #333333;
  431. }
  432. &:nth-of-type(3) {
  433. font-size: 24rpx;
  434. color: #999999;
  435. }
  436. }
  437. }
  438. .right {
  439. flex: 1;
  440. display: flex;
  441. flex-direction: column;
  442. justify-content: space-between;
  443. .flex {
  444. background: #f5f5f5;
  445. display: flex;
  446. height: 80rpx;
  447. align-items: center;
  448. padding: 0 40rpx;
  449. border-radius: 16rpx;
  450. image {
  451. margin-right: 28rpx;
  452. &.right_num {
  453. width:26rpx;
  454. }
  455. &.out_num {
  456. width:38rpx;
  457. }
  458. &.wrong_num {
  459. width:30rpx;
  460. }
  461. }
  462. .text {
  463. flex: 1;
  464. font-size: 30rpx;
  465. color: #666666;
  466. }
  467. text {
  468. font-size: 48rpx;
  469. color: #e12626;
  470. &.red {
  471. color: #FF3B30;
  472. }
  473. &.green {
  474. color: #36C75A;
  475. }
  476. &.yellow {
  477. color:#FFC53D;
  478. }
  479. }
  480. }
  481. }
  482. }
  483. }
  484. .bottom {
  485. .circle-wrap {
  486. .circle-list {
  487. display: flex;
  488. .item {
  489. padding: 20rpx;
  490. border-radius: 16rpx;
  491. background: #fff;
  492. margin: 16rpx;
  493. flex: 1;
  494. .title {
  495. font-weight: bold;
  496. font-size: 30rpx;
  497. line-height: 24rpx;
  498. color: #333333;
  499. text {
  500. font-size: 20rpx;
  501. color: #999999;
  502. }
  503. }
  504. canvas {
  505. margin: 36rpx auto 0;
  506. width: 180rpx;
  507. height: 180rpx;
  508. }
  509. .text {
  510. text-align: center;
  511. margin-top: 16rpx;
  512. font-size: 24rpx;
  513. color: #333333;
  514. }
  515. }
  516. }
  517. }
  518. }
  519. .notice {
  520. background:#fff;
  521. padding:40rpx;
  522. .img {
  523. width:100%;
  524. }
  525. .text {
  526. text-align: center;
  527. font-size: 28rpx;
  528. color: #666666;
  529. line-height: 48rpx;
  530. .blue {
  531. color:#007AFF;
  532. }
  533. }
  534. .btn {
  535. text-align: center;
  536. line-height: 80rpx;
  537. margin:40rpx auto 0;
  538. width: 528rpx;
  539. height: 80rpx;
  540. background: #007AFF;
  541. border-radius: 40rpx;
  542. color:#fff;
  543. }
  544. }
  545. .notice__modal {
  546. .notice__content {
  547. width: 640rpx;
  548. height: 779rpx;
  549. background: #FFFFFF;
  550. display: flex;
  551. flex-direction: column;
  552. .body {
  553. flex:1;
  554. .content {
  555. padding:30rpx 40rpx 28rpx;
  556. line-height: 40rpx;
  557. font-size: 28rpx;
  558. color:#666;
  559. .img {
  560. width:100%;
  561. }
  562. .bold {
  563. color:#333;
  564. font-size: 32rpx;
  565. font-weight: bold;
  566. }
  567. .center {
  568. text-align: center;
  569. }
  570. .blue {
  571. color:#007AFF;
  572. }
  573. .text {
  574. margin-top:20rpx;
  575. }
  576. }
  577. }
  578. .footer {
  579. height:140rpx;
  580. border-top:1px solid #EEEEEE;
  581. display: flex;
  582. align-items: center;
  583. justify-content: center;
  584. .btn {
  585. margin:0 12rpx;
  586. width: 268rpx;
  587. height: 80rpx;
  588. color:#fff;
  589. font-size: 30rpx;
  590. text-align: center;
  591. line-height: 80rpx;
  592. background: #007AFF;
  593. border-radius: 40rpx 40rpx 40rpx 40rpx;
  594. &.close {
  595. color:#007AFF;
  596. background: #F5F5F5;
  597. border-radius: 40rpx 40rpx 40rpx 40rpx;
  598. }
  599. }
  600. }
  601. }
  602. }
  603. </style>