question_report.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  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. bankNum: 5, // 随机练习的题目数量
  168. };
  169. },
  170. onUnload() {},
  171. computed: { ...mapGetters(['userInfo', 'hideBuyState']) },
  172. onShow() {
  173. this.pageNum = 1
  174. this.courseList = []
  175. this.getcourList()
  176. },
  177. async onLoad(option) {
  178. console.log(option)
  179. this.entryType = option.entryType
  180. this.bankNum = option.bankNum
  181. this.orderGoodsId = option.orderGoodsId
  182. this.recordId = option.id;
  183. this.examId = option.examId;
  184. this.moduleId = option.moduleId || 0;
  185. this.chapterId = option.chapterId || 0;
  186. this.goodsId = option.goodsId || '';
  187. this.examWrongRecordWrongNum();
  188. this.bankExamNextExam()
  189. await this.bankExam();
  190. await this.examReport();
  191. },
  192. onPullDownRefresh() {
  193. this.pageNum = 1
  194. this.courseList = []
  195. this.getcourList()
  196. // this.timer = setTimeout(function() {
  197. // uni.stopPullDownRefresh()
  198. // }, 500)
  199. },
  200. onReachBottom() {
  201. if (this.courseList.length < this.total) {
  202. this.pageNum++
  203. this.getcourList()
  204. }
  205. },
  206. methods: {
  207. getCanvas() {
  208. uni.getSystemInfo({
  209. success: res => {
  210. var winW = res.screenWidth;
  211. var winH = res.screenHeight;
  212. uni.createSelectorQuery()
  213. .in(this)
  214. .select('.canvas')
  215. .boundingClientRect()
  216. .exec(async newRes => {
  217. var width = newRes[0].width;
  218. var height = newRes[0].height;
  219. var caculateX = winW / 750;
  220. var caculateY = winH / 1334;
  221. console.log(caculateX);
  222. if(this.reportdata.totalScore) {
  223. var context1 = uni.createCanvasContext('Canvas1');
  224. this.context1 = context1;
  225. context1.setStrokeStyle('#EEEEEE');
  226. context1.setLineWidth(caculateX * 20);
  227. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  228. context1.stroke();
  229. context1.beginPath();
  230. context1.setStrokeStyle('#32D74B');
  231. context1.setFillStyle('#32D74B');
  232. context1.setTextAlign('center');
  233. context1.setTextBaseline('middle');
  234. context1.setLineCap('round');
  235. context1.setFontSize(caculateX * 64);
  236. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  237. context1.setFillStyle('#999999');
  238. context1.setFontSize(caculateX * 20);
  239. context1.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
  240. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  241. context1.stroke();
  242. context1.draw();
  243. }
  244. if(this.reportdata.examTime) {
  245. var context2 = uni.createCanvasContext('Canvas2');
  246. this.context2 = context2;
  247. context2.setStrokeStyle('#EEEEEE');
  248. context2.setLineWidth(caculateX * 20);
  249. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  250. context2.stroke();
  251. context2.beginPath();
  252. context2.setStrokeStyle('#007AFF');
  253. context2.setFillStyle('#007AFF');
  254. context2.setTextAlign('center');
  255. context2.setTextBaseline('middle');
  256. context2.setLineCap('round');
  257. context2.setFontSize(caculateX * 64);
  258. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  259. context2.setFillStyle('#999999');
  260. context2.setFontSize(caculateX * 20);
  261. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  262. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  263. context2.stroke();
  264. context2.draw();
  265. }
  266. if(this.reportdata.score != -1) {
  267. var context3 = uni.createCanvasContext('Canvas3');
  268. this.context3 = context3;
  269. context3.setStrokeStyle('#EEEEEE');
  270. context3.setLineWidth(caculateX * 20);
  271. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  272. context3.stroke();
  273. context3.beginPath();
  274. context3.setStrokeStyle('#32D74B');
  275. context3.setFillStyle('#32D74B');
  276. context3.setTextAlign('center');
  277. context3.setTextBaseline('middle');
  278. context3.setLineCap('round');
  279. context3.setFontSize(caculateX * 64);
  280. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  281. context3.setFillStyle('#999999');
  282. context3.setFontSize(caculateX * 20);
  283. context3.fillText(`满分${this.reportdata.totalScore || 0}`, caculateX * 90, caculateX * 130, caculateX * 180);
  284. 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);
  285. context3.stroke();
  286. context3.draw();
  287. }
  288. });
  289. }
  290. });
  291. },
  292. getcourList() {
  293. this.$http({
  294. url: '/apply/recommend/goodsList',
  295. method: 'post',
  296. data: {
  297. examId: this.examId,
  298. pageNum: this.pageNum,
  299. pageSize: this.pageSize,
  300. }
  301. }).then((res) => {
  302. if (res.data.code == 200) {
  303. this.courseList.push(...(res.data.rows || [] ))
  304. console.log('this.courseList', this.courseList)
  305. this.total = res.data.total
  306. }
  307. })
  308. },
  309. toBuy(item) {
  310. if (item.goodsType == 2) {
  311. uni.navigateTo({
  312. url: '/pages2/bank/detail?id='+item.goodsId
  313. })
  314. } else {
  315. // /pages5/liveDetail/index
  316. uni.navigateTo({
  317. url: '/pages3/course/detail?id='+item.goodsId + '&goodsType=' + item.goodsType
  318. })
  319. }
  320. },
  321. bankExamNextExam() {
  322. this.$api.bankExamNextExam({
  323. chapterExamId:this.chapterId,
  324. examId:this.examId,
  325. goodsId:this.goodsId,
  326. orderGoodsId:this.orderGoodsId,
  327. moduleExamId:this.moduleId
  328. }).then(res => {
  329. if(res.data.code == 500) {
  330. this.nextExamId = '';
  331. } else if(res.data.code == 200) {
  332. this.nextExamId = res.data.data.examId;
  333. }
  334. })
  335. },
  336. backBank() {
  337. uni.navigateTo({
  338. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  339. });
  340. // uni.navigateBack({
  341. // delta:1
  342. // })
  343. // uni.redirectTo({
  344. // url: '/pages2/bank/my_question'
  345. // });
  346. },
  347. bankExam(){
  348. return new Promise(resolve =>{
  349. this.$api.bankExam(this.examId).then(res => {
  350. this.examData = res.data.data;
  351. resolve()
  352. })
  353. })
  354. },
  355. /**
  356. * 去做题
  357. */
  358. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  359. // await this.getDetail(goodsId);
  360. let count = await this.examRecordCount(id, goodsId);
  361. let answerNum = await this.getExamDetail(id);
  362. //超过答题次数
  363. if (answerNum > 0 && count >= answerNum) {
  364. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  365. return;
  366. }
  367. var pages = getCurrentPages();
  368. var prepage = pages[pages.length - 2]; //上一个页面
  369. prepage.$vm.isRepeat = true;
  370. uni.redirectTo({
  371. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId
  372. + '&entryType=' + this.entryType + '&bankNum=' + this.bankNum
  373. });
  374. },
  375. /**
  376. * @param {Object} exam_id
  377. * 获取试卷可以做的次数
  378. */
  379. getExamDetail(exam_id) {
  380. return new Promise(resolve => {
  381. this.$api.getExamDetail(exam_id).then(res => {
  382. resolve(res.data.data.answerNum);
  383. });
  384. });
  385. },
  386. examWrongRecordWrongNum() {
  387. return new Promise(resolve => {
  388. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  389. this.wrongRecordWrongNum = res.data.data || 0;
  390. resolve();
  391. });
  392. });
  393. },
  394. /**
  395. * 查询试卷历史做题次数
  396. */
  397. examRecordCount(examId, goodsId) {
  398. return new Promise(resolve => {
  399. this.$api
  400. .examRecordCount({
  401. examId: examId,
  402. orderGoodsId: this.orderGoodsId,
  403. })
  404. .then(res => {
  405. resolve(res.data.data);
  406. });
  407. });
  408. },
  409. getDetail(id) {
  410. return new Promise(resolve => {
  411. this.$api.goodsDetail(id).then(res => {
  412. this.goodsData = res.data.data;
  413. resolve();
  414. });
  415. });
  416. },
  417. examReport() {
  418. return new Promise(resolve => {
  419. this.$api.examReport(this.recordId).then(res => {
  420. this.reportdata = res.data.data;
  421. this.getCanvas()
  422. resolve()
  423. });
  424. })
  425. }
  426. }
  427. };
  428. </script>
  429. <style>
  430. page {
  431. background-color: #eaeef1;
  432. }
  433. </style>
  434. <style lang="scss" scope>
  435. @import '../../pages5/examReport/indexCourseList.scss';
  436. .disNone {
  437. display: none;
  438. }
  439. .greenBtn {
  440. margin: 16rpx 16rpx 0;
  441. height: 80rpx;
  442. line-height: 80rpx;
  443. text-align: center;
  444. background-color: #f7fff8;
  445. border-radius: 16rpx;
  446. color: #34c759;
  447. font-weight: bold;
  448. font-size: 30rpx;
  449. }
  450. .redBtn {
  451. margin: 16rpx 16rpx 0;
  452. height: 80rpx;
  453. line-height: 80rpx;
  454. text-align: center;
  455. background-color: #FFF3F2;
  456. border-radius: 16rpx;
  457. color: #FF3B30;
  458. font-weight: bold;
  459. font-size: 30rpx;
  460. }
  461. .dis_fst {
  462. margin-top: 40rpx;
  463. display: flex;
  464. align-items: center;
  465. justify-content: space-around;
  466. }
  467. .btnACs {
  468. height: 48rpx;
  469. width: 160rpx;
  470. text-align: center;
  471. line-height: 48rpx;
  472. border: 1rpx solid #007aff;
  473. border-radius: 16rpx;
  474. color: #007aff;
  475. font-size: 24rpx;
  476. }
  477. .top {
  478. margin: 16rpx 16rpx 0;
  479. border-radius: 16rpx;
  480. padding: 40rpx 24rpx 16rpx;
  481. background: #fff;
  482. .title {
  483. font-size: 32rpx;
  484. font-weight: bold;
  485. color: #333333;
  486. white-space: nowrap;
  487. overflow: hidden;
  488. text-overflow: ellipsis;
  489. }
  490. .desc {
  491. margin-top: 20rpx;
  492. font-size: 24rpx;
  493. color: #999999;
  494. }
  495. .box {
  496. margin-top: 30rpx;
  497. display: flex;
  498. .left {
  499. width: 250rpx;
  500. height: 272rpx;
  501. background: #f5f5f5;
  502. border-radius: 16rpx;
  503. display: flex;
  504. align-items: center;
  505. justify-content: center;
  506. flex-direction: column;
  507. margin-right: 16rpx;
  508. view {
  509. text-align: center;
  510. &:nth-of-type(1) {
  511. font-size: 60rpx;
  512. font-weight: bold;
  513. color: #007aff;
  514. }
  515. &:nth-of-type(2) {
  516. font-size: 32rpx;
  517. font-weight: bold;
  518. color: #333333;
  519. }
  520. &:nth-of-type(3) {
  521. font-size: 24rpx;
  522. color: #999999;
  523. }
  524. }
  525. }
  526. .right {
  527. flex: 1;
  528. display: flex;
  529. flex-direction: column;
  530. justify-content: space-between;
  531. .flex {
  532. background: #f5f5f5;
  533. display: flex;
  534. height: 80rpx;
  535. align-items: center;
  536. padding: 0 40rpx;
  537. border-radius: 16rpx;
  538. image {
  539. margin-right: 28rpx;
  540. &.right_num {
  541. width:26rpx;
  542. }
  543. &.out_num {
  544. width:38rpx;
  545. }
  546. &.wrong_num {
  547. width:30rpx;
  548. }
  549. }
  550. .text {
  551. flex: 1;
  552. font-size: 30rpx;
  553. color: #666666;
  554. }
  555. text {
  556. font-size: 48rpx;
  557. color: #e12626;
  558. &.red {
  559. color: #FF3B30;
  560. }
  561. &.green {
  562. color: #36C75A;
  563. }
  564. &.yellow {
  565. color:#FFC53D;
  566. }
  567. }
  568. }
  569. }
  570. }
  571. }
  572. .bottom {
  573. .circle-wrap {
  574. .circle-list {
  575. display: flex;
  576. .item {
  577. padding: 20rpx;
  578. border-radius: 16rpx;
  579. background: #fff;
  580. margin: 16rpx;
  581. flex: 1;
  582. .title {
  583. font-weight: bold;
  584. font-size: 30rpx;
  585. line-height: 24rpx;
  586. color: #333333;
  587. text {
  588. font-size: 20rpx;
  589. color: #999999;
  590. }
  591. }
  592. canvas {
  593. margin: 36rpx auto 0;
  594. width: 180rpx;
  595. height: 180rpx;
  596. }
  597. .text {
  598. text-align: center;
  599. margin-top: 16rpx;
  600. font-size: 24rpx;
  601. color: #333333;
  602. }
  603. }
  604. }
  605. }
  606. }
  607. </style>