question_report.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659
  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 != 'random' || nextExamId" @click="backBank">继续做题</view>
  81. </view>
  82. </view>
  83. <view v-show="entryType != 'random'" 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. if (this.entryType == 'daily') {
  338. uni.navigateBack()
  339. return
  340. }
  341. uni.navigateTo({
  342. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  343. });
  344. // uni.navigateBack({
  345. // delta:1
  346. // })
  347. // uni.redirectTo({
  348. // url: '/pages2/bank/my_question'
  349. // });
  350. },
  351. bankExam(){
  352. return new Promise(resolve =>{
  353. this.$api.bankExam(this.examId).then(res => {
  354. this.examData = res.data.data;
  355. resolve()
  356. })
  357. })
  358. },
  359. /**
  360. * 去做题
  361. */
  362. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  363. if (this.entryType == 'random') {
  364. uni.navigateBack()
  365. return
  366. }
  367. // await this.getDetail(goodsId);
  368. let count = await this.examRecordCount(id, goodsId);
  369. let answerNum = await this.getExamDetail(id);
  370. //超过答题次数
  371. if (answerNum > 0 && count >= answerNum) {
  372. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  373. return;
  374. }
  375. var pages = getCurrentPages();
  376. var prepage = pages[pages.length - 2]; //上一个页面
  377. prepage.$vm.isRepeat = true;
  378. uni.redirectTo({
  379. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId
  380. + '&entryType=' + this.entryType + '&bankNum=' + this.bankNum
  381. });
  382. },
  383. /**
  384. * @param {Object} exam_id
  385. * 获取试卷可以做的次数
  386. */
  387. getExamDetail(exam_id) {
  388. return new Promise(resolve => {
  389. this.$api.getExamDetail(exam_id).then(res => {
  390. resolve(res.data.data.answerNum);
  391. });
  392. });
  393. },
  394. examWrongRecordWrongNum() {
  395. return new Promise(resolve => {
  396. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  397. this.wrongRecordWrongNum = res.data.data || 0;
  398. resolve();
  399. });
  400. });
  401. },
  402. /**
  403. * 查询试卷历史做题次数
  404. */
  405. examRecordCount(examId, goodsId) {
  406. return new Promise(resolve => {
  407. this.$api
  408. .examRecordCount({
  409. examId: examId,
  410. orderGoodsId: this.orderGoodsId,
  411. })
  412. .then(res => {
  413. resolve(res.data.data);
  414. });
  415. });
  416. },
  417. getDetail(id) {
  418. return new Promise(resolve => {
  419. this.$api.goodsDetail(id).then(res => {
  420. this.goodsData = res.data.data;
  421. resolve();
  422. });
  423. });
  424. },
  425. examReport() {
  426. return new Promise(resolve => {
  427. this.$api.examReport(this.recordId).then(res => {
  428. this.reportdata = res.data.data;
  429. this.getCanvas()
  430. resolve()
  431. });
  432. })
  433. }
  434. }
  435. };
  436. </script>
  437. <style>
  438. page {
  439. background-color: #eaeef1;
  440. }
  441. </style>
  442. <style lang="scss" scope>
  443. @import '../../pages5/examReport/indexCourseList.scss';
  444. .disNone {
  445. display: none;
  446. }
  447. .greenBtn {
  448. margin: 16rpx 16rpx 0;
  449. height: 80rpx;
  450. line-height: 80rpx;
  451. text-align: center;
  452. background-color: #f7fff8;
  453. border-radius: 16rpx;
  454. color: #34c759;
  455. font-weight: bold;
  456. font-size: 30rpx;
  457. }
  458. .redBtn {
  459. margin: 16rpx 16rpx 0;
  460. height: 80rpx;
  461. line-height: 80rpx;
  462. text-align: center;
  463. background-color: #FFF3F2;
  464. border-radius: 16rpx;
  465. color: #FF3B30;
  466. font-weight: bold;
  467. font-size: 30rpx;
  468. }
  469. .dis_fst {
  470. margin-top: 40rpx;
  471. display: flex;
  472. align-items: center;
  473. justify-content: space-around;
  474. }
  475. .btnACs {
  476. height: 48rpx;
  477. width: 160rpx;
  478. text-align: center;
  479. line-height: 48rpx;
  480. border: 1rpx solid #007aff;
  481. border-radius: 16rpx;
  482. color: #007aff;
  483. font-size: 24rpx;
  484. }
  485. .top {
  486. margin: 16rpx 16rpx 0;
  487. border-radius: 16rpx;
  488. padding: 40rpx 24rpx 16rpx;
  489. background: #fff;
  490. .title {
  491. font-size: 32rpx;
  492. font-weight: bold;
  493. color: #333333;
  494. white-space: nowrap;
  495. overflow: hidden;
  496. text-overflow: ellipsis;
  497. }
  498. .desc {
  499. margin-top: 20rpx;
  500. font-size: 24rpx;
  501. color: #999999;
  502. }
  503. .box {
  504. margin-top: 30rpx;
  505. display: flex;
  506. .left {
  507. width: 250rpx;
  508. height: 272rpx;
  509. background: #f5f5f5;
  510. border-radius: 16rpx;
  511. display: flex;
  512. align-items: center;
  513. justify-content: center;
  514. flex-direction: column;
  515. margin-right: 16rpx;
  516. view {
  517. text-align: center;
  518. &:nth-of-type(1) {
  519. font-size: 60rpx;
  520. font-weight: bold;
  521. color: #007aff;
  522. }
  523. &:nth-of-type(2) {
  524. font-size: 32rpx;
  525. font-weight: bold;
  526. color: #333333;
  527. }
  528. &:nth-of-type(3) {
  529. font-size: 24rpx;
  530. color: #999999;
  531. }
  532. }
  533. }
  534. .right {
  535. flex: 1;
  536. display: flex;
  537. flex-direction: column;
  538. justify-content: space-between;
  539. .flex {
  540. background: #f5f5f5;
  541. display: flex;
  542. height: 80rpx;
  543. align-items: center;
  544. padding: 0 40rpx;
  545. border-radius: 16rpx;
  546. image {
  547. margin-right: 28rpx;
  548. &.right_num {
  549. width:26rpx;
  550. }
  551. &.out_num {
  552. width:38rpx;
  553. }
  554. &.wrong_num {
  555. width:30rpx;
  556. }
  557. }
  558. .text {
  559. flex: 1;
  560. font-size: 30rpx;
  561. color: #666666;
  562. }
  563. text {
  564. font-size: 48rpx;
  565. color: #e12626;
  566. &.red {
  567. color: #FF3B30;
  568. }
  569. &.green {
  570. color: #36C75A;
  571. }
  572. &.yellow {
  573. color:#FFC53D;
  574. }
  575. }
  576. }
  577. }
  578. }
  579. }
  580. .bottom {
  581. .circle-wrap {
  582. .circle-list {
  583. display: flex;
  584. .item {
  585. padding: 20rpx;
  586. border-radius: 16rpx;
  587. background: #fff;
  588. margin: 16rpx;
  589. flex: 1;
  590. .title {
  591. font-weight: bold;
  592. font-size: 30rpx;
  593. line-height: 24rpx;
  594. color: #333333;
  595. text {
  596. font-size: 20rpx;
  597. color: #999999;
  598. }
  599. }
  600. canvas {
  601. margin: 36rpx auto 0;
  602. width: 180rpx;
  603. height: 180rpx;
  604. }
  605. .text {
  606. text-align: center;
  607. margin-top: 16rpx;
  608. font-size: 24rpx;
  609. color: #333333;
  610. }
  611. }
  612. }
  613. }
  614. }
  615. </style>