question_report.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  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/subject/wrongBank?isFromReport=1&explain=1&id=' + reportdata.recordId+'&examId='+examData.examId
  34. "
  35. >
  36. <view class="btnACs" v-if="wrongRecordWrongNum != 0">错题解析</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.navigateBack({
  168. delta:1
  169. })
  170. // uni.redirectTo({
  171. // url: '/pages2/bank/my_question'
  172. // });
  173. },
  174. bankExam(){
  175. return new Promise(resolve =>{
  176. this.$api.bankExam(this.examId).then(res => {
  177. this.examData = res.data.data;
  178. resolve()
  179. })
  180. })
  181. },
  182. /**
  183. * 去做题
  184. */
  185. async doRepeat(id, goodsId, moduleId = 0, chapterId = 0) {
  186. await this.getDetail(goodsId);
  187. let count = await this.examRecordCount(id, goodsId);
  188. let answerNum = await this.getExamDetail(id);
  189. //超过答题次数
  190. if (answerNum > 0 && count >= answerNum) {
  191. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  192. return;
  193. }
  194. uni.navigateTo({
  195. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  196. });
  197. },
  198. /**
  199. * @param {Object} exam_id
  200. * 获取试卷可以做的次数
  201. */
  202. getExamDetail(exam_id) {
  203. return new Promise(resolve => {
  204. this.$api.getExamDetail(exam_id).then(res => {
  205. resolve(res.data.data.answerNum);
  206. });
  207. });
  208. },
  209. examWrongRecordWrongNum() {
  210. return new Promise(resolve => {
  211. this.$api.examWrongRecordWrongNum(this.id).then(res => {
  212. this.wrongRecordWrongNum = res.data.data;
  213. resolve();
  214. });
  215. });
  216. },
  217. /**
  218. * 查询试卷历史做题次数
  219. */
  220. examRecordCount(examId, goodsId) {
  221. return new Promise(resolve => {
  222. this.$api
  223. .examRecordCount({
  224. examId: examId,
  225. goodsId: goodsId
  226. })
  227. .then(res => {
  228. resolve(res.data.data);
  229. });
  230. });
  231. },
  232. getDetail(id) {
  233. return new Promise(resolve => {
  234. this.$api.goodsDetail(id).then(res => {
  235. this.goodsData = res.data.data;
  236. resolve();
  237. });
  238. });
  239. },
  240. examReport() {
  241. return new Promise(resolve => {
  242. this.$api.examReport(this.id).then(res => {
  243. this.reportdata = res.data.data;
  244. resolve()
  245. });
  246. })
  247. }
  248. }
  249. };
  250. </script>
  251. <style>
  252. page {
  253. background-color: #eaeef1;
  254. }
  255. </style>
  256. <style lang="scss" scope>
  257. .disNone {
  258. display: none;
  259. }
  260. .greenBtn {
  261. margin: 16rpx 16rpx 0;
  262. height: 80rpx;
  263. line-height: 80rpx;
  264. text-align: center;
  265. background-color: #f7fff8;
  266. border-radius: 16rpx;
  267. color: #34c759;
  268. font-weight: bold;
  269. font-size: 30rpx;
  270. }
  271. .redBtn {
  272. margin: 16rpx 16rpx 0;
  273. height: 80rpx;
  274. line-height: 80rpx;
  275. text-align: center;
  276. background-color: #FFF3F2;
  277. border-radius: 16rpx;
  278. color: #FF3B30;
  279. font-weight: bold;
  280. font-size: 30rpx;
  281. }
  282. .dis_fst {
  283. margin-top: 40rpx;
  284. display: flex;
  285. align-items: center;
  286. justify-content: space-around;
  287. }
  288. .btnACs {
  289. height: 48rpx;
  290. width: 160rpx;
  291. text-align: center;
  292. line-height: 48rpx;
  293. border: 1rpx solid #007aff;
  294. border-radius: 16rpx;
  295. color: #007aff;
  296. font-size: 24rpx;
  297. }
  298. .top {
  299. margin: 16rpx 16rpx 0;
  300. border-radius: 16rpx;
  301. padding: 40rpx 24rpx 16rpx;
  302. background: #fff;
  303. .title {
  304. font-size: 32rpx;
  305. font-weight: bold;
  306. color: #333333;
  307. }
  308. .desc {
  309. margin-top: 20rpx;
  310. font-size: 24rpx;
  311. color: #999999;
  312. }
  313. .box {
  314. margin-top: 30rpx;
  315. display: flex;
  316. .left {
  317. width: 250rpx;
  318. height: 176rpx;
  319. background: #f5f5f5;
  320. border-radius: 16rpx;
  321. display: flex;
  322. align-items: center;
  323. justify-content: center;
  324. flex-direction: column;
  325. margin-right: 16rpx;
  326. view {
  327. text-align: center;
  328. &:nth-of-type(1) {
  329. font-size: 60rpx;
  330. font-weight: bold;
  331. color: #007aff;
  332. }
  333. &:nth-of-type(2) {
  334. font-size: 32rpx;
  335. font-weight: bold;
  336. color: #333333;
  337. }
  338. &:nth-of-type(3) {
  339. font-size: 24rpx;
  340. color: #999999;
  341. }
  342. }
  343. }
  344. .right {
  345. flex: 1;
  346. display: flex;
  347. flex-direction: column;
  348. justify-content: space-between;
  349. .flex {
  350. background: #f5f5f5;
  351. display: flex;
  352. height: 80rpx;
  353. align-items: center;
  354. padding: 0 40rpx;
  355. border-radius: 16rpx;
  356. image {
  357. width: 30rpx;
  358. height: 30rpx;
  359. margin-right: 28rpx;
  360. }
  361. .text {
  362. flex: 1;
  363. font-size: 30rpx;
  364. color: #666666;
  365. }
  366. text {
  367. font-size: 48rpx;
  368. color: #e12626;
  369. &.red {
  370. color: red;
  371. }
  372. &.green {
  373. color: green;
  374. }
  375. }
  376. }
  377. }
  378. }
  379. }
  380. .bottom {
  381. .circle-wrap {
  382. .circle-list {
  383. display: flex;
  384. .item {
  385. padding: 20rpx;
  386. border-radius: 16rpx;
  387. background: #fff;
  388. margin: 16rpx;
  389. flex: 1;
  390. .title {
  391. font-weight: bold;
  392. font-size: 30rpx;
  393. line-height: 24rpx;
  394. color: #333333;
  395. text {
  396. font-size: 20rpx;
  397. color: #999999;
  398. }
  399. }
  400. canvas {
  401. margin: 36rpx auto 0;
  402. width: 180rpx;
  403. height: 180rpx;
  404. }
  405. .text {
  406. text-align: center;
  407. margin-top: 16rpx;
  408. font-size: 24rpx;
  409. color: #333333;
  410. }
  411. }
  412. }
  413. }
  414. }
  415. </style>