question_report.vue 10 KB

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