question_report.vue 18 KB

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