question_report.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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>{{ (((reportdata.rightQuestionNum / (reportdata.rightQuestionNum + wrongRecordWrongNum)) || 0) * 100).toFixed(0)}}%</view>
  13. <view>正确率</view>
  14. <view>不含简答/案例题</view>
  15. </view>
  16. <view class="right">
  17. <view class="flex up">
  18. <u-icon name="checkmark" color="#16D48B" size="48" style="margin-right: 14rpx;"></u-icon>
  19. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  20. <view class="text">正确题数</view>
  21. <text class="green">{{ reportdata.rightQuestionNum }}</text>
  22. </view>
  23. <view class="flex down">
  24. <u-icon name="close" color="#FF3B30" size="38" style="margin-right: 26rpx;"></u-icon>
  25. <!-- <image src="/static/5-4_03.png" mode=""></image> -->
  26. <view class="text">错误题数</view>
  27. <text class="red">{{ wrongRecordWrongNum }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="dis_fst" v-if="!hideBtns">
  32. <navigator
  33. v-if="wrongRecordWrongNum != 0"
  34. :url="
  35. '/pages2/bank/questionBankWrongExplain?recordId=' + reportdata.recordId+'&id='+examData.examId
  36. "
  37. >
  38. <view class="btnACs">错题解析</view>
  39. </navigator>
  40. <navigator
  41. :url="
  42. '/pages2/bank/questionBankAllExplain?id=' +
  43. reportdata.examId +
  44. '&goodsid=' +
  45. reportdata.goodsId +
  46. '&moduleId=' +
  47. reportdata.moduleExamId +
  48. '&chapterId=' +
  49. reportdata.chapterExamId +
  50. '&recordId='+ reportdata.recordId
  51. "
  52. >
  53. <view class="btnACs">全部解析</view>
  54. </navigator>
  55. <view class="btnACs" @click="doRepeat(reportdata.examId, reportdata.goodsId, reportdata.moduleExamId, reportdata.chapterExamId)">重新做题</view>
  56. <view class="btnACs" v-if="nextExamId" @click="backBank">继续做题</view>
  57. </view>
  58. </view>
  59. <view class="bottom">
  60. <view class="circle-wrap">
  61. <view class="circle-list">
  62. <view class="item" v-show="reportdata.totalScore">
  63. <view class="title">
  64. 试卷得分
  65. <text>(不含简答和案例题)</text>
  66. </view>
  67. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  68. </view>
  69. <view class="item" v-show="reportdata.examTime">
  70. <view class="title">答题时长</view>
  71. <canvas canvas-id="Canvas2"></canvas>
  72. </view>
  73. <view class="item" v-show="reportdata.score != -1">
  74. <view class="title">试卷得分
  75. <text>(含简答和案例题)</text>
  76. </view>
  77. <canvas canvas-id="Canvas3"></canvas>
  78. </view>
  79. </view>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script>
  85. import { mapGetters } from 'vuex';
  86. export default {
  87. data() {
  88. return {
  89. id: '',
  90. hideBtns:false,
  91. recordId:'',
  92. reportdata: {},
  93. examData:{},
  94. examId:'',
  95. moduleId:'',
  96. goodsId:'',
  97. chapterId:'',
  98. context1: null,
  99. context2: null,
  100. nextExamId:'',
  101. wrongRecordWrongNum:'',
  102. orderGoodsId:'',
  103. };
  104. },
  105. onUnload() {},
  106. computed: { ...mapGetters(['userInfo']) },
  107. async onShow() {
  108. },
  109. async onLoad(option) {
  110. console.log(option)
  111. this.orderGoodsId = option.orderGoodsId
  112. this.recordId = option.id;
  113. this.examId = option.examId;
  114. this.moduleId = option.moduleId || 0;
  115. this.chapterId = option.chapterId || 0;
  116. this.goodsId = option.goodsId || '';
  117. this.examWrongRecordWrongNum();
  118. this.bankExamNextExam()
  119. await this.bankExam();
  120. await this.examReport();
  121. uni.getSystemInfo({
  122. success: res => {
  123. var winW = res.screenWidth;
  124. var winH = res.screenHeight;
  125. uni.createSelectorQuery()
  126. .in(this)
  127. .select('.canvas')
  128. .boundingClientRect()
  129. .exec(async newRes => {
  130. var width = newRes[0].width;
  131. var height = newRes[0].height;
  132. var caculateX = winW / 750;
  133. var caculateY = winH / 1334;
  134. console.log(caculateX);
  135. if(this.reportdata.totalScore) {
  136. var context1 = uni.createCanvasContext('Canvas1');
  137. this.context1 = context1;
  138. context1.setStrokeStyle('#EEEEEE');
  139. context1.setLineWidth(caculateX * 20);
  140. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  141. context1.stroke();
  142. context1.beginPath();
  143. context1.setStrokeStyle('#32D74B');
  144. context1.setFillStyle('#32D74B');
  145. context1.setTextAlign('center');
  146. context1.setTextBaseline('middle');
  147. context1.setLineCap('round');
  148. context1.setFontSize(caculateX * 64);
  149. context1.fillText(this.reportdata.performance, caculateX * 90, caculateX * 90, caculateX * 180);
  150. context1.setFillStyle('#999999');
  151. context1.setFontSize(caculateX * 20);
  152. context1.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  153. context1.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.performance / this.reportdata.totalScore) * 2 * Math.PI, false);
  154. context1.stroke();
  155. context1.draw();
  156. }
  157. if(this.reportdata.examTime) {
  158. var context2 = uni.createCanvasContext('Canvas2');
  159. this.context2 = context2;
  160. context2.setStrokeStyle('#EEEEEE');
  161. context2.setLineWidth(caculateX * 20);
  162. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  163. context2.stroke();
  164. context2.beginPath();
  165. context2.setStrokeStyle('#007AFF');
  166. context2.setFillStyle('#007AFF');
  167. context2.setTextAlign('center');
  168. context2.setTextBaseline('middle');
  169. context2.setLineCap('round');
  170. context2.setFontSize(caculateX * 64);
  171. context2.fillText(`${this.reportdata.doTime}'`, caculateX * 90, caculateX * 90, caculateX * 180);
  172. context2.setFillStyle('#999999');
  173. context2.setFontSize(caculateX * 20);
  174. context2.fillText(`限时${this.reportdata.examTime}'`, caculateX * 90, caculateX * 130, caculateX * 180);
  175. context2.arc(caculateX * 90, caculateX * 90, caculateX * 80, -Math.PI/2, -Math.PI/2 + (this.reportdata.doTime / this.reportdata.examTime) * 2 * Math.PI, false);
  176. context2.stroke();
  177. context2.draw();
  178. }
  179. if(this.reportdata.score != -1) {
  180. var context3 = uni.createCanvasContext('Canvas3');
  181. this.context3 = context3;
  182. context3.setStrokeStyle('#EEEEEE');
  183. context3.setLineWidth(caculateX * 20);
  184. context3.arc(caculateX * 90, caculateX * 90, caculateX * 80, 0, 2 * Math.PI, true);
  185. context3.stroke();
  186. context3.beginPath();
  187. context3.setStrokeStyle('#32D74B');
  188. context3.setFillStyle('#32D74B');
  189. context3.setTextAlign('center');
  190. context3.setTextBaseline('middle');
  191. context3.setLineCap('round');
  192. context3.setFontSize(caculateX * 64);
  193. context3.fillText((this.reportdata.performance + this.reportdata.score), caculateX * 90, caculateX * 90, caculateX * 180);
  194. context3.setFillStyle('#999999');
  195. context3.setFontSize(caculateX * 20);
  196. context3.fillText(`满分${this.reportdata.totalScore}`, caculateX * 90, caculateX * 130, caculateX * 180);
  197. 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);
  198. context3.stroke();
  199. context3.draw();
  200. }
  201. });
  202. }
  203. });
  204. },
  205. methods: {
  206. bankExamNextExam() {
  207. this.$api.bankExamNextExam({
  208. chapterExamId:this.chapterId,
  209. examId:this.examId,
  210. goodsId:this.goodsId,
  211. orderGoodsId:this.orderGoodsId,
  212. moduleExamId:this.moduleId
  213. }).then(res => {
  214. if(res.data.code == 500) {
  215. this.nextExamId = '';
  216. } else if(res.data.code == 200) {
  217. this.nextExamId = res.data.data.examId;
  218. }
  219. })
  220. },
  221. backBank() {
  222. uni.navigateTo({
  223. url: '/pages2/bank/questionBank?orderGoodsId='+orderGoodsId+'&id=' +this.nextExamId + '&goodsid=' + this.goodsId + '&moduleId=' + this.moduleId + '&chapterId=' + this.chapterId + ''
  224. });
  225. // uni.navigateBack({
  226. // delta:1
  227. // })
  228. // uni.redirectTo({
  229. // url: '/pages2/bank/my_question'
  230. // });
  231. },
  232. bankExam(){
  233. return new Promise(resolve =>{
  234. this.$api.bankExam(this.examId).then(res => {
  235. this.examData = res.data.data;
  236. resolve()
  237. })
  238. })
  239. },
  240. /**
  241. * 去做题
  242. */
  243. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  244. // await this.getDetail(goodsId);
  245. let count = await this.examRecordCount(id, goodsId);
  246. let answerNum = await this.getExamDetail(id);
  247. //超过答题次数
  248. if (answerNum > 0 && count >= answerNum) {
  249. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  250. return;
  251. }
  252. var pages = getCurrentPages();
  253. var prepage = pages[pages.length - 2]; //上一个页面
  254. prepage.$vm.isRepeat = true;
  255. uni.redirectTo({
  256. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  257. });
  258. },
  259. /**
  260. * @param {Object} exam_id
  261. * 获取试卷可以做的次数
  262. */
  263. getExamDetail(exam_id) {
  264. return new Promise(resolve => {
  265. this.$api.getExamDetail(exam_id).then(res => {
  266. resolve(res.data.data.answerNum);
  267. });
  268. });
  269. },
  270. examWrongRecordWrongNum() {
  271. return new Promise(resolve => {
  272. this.$api.examWrongRecordWrongNum(this.recordId).then(res => {
  273. this.wrongRecordWrongNum = res.data.data || 0;
  274. resolve();
  275. });
  276. });
  277. },
  278. /**
  279. * 查询试卷历史做题次数
  280. */
  281. examRecordCount(examId, goodsId) {
  282. return new Promise(resolve => {
  283. this.$api
  284. .examRecordCount({
  285. examId: examId,
  286. orderGoodsId: this.orderGoodsId,
  287. })
  288. .then(res => {
  289. resolve(res.data.data);
  290. });
  291. });
  292. },
  293. getDetail(id) {
  294. return new Promise(resolve => {
  295. this.$api.goodsDetail(id).then(res => {
  296. this.goodsData = res.data.data;
  297. resolve();
  298. });
  299. });
  300. },
  301. examReport() {
  302. return new Promise(resolve => {
  303. this.$api.examReport(this.recordId).then(res => {
  304. this.reportdata = res.data.data;
  305. resolve()
  306. });
  307. })
  308. }
  309. }
  310. };
  311. </script>
  312. <style>
  313. page {
  314. background-color: #eaeef1;
  315. }
  316. </style>
  317. <style lang="scss" scope>
  318. .disNone {
  319. display: none;
  320. }
  321. .greenBtn {
  322. margin: 16rpx 16rpx 0;
  323. height: 80rpx;
  324. line-height: 80rpx;
  325. text-align: center;
  326. background-color: #f7fff8;
  327. border-radius: 16rpx;
  328. color: #34c759;
  329. font-weight: bold;
  330. font-size: 30rpx;
  331. }
  332. .redBtn {
  333. margin: 16rpx 16rpx 0;
  334. height: 80rpx;
  335. line-height: 80rpx;
  336. text-align: center;
  337. background-color: #FFF3F2;
  338. border-radius: 16rpx;
  339. color: #FF3B30;
  340. font-weight: bold;
  341. font-size: 30rpx;
  342. }
  343. .dis_fst {
  344. margin-top: 40rpx;
  345. display: flex;
  346. align-items: center;
  347. justify-content: space-around;
  348. }
  349. .btnACs {
  350. height: 48rpx;
  351. width: 160rpx;
  352. text-align: center;
  353. line-height: 48rpx;
  354. border: 1rpx solid #007aff;
  355. border-radius: 16rpx;
  356. color: #007aff;
  357. font-size: 24rpx;
  358. }
  359. .top {
  360. margin: 16rpx 16rpx 0;
  361. border-radius: 16rpx;
  362. padding: 40rpx 24rpx 16rpx;
  363. background: #fff;
  364. .title {
  365. font-size: 32rpx;
  366. font-weight: bold;
  367. color: #333333;
  368. }
  369. .desc {
  370. margin-top: 20rpx;
  371. font-size: 24rpx;
  372. color: #999999;
  373. }
  374. .box {
  375. margin-top: 30rpx;
  376. display: flex;
  377. .left {
  378. width: 250rpx;
  379. height: 176rpx;
  380. background: #f5f5f5;
  381. border-radius: 16rpx;
  382. display: flex;
  383. align-items: center;
  384. justify-content: center;
  385. flex-direction: column;
  386. margin-right: 16rpx;
  387. view {
  388. text-align: center;
  389. &:nth-of-type(1) {
  390. font-size: 60rpx;
  391. font-weight: bold;
  392. color: #007aff;
  393. }
  394. &:nth-of-type(2) {
  395. font-size: 32rpx;
  396. font-weight: bold;
  397. color: #333333;
  398. }
  399. &:nth-of-type(3) {
  400. font-size: 24rpx;
  401. color: #999999;
  402. }
  403. }
  404. }
  405. .right {
  406. flex: 1;
  407. display: flex;
  408. flex-direction: column;
  409. justify-content: space-between;
  410. .flex {
  411. background: #f5f5f5;
  412. display: flex;
  413. height: 80rpx;
  414. align-items: center;
  415. padding: 0 40rpx;
  416. border-radius: 16rpx;
  417. image {
  418. width: 30rpx;
  419. height: 30rpx;
  420. margin-right: 28rpx;
  421. }
  422. .text {
  423. flex: 1;
  424. font-size: 30rpx;
  425. color: #666666;
  426. }
  427. text {
  428. font-size: 48rpx;
  429. color: #e12626;
  430. &.red {
  431. color: #FF3B30;
  432. }
  433. &.green {
  434. color: #36C75A;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. }
  441. .bottom {
  442. .circle-wrap {
  443. .circle-list {
  444. display: flex;
  445. .item {
  446. padding: 20rpx;
  447. border-radius: 16rpx;
  448. background: #fff;
  449. margin: 16rpx;
  450. flex: 1;
  451. .title {
  452. font-weight: bold;
  453. font-size: 30rpx;
  454. line-height: 24rpx;
  455. color: #333333;
  456. text {
  457. font-size: 20rpx;
  458. color: #999999;
  459. }
  460. }
  461. canvas {
  462. margin: 36rpx auto 0;
  463. width: 180rpx;
  464. height: 180rpx;
  465. }
  466. .text {
  467. text-align: center;
  468. margin-top: 16rpx;
  469. font-size: 24rpx;
  470. color: #333333;
  471. }
  472. }
  473. }
  474. }
  475. }
  476. </style>