index.vue 16 KB

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