question_statistics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <view>
  3. <view class="top">
  4. <view class="title">
  5. 做题统计
  6. <text>(不含简答和案例题)</text>
  7. </view>
  8. <view class="circle-wrap">
  9. <view class="circle-list">
  10. <view class="item">
  11. <canvas class="canvas" canvas-id="Canvas1"></canvas>
  12. <view class="text">正确率</view>
  13. </view>
  14. <view class="item">
  15. <canvas canvas-id="Canvas2"></canvas>
  16. <view class="text">做题进度</view>
  17. </view>
  18. <view class="numbers">
  19. <view class="blue">已答 {{ goodsCount.doNum }}</view>
  20. <view>总数 {{ goodsCount.totalNum }}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <view class="title-list">
  26. <view class="content">
  27. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  28. <template v-if="item1.type == 1">
  29. <view class="moduleItem" @click="clickModule(item1.majorId, index1)">
  30. <view class="courseName">{{ item1.name }}</view>
  31. <view>
  32. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  33. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  34. </view>
  35. </view>
  36. <template v-if="item1.showList">
  37. <view v-for="(item2, index2) in item1.list" :key="index2">
  38. <view class="section" @click="changeItem(index1, item2.chapterExamId, item1.type)">
  39. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  40. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image> -->
  41. <u-icon name="arrow-up" color="#999" size="24" v-if="item2.showList"></u-icon>
  42. <u-icon name="arrow-down" color="#999" size="24" v-if="!item2.showList"></u-icon>
  43. <text
  44. style="margin-left:34rpx;font-size: 24rpx;
  45. color:#666;"
  46. >
  47. {{ item2.name }}
  48. </text>
  49. </view>
  50. <view v-if="item2.showList">
  51. <view class="article" v-for="(article, index3) in item2.list" :key="index3">
  52. <view class="flex-auto">
  53. <view class="tit">{{ article.examName }}</view>
  54. <view class="desc">
  55. <view class="flex-auto">
  56. 正确率
  57. <text class="green">65%</text>
  58. </view>
  59. <view class="flex-auto">
  60. 已完成
  61. <text class="blue">65%</text>
  62. </view>
  63. </view>
  64. </view>
  65. <navigator
  66. :url="
  67. '/pages2/bank/questionBankExplain?continue=1&recordId=' +
  68. article.recordId +
  69. '&id=' +
  70. article.examId +
  71. '&goodsid=' +
  72. article.goodsId +
  73. '&moduleId=' +
  74. article.moduleExamId +
  75. '&chapterId=' +
  76. article.chapterExamId +
  77. ''
  78. "
  79. >
  80. <view class="btn" v-if="article.recordStatus == 0">继续</view>
  81. </navigator>
  82. <view class="btn" v-if="article.recordStatus == 1" @click="doRepeat(article.recordId,article.examId,article.goodsId,article.moduleExamId,article.chapterExamId)">重做</view>
  83. </view>
  84. </view>
  85. <u-line></u-line>
  86. </view>
  87. </template>
  88. </template>
  89. <template v-if="item1.type == 2">
  90. <view class="section" @click="changeItem(index1, item1.majorId, item1.type)">
  91. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  92. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image> -->
  93. <u-icon name="arrow-up" color="#999" size="24" v-if="item1.showList"></u-icon>
  94. <u-icon name="arrow-down" color="#999" size="24" v-if="!item1.showList"></u-icon>
  95. <text style="margin-left:34rpx;font-size: 24rpx;color:#666;">{{ item1.name }}</text>
  96. </view>
  97. <view v-if="item1.showList">
  98. <view class="article" :key="index3" v-for="(article, index2) in item1.list">
  99. <view class="flex-auto">
  100. <view class="tit">{{ article.name }}</view>
  101. <view class="desc">
  102. <view class="flex-auto">
  103. 正确率
  104. <text class="green">65%</text>
  105. </view>
  106. <view class="flex-auto">
  107. 已完成
  108. <text class="blue">65%</text>
  109. </view>
  110. </view>
  111. </view>
  112. <navigator
  113. :url="
  114. '/pages2/bank/questionBankExplain?continue=1&recordId=' +
  115. article.recordId +
  116. '&id=' +
  117. article.examId +
  118. '&goodsid=' +
  119. article.goodsId +
  120. '&moduleId=0&chapterId=' +
  121. article.chapterExamId +
  122. ''
  123. "
  124. >
  125. <view class="btn" v-if="article.recordStatus == 0">继续</view>
  126. </navigator>
  127. <view class="btn" v-if="article.recordStatus == 1" @click="doRepeat(article.recordId,article.examId,article.goodsId,0,article.chapterExamId)">重做</view>
  128. </view>
  129. </view>
  130. </template>
  131. <template v-if="item1.type == 3">
  132. <view class="article">
  133. <view class="flex-auto">
  134. <view class="tit">{{ item1.name }}</view>
  135. <view class="desc">
  136. <view class="flex-auto">
  137. 正确率
  138. <text class="green">65%</text>
  139. </view>
  140. <view class="flex-auto">
  141. 已完成
  142. <text class="blue">65%</text>
  143. </view>
  144. </view>
  145. </view>
  146. <navigator
  147. :url="
  148. '/pages2/bank/questionBankExplain?continue=1&recordId=' +
  149. item1.recordId +
  150. '&id=' +
  151. item1.majorId +
  152. '&goodsid=' +
  153. item1.goodsId +
  154. '&moduleId=0&chapterId=0'
  155. "
  156. >
  157. <view class="btn" v-if="item1.recordStatus == 0">继续</view>
  158. </navigator>
  159. <view class="btn" v-if="item1.recordStatus == 1" @click="doRepeat(item1.recordId,item1.majorId,item1.goodsId,0,0)">重做</view>
  160. </view>
  161. </template>
  162. </view>
  163. </view>
  164. </view>
  165. </view>
  166. </template>
  167. <script>
  168. import { mapGetters } from 'vuex';
  169. export default {
  170. data() {
  171. return {
  172. bankList: [],
  173. goodsCount: {},
  174. id: '',
  175. context1: null,
  176. context2: null,
  177. caculateX: 0,
  178. caculateY: 0
  179. };
  180. },
  181. onUnload() {},
  182. computed: { ...mapGetters(['userInfo']) },
  183. onLoad(option) {
  184. this.id = option.id;
  185. },
  186. onShow() {
  187. uni.getSystemInfo({
  188. success: res => {
  189. var winW = res.screenWidth;
  190. var winH = res.screenHeight;
  191. uni.createSelectorQuery()
  192. .in(this)
  193. .select('.canvas')
  194. .boundingClientRect()
  195. .exec(newRes => {
  196. // this.goodsBankList();
  197. var width = newRes[0].width;
  198. var height = newRes[0].height;
  199. this.caculateX = winW / 750;
  200. this.caculateY = winH / 1334;
  201. var context1 = uni.createCanvasContext('Canvas1');
  202. this.context1 = context1;
  203. context1.setStrokeStyle('#EEEEEE');
  204. context1.setLineWidth(this.caculateX * 20);
  205. context1.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, 2 * Math.PI, true);
  206. context1.stroke();
  207. context1.draw();
  208. var context2 = uni.createCanvasContext('Canvas2');
  209. this.context2 = context2;
  210. context2.setStrokeStyle('#EEEEEE');
  211. context2.setLineWidth(this.caculateX * 20);
  212. context2.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, 2 * Math.PI, false);
  213. context2.stroke();
  214. context2.draw();
  215. this.goodsBankQuestionNum();
  216. this.goodsBankDolist();
  217. });
  218. }
  219. });
  220. },
  221. methods: {
  222. doRepeat(recordId,examId,goodsId,chapterExamId) {
  223. uni.showModal({
  224. title: '提示',
  225. content: '是否清空答案重做?',
  226. cancelText:'查看上次',
  227. cancelColor:'',
  228. confirmText:'重做',
  229. confirmColor:'',
  230. success: (res) => {
  231. if (res.confirm) {
  232. uni.navigateTo({
  233. url:'/pages2/bank/questionBank?id=' +examId +'&goodsid=' +goodsId +'&moduleId=0&chapterId=' +chapterExamId
  234. })
  235. } else if (res.cancel) {
  236. uni.navigateTo({
  237. url:'/pages2/bank/questionBankExplain?isHistory=1&recordId='+recordId +'&id=' +examId +'&goodsid=' +goodsId +'&moduleId=0&chapterId=' +chapterExamId
  238. })
  239. console.log('查看上次答题');
  240. }
  241. }
  242. });
  243. },
  244. goodsBankDolist() {
  245. this.$api
  246. .goodsBankDolist({
  247. goodsId: this.id
  248. })
  249. .then(res => {
  250. console.log(res);
  251. this.bankList = res.data.data;
  252. });
  253. },
  254. goodsBankList() {
  255. this.$api
  256. .goodsBankList({
  257. goodsId: this.id
  258. })
  259. .then(res => {
  260. console.log(res);
  261. this.bankList = res.data.data;
  262. });
  263. },
  264. goodsBankQuestionNum() {
  265. this.$api.goodsBankQuestionNum(this.id).then(res => {
  266. this.goodsCount = res.data.data;
  267. this.context1.beginPath();
  268. this.context1.setStrokeStyle('#32D74B');
  269. this.context1.setFillStyle('#32D74B');
  270. this.context1.setTextAlign('center');
  271. this.context1.setLineCap('round');
  272. this.context1.setFontSize(this.caculateX * 32);
  273. this.context1.fillText(
  274. ((this.goodsCount.rightNum / this.goodsCount.totalNum) * 100).toFixed(2) + '%',
  275. this.caculateX * 90,
  276. this.caculateX * 90,
  277. this.caculateX * 180
  278. );
  279. this.context1.save();
  280. this.context1.translate(this.caculateX * 90, this.caculateX * 90);
  281. this.context1.rotate((-90 * Math.PI) / 180);
  282. this.context1.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, (this.goodsCount.rightNum / this.goodsCount.totalNum) * 2 * Math.PI, false);
  283. this.context1.restore();
  284. this.context1.stroke();
  285. this.context1.draw(true);
  286. this.context2.beginPath();
  287. this.context2.setStrokeStyle('#007AFF');
  288. this.context2.setFillStyle('#007AFF');
  289. this.context2.setTextAlign('center');
  290. this.context2.setLineCap('round');
  291. this.context2.setFontSize(this.caculateX * 32);
  292. this.context2.fillText(((this.goodsCount.doNum / this.goodsCount.totalNum) * 100).toFixed(2) + '%', this.caculateX * 90, this.caculateX * 90, this.caculateX * 180);
  293. this.context2.save();
  294. this.context2.translate(this.caculateX * 90, this.caculateX * 90);
  295. this.context2.rotate((-90 * Math.PI) / 180);
  296. this.context2.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, (this.goodsCount.doNum / this.goodsCount.totalNum) * 2 * Math.PI, false);
  297. this.context2.restore();
  298. this.context2.stroke();
  299. this.context2.draw(true);
  300. });
  301. },
  302. clickModule(id, index) {
  303. if (this.bankList[index].list) {
  304. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  305. return;
  306. }
  307. this.$api
  308. .goodsChapterDolist({
  309. moduleExamId: id
  310. })
  311. .then(res => {
  312. this.$set(this.bankList[index], 'showList', true);
  313. this.$set(this.bankList[index], 'list', res.data.data);
  314. });
  315. },
  316. changeItem(index1, id, type) {
  317. if (type == 1) {
  318. if (this.bankList[index1].list[index2].list) {
  319. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  320. return;
  321. }
  322. this.$api
  323. .goodsExamList({
  324. chapterExamId: id
  325. })
  326. .then(res => {
  327. this.$set(this.bankList[index1].list[index2], 'showList', true);
  328. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  329. });
  330. } else if (type == 2) {
  331. if (this.bankList[index1].list) {
  332. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  333. return;
  334. }
  335. this.$api
  336. .goodsExamDolist({
  337. chapterExamId: id
  338. })
  339. .then(res => {
  340. this.$set(this.bankList[index1], 'showList', true);
  341. this.$set(this.bankList[index1], 'list', res.data.data);
  342. });
  343. }
  344. }
  345. }
  346. };
  347. </script>
  348. <style>
  349. page {
  350. background-color: #eaeef1;
  351. }
  352. </style>
  353. <style lang="scss" scope>
  354. .top {
  355. margin: 16rpx;
  356. border-radius: 16rpx;
  357. background: #fff;
  358. padding: 24rpx;
  359. .title {
  360. font-size: 24rpx;
  361. line-height: 24rpx;
  362. color: #333333;
  363. text {
  364. font-size: 30rpx;
  365. color: #999999;
  366. }
  367. }
  368. .circle-wrap {
  369. margin-top: 20rpx;
  370. .circle-list {
  371. display: flex;
  372. .item {
  373. flex: 1;
  374. padding-left: 30rpx;
  375. canvas {
  376. margin: 0 auto;
  377. width: 180rpx;
  378. height: 180rpx;
  379. }
  380. .text {
  381. text-align: center;
  382. margin-top: 16rpx;
  383. font-size: 24rpx;
  384. color: #333333;
  385. }
  386. }
  387. .numbers {
  388. display: flex;
  389. color: #999999;
  390. font-size: 24rpx;
  391. align-items: center;
  392. justify-content: center;
  393. flex-direction: column;
  394. .blue {
  395. margin-bottom: 40rpx;
  396. color: #007aff;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. .courseName {
  403. font-size: 24rpx;
  404. color: #666;
  405. white-space: nowrap;
  406. overflow: hidden;
  407. text-overflow: ellipsis;
  408. }
  409. .moduleItem {
  410. height: 80rpx;
  411. color: #333333;
  412. font-size: 32rpx;
  413. line-height: 80rpx;
  414. font-weight: bold;
  415. display: flex;
  416. justify-content: space-between;
  417. }
  418. .icon_up {
  419. width: 32rpx;
  420. height: 32rpx;
  421. }
  422. .title-list {
  423. background: #eaeef1;
  424. padding: 16rpx 16rpx 124rpx;
  425. .content {
  426. .list {
  427. background: #fff;
  428. margin-bottom: 30rpx;
  429. overflow: hidden;
  430. border-radius: 16rpx;
  431. padding: 10rpx 16rpx;
  432. .module {
  433. font-size: 30rpx;
  434. color: #333333;
  435. .icon {
  436. margin-right: 10rpx;
  437. }
  438. }
  439. .section {
  440. font-size: 30rpx;
  441. font-family: PingFang SC;
  442. font-weight: bold;
  443. color: #333333;
  444. white-space: nowrap;
  445. overflow: hidden;
  446. text-overflow: ellipsis;
  447. margin: 20rpx 0;
  448. display: flex;
  449. align-items: center;
  450. }
  451. .article {
  452. padding: 14rpx 0 10rpx;
  453. display: flex;
  454. align-items: center;
  455. margin-left: 40rpx;
  456. font-size: 24rpx;
  457. color: #666666;
  458. border-bottom: 1rpx solid #eeeeee;
  459. .flex-auto {
  460. font-size: 26rpx;
  461. flex: 1;
  462. margin-right: 30rpx;
  463. &:nth-last-of-type(1) {
  464. border: 0;
  465. }
  466. .desc {
  467. width: 480rpx;
  468. padding: 0 14rpx;
  469. margin-top: 20rpx;
  470. height: 40rpx;
  471. border: 1px solid #eeeeee;
  472. border-radius: 16rpx;
  473. font-size: 26rpx;
  474. display: flex;
  475. align-items: center;
  476. .blue {
  477. font-size: 26rpx;
  478. color: #007aff;
  479. }
  480. .green {
  481. font-size: 26rpx;
  482. color: #32d74b;
  483. }
  484. }
  485. }
  486. .btn {
  487. width: 96rpx;
  488. height: 48rpx;
  489. line-height: 48rpx;
  490. text-align: center;
  491. color: #fff;
  492. font-size: 30rpx;
  493. border-radius: 24rpx;
  494. background: #007aff;
  495. // margin-left:36rpx;
  496. border-radius: 24rpx;
  497. }
  498. }
  499. }
  500. }
  501. }
  502. </style>