question_report.vue 10 KB

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