question_statistics.vue 15 KB

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