question_statistics.vue 13 KB

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