question_statistics.vue 14 KB

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