question_report.vue 12 KB

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