question_report.vue 9.8 KB

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