question_statistics.vue 13 KB

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