question_statistics.vue 15 KB

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