question_statistics.vue 13 KB

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