question_report.vue 9.6 KB

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