question_statistics.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  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. onShow() {
  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.goodsBankList();
  179. var width = newRes[0].width;
  180. var height = newRes[0].height;
  181. this.caculateX = winW / 750;
  182. this.caculateY = winH / 1334;
  183. var context1 = uni.createCanvasContext('Canvas1');
  184. this.context1 = context1;
  185. context1.setStrokeStyle('#EEEEEE');
  186. context1.setLineWidth(this.caculateX * 20);
  187. context1.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, 2 * Math.PI, true);
  188. context1.stroke();
  189. context1.draw();
  190. var context2 = uni.createCanvasContext('Canvas2');
  191. this.context2 = context2;
  192. context2.setStrokeStyle('#EEEEEE');
  193. context2.setLineWidth(this.caculateX * 20);
  194. context2.arc(this.caculateX * 90, this.caculateX * 90, this.caculateX * 80, 0, 2 * Math.PI, false);
  195. context2.stroke();
  196. context2.draw();
  197. this.goodsBankQuestionNum();
  198. this.goodsBankDolist();
  199. });
  200. }
  201. });
  202. },
  203. methods: {
  204. goodsBankDolist() {
  205. this.$api
  206. .goodsBankDolist({
  207. goodsId:this.id,
  208. orderGoodsId: this.orderGoodsId
  209. })
  210. .then(res => {
  211. console.log(res);
  212. this.bankList = res.data.data;
  213. });
  214. },
  215. goodsBankList() {
  216. this.$api
  217. .goodsBankList({
  218. goodsId:this.id,
  219. orderGoodsId: this.orderGoodsId
  220. })
  221. .then(res => {
  222. console.log(res);
  223. this.bankList = res.data.data;
  224. });
  225. },
  226. goodsBankQuestionNum() {
  227. this.$api.goodsBankQuestionNum(this.orderGoodsId).then(res => {
  228. this.goodsCount = res.data.data;
  229. this.context1.beginPath();
  230. this.context1.setStrokeStyle('#32D74B');
  231. this.context1.setFillStyle('#32D74B');
  232. this.context1.setTextAlign('center');
  233. this.context1.setLineCap('round');
  234. this.context1.setFontSize(this.caculateX * 32);
  235. this.context1.fillText(
  236. ((this.goodsCount.rightNum / this.goodsCount.totalNum) * 100).toFixed(2) + '%',
  237. this.caculateX * 90,
  238. this.caculateX * 90,
  239. this.caculateX * 180
  240. );
  241. this.context1.save();
  242. 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);
  243. this.context1.restore();
  244. this.context1.stroke();
  245. this.context1.draw(true);
  246. this.context2.beginPath();
  247. this.context2.setStrokeStyle('#007AFF');
  248. this.context2.setFillStyle('#007AFF');
  249. this.context2.setTextAlign('center');
  250. this.context2.setLineCap('round');
  251. this.context2.setFontSize(this.caculateX * 32);
  252. this.context2.fillText(((this.goodsCount.doNum / this.goodsCount.totalNum) * 100).toFixed(2) + '%', this.caculateX * 90, this.caculateX * 90, this.caculateX * 180);
  253. this.context2.save();
  254. this.context2.translate(this.caculateX * 90, this.caculateX * 90);
  255. this.context2.rotate((-90 * Math.PI) / 180);
  256. 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);
  257. this.context2.restore();
  258. this.context2.stroke();
  259. this.context2.draw(true);
  260. });
  261. },
  262. clickModule(id, index) {
  263. if (this.bankList[index].list) {
  264. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  265. return;
  266. }
  267. this.$api
  268. .goodsChapterDolist({
  269. goodsId:this.id,
  270. orderGoodsId: this.orderGoodsId,
  271. moduleExamId: id
  272. })
  273. .then(res => {
  274. this.$set(this.bankList[index], 'showList', true);
  275. this.$set(this.bankList[index], 'list', res.data.data);
  276. });
  277. },
  278. changeItem(moduleExamId,index1, id, type,index2) {
  279. if (type == 1) {
  280. if (this.bankList[index1].list[index2].list) {
  281. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  282. return;
  283. }
  284. this.$api
  285. .goodsExamDolist({
  286. goodsId:this.id,
  287. orderGoodsId: this.orderGoodsId,
  288. moduleExamId: moduleExamId,
  289. chapterExamId: id
  290. })
  291. .then(res => {
  292. this.$set(this.bankList[index1].list[index2], 'showList', true);
  293. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  294. });
  295. } else if (type == 2) {
  296. if (this.bankList[index1].list) {
  297. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  298. return;
  299. }
  300. this.$api
  301. .goodsExamDolist({
  302. goodsId:this.id,
  303. orderGoodsId: this.orderGoodsId,
  304. moduleExamId: moduleExamId,
  305. chapterExamId: id
  306. })
  307. .then(res => {
  308. this.$set(this.bankList[index1], 'showList', true);
  309. this.$set(this.bankList[index1], 'list', res.data.data);
  310. });
  311. }
  312. }
  313. }
  314. };
  315. </script>
  316. <style>
  317. page {
  318. background-color: #eaeef1;
  319. }
  320. </style>
  321. <style lang="scss" scope>
  322. .top {
  323. margin: 16rpx;
  324. border-radius: 16rpx;
  325. background: #fff;
  326. padding: 24rpx;
  327. .title {
  328. font-size: 24rpx;
  329. line-height: 24rpx;
  330. color: #333333;
  331. text {
  332. font-size: 30rpx;
  333. color: #999999;
  334. }
  335. }
  336. .circle-wrap {
  337. margin-top: 20rpx;
  338. .circle-list {
  339. display: flex;
  340. .item {
  341. flex: 1;
  342. padding-left: 30rpx;
  343. canvas {
  344. margin: 0 auto;
  345. width: 180rpx;
  346. height: 180rpx;
  347. }
  348. .text {
  349. text-align: center;
  350. margin-top: 16rpx;
  351. font-size: 24rpx;
  352. color: #333333;
  353. }
  354. }
  355. .numbers {
  356. display: flex;
  357. color: #999999;
  358. font-size: 24rpx;
  359. align-items: center;
  360. justify-content: center;
  361. flex-direction: column;
  362. .blue {
  363. margin-bottom: 40rpx;
  364. color: #007aff;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. .courseName {
  371. font-size: 24rpx;
  372. color: #666;
  373. white-space: nowrap;
  374. overflow: hidden;
  375. text-overflow: ellipsis;
  376. }
  377. .moduleItem {
  378. height: 80rpx;
  379. color: #333333;
  380. font-size: 32rpx;
  381. line-height: 80rpx;
  382. font-weight: bold;
  383. display: flex;
  384. justify-content: space-between;
  385. }
  386. .icon_up {
  387. width: 32rpx;
  388. height: 32rpx;
  389. }
  390. .title-list {
  391. background: #eaeef1;
  392. padding: 16rpx 16rpx 124rpx;
  393. .content {
  394. .list {
  395. background: #fff;
  396. margin-bottom: 30rpx;
  397. overflow: hidden;
  398. border-radius: 16rpx;
  399. padding: 10rpx 16rpx;
  400. .module {
  401. font-size: 30rpx;
  402. color: #333333;
  403. .icon {
  404. margin-right: 10rpx;
  405. }
  406. }
  407. .section {
  408. font-size: 30rpx;
  409. font-family: PingFang SC;
  410. font-weight: bold;
  411. color: #333333;
  412. white-space: nowrap;
  413. overflow: hidden;
  414. text-overflow: ellipsis;
  415. margin: 20rpx 0;
  416. display: flex;
  417. align-items: center;
  418. }
  419. .article {
  420. padding: 14rpx 0 10rpx;
  421. display: flex;
  422. align-items: center;
  423. margin-left: 40rpx;
  424. font-size: 24rpx;
  425. color: #666666;
  426. border-bottom: 1rpx solid #eeeeee;
  427. .flex-auto {
  428. font-size: 26rpx;
  429. flex: 1;
  430. margin-right: 30rpx;
  431. &:nth-last-of-type(1) {
  432. border: 0;
  433. }
  434. .desc {
  435. width: 480rpx;
  436. padding: 0 14rpx;
  437. margin-top: 20rpx;
  438. height: 40rpx;
  439. border: 1px solid #eeeeee;
  440. border-radius: 16rpx;
  441. font-size: 26rpx;
  442. display: flex;
  443. align-items: center;
  444. .blue {
  445. font-size: 26rpx;
  446. color: #007aff;
  447. }
  448. .green {
  449. font-size: 26rpx;
  450. color: #32d74b;
  451. }
  452. }
  453. }
  454. .btn {
  455. width: 96rpx;
  456. height: 48rpx;
  457. line-height: 48rpx;
  458. text-align: center;
  459. color: #fff;
  460. font-size: 30rpx;
  461. border-radius: 24rpx;
  462. background: #007aff;
  463. // margin-left:36rpx;
  464. border-radius: 24rpx;
  465. }
  466. }
  467. }
  468. }
  469. }
  470. </style>