question_statistics.vue 13 KB

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