question_report.vue 13 KB

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