question_detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  1. <template>
  2. <view>
  3. <nav-bar title="进入刷题"></nav-bar>
  4. <view class="top">
  5. <navigator hover-class="none" :url="'/pages2/bank/question_statistics?id=' + id">
  6. <view class="left">
  7. <view class="title">做题统计</view>
  8. <view class="progress">
  9. <view class="item-left">
  10. <view class="desc"><text>总进度</text></view>
  11. <view class="percent">
  12. {{
  13. goodsCount.totalNum > 0
  14. ? ((goodsCount.doNum / goodsCount.totalNum) * 100).toFixed((goodsCount.doNum / goodsCount.totalNum) * 100 == 100 ? 0 : 1)
  15. : 0
  16. }}
  17. <text class="per">%</text>
  18. </view>
  19. </view>
  20. <view class="item-right">
  21. <view class="up">
  22. <text class="orange">已答</text>
  23. <text>/未答</text>
  24. </view>
  25. <view class="down">
  26. <text class="orange">{{ goodsCount.doNum }}</text>
  27. <text>/{{ goodsCount.totalNum - goodsCount.doNum }}</text>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </navigator>
  33. <navigator hover-class="none" :url="'/pages2/bank/wrongById?goodsid=' + id">
  34. <view class="right">
  35. <view class="title">
  36. 错题集
  37. <u-icon name="arrow-right"></u-icon>
  38. </view>
  39. <view class="number">{{ goodsCount.wrongNum || '0' }}</view>
  40. </view>
  41. </navigator>
  42. <navigator hover-class="none" :url="'/pages2/bank/collectById?goodsid=' + id">
  43. <view class="right">
  44. <view class="title">
  45. 收藏集
  46. <u-icon name="arrow-right"></u-icon>
  47. </view>
  48. <view class="number">{{ goodsCount.collectNum || '0' }}</view>
  49. </view>
  50. </navigator>
  51. </view>
  52. <view class="title-list">
  53. <view class="content">
  54. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  55. <template v-if="item1.type == 1">
  56. <view class="moduleItem" @click="clickModule(item1.majorId, index1)">
  57. <view class="courseName">{{ item1.name }}</view>
  58. <view>
  59. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  60. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  61. </view>
  62. </view>
  63. <template v-if="item1.showList">
  64. <view v-for="(item2, index2) in item1.list" :key="index2">
  65. <view class="section" @click="changeItem(index1, item2.chapterExamId, item1.type, index2)">
  66. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  67. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  68. <!-- <u-icon name="arrow-up" color="#999" size="24" v-if="item2.showList"></u-icon>
  69. <u-icon name="arrow-down" color="#999" size="24" v-if="!item2.showList"></u-icon> -->
  70. <text style="margin-left:34rpx;">{{ item2.name }}</text>
  71. </view>
  72. <view v-if="item2.showList">
  73. <view class="article active" style="margin-left:62rpx;" v-for="(article, index3) in item2.list" :key="index3">
  74. <view class="flex_auto">{{ article.examName }}</view>
  75. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, item1.majorId, item2.chapterExamId)" v-if="article.recordStatus == -1">做题</view>
  76. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  77. <view class="btn" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  78. </view>
  79. </view>
  80. <u-line v-if="item1.length > 1"></u-line>
  81. </view>
  82. </template>
  83. </template>
  84. <template v-if="item1.type == 2">
  85. <view class="section" @click="changeItem(index1, item1.majorId, item1.type)">
  86. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  87. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  88. <!-- <u-icon name="arrow-up" color="#999" size="24" v-if="item1.showList"></u-icon>
  89. <u-icon name="arrow-down" color="#999" size="24" v-if="!item1.showList"></u-icon> -->
  90. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  91. </view>
  92. <view v-if="item1.showList">
  93. <view class="article active" style="margin-left:64rpx;" v-for="(article, index2) in item1.list" :key="index2">
  94. <view class="flex_auto">{{ article.examName }}</view>
  95. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == -1">做题</view>
  96. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  97. <view class="btn" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item1.majorId,0)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  98. </view>
  99. </view>
  100. </template>
  101. <template v-if="item1.type == 3">
  102. <view class="article active">
  103. <view class="flex_auto">{{ item1.name }}</view>
  104. <view class="btn" @click="toDo(item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == -1">做题</view>
  105. <view class="btn" @click="continueDo(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 0 && item1.doType == 1">继续</view>
  106. <view class="btn" @click="doRepeat(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 1 || (item1.recordStatus == 0 && item1.doType == 2)">重做</view>
  107. </view>
  108. </template>
  109. </view>
  110. </view>
  111. </view>
  112. </view>
  113. </template>
  114. <script>
  115. import { mapGetters } from 'vuex';
  116. export default {
  117. data() {
  118. return {
  119. goodsData: {},
  120. bankList: [],
  121. id: '',
  122. goodsCount: {
  123. totalNum: 0
  124. },
  125. firstEnter:true,
  126. };
  127. },
  128. onUnload() {
  129. },
  130. computed: { ...mapGetters(['userInfo']) },
  131. onLoad(option) {
  132. this.id = option.id;
  133. this.getDetail();
  134. // this.goodsBankList();
  135. // this.getCollectNum();
  136. // this.getWrongNum()
  137. },
  138. onShow() {
  139. this.goodsBankQuestionNum();
  140. this.goodsBank();
  141. },
  142. methods: {
  143. /**
  144. * 继续做题
  145. */
  146. continueDo(recordId,examId,goodsId,chapterId = 0,moduleId = 0) {
  147. uni.navigateTo({
  148. url:'/pages2/bank/questionBankContinue?recordId=' +recordId +'&id=' +examId +'&goodsid=' +goodsId +'&chapterId='+chapterId+'&moduleId='+moduleId
  149. })
  150. },
  151. /**
  152. * 重做
  153. * @param {Object} recordId
  154. * @param {Object} examId
  155. * @param {Object} goodsId
  156. * @param {Object} chapterExamId
  157. */
  158. async doRepeat(recordId,examId,goodsId,chapterExamId=0,moduleId=0) {
  159. let count = await this.examRecordCount(examId);
  160. let answerNum = await this.getExamDetail(examId);
  161. //超过答题次数
  162. if (answerNum > 0 && count >= answerNum) {
  163. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  164. return;
  165. }
  166. uni.showModal({
  167. title: '提示',
  168. content: '是否清空答案重做?',
  169. cancelText:'查看上次',
  170. cancelColor:'',
  171. confirmText:'重做',
  172. confirmColor:'',
  173. success: (res) => {
  174. if (res.confirm) {
  175. uni.navigateTo({
  176. url:'/pages2/bank/questionBank?id=' +examId +'&goodsid=' +goodsId +'&moduleId='+moduleId+'&chapterId=' +chapterExamId
  177. })
  178. } else if (res.cancel) {
  179. uni.navigateTo({
  180. url:'/pages2/bank/questionBankAllExplain?id=' + examId +
  181. '&goodsid=' + goodsId +
  182. '&moduleId=' + moduleId +
  183. '&chapterId=' + chapterExamId +
  184. '&recordId='+ recordId
  185. })
  186. console.log('查看上次答题');
  187. }
  188. }
  189. });
  190. },
  191. /**
  192. * 获取课程目录
  193. */
  194. goodsBank() {
  195. this.$api.goodsBank({
  196. goodsId: this.id
  197. }).then(res => {
  198. this.bankList = res.data.data;
  199. if(this.firstEnter) {
  200. this.showAllCharpter();
  201. this.firstEnter = false;
  202. }
  203. });
  204. },
  205. /**
  206. * 展示第一个章下的节内容
  207. */
  208. showAllCharpter() {
  209. for(let i = 0; i < this.bankList.length; i++) {
  210. if(this.bankList[i].type == 1) { //第一个是模块直接展开,再展开章下面的节
  211. this.$api
  212. .goodsChapterList({
  213. moduleExamId: this.bankList[i].majorId
  214. })
  215. .then(res => {
  216. this.$set(this.bankList[i], 'showList', true);
  217. this.$set(this.bankList[i], 'list', res.data.data);
  218. this.changeItem(i,this.bankList[i].list[0].chapterExamId,this.bankList[i].type,0)
  219. });
  220. break;
  221. } else if(this.bankList[i].type == 2) { //第一个章展开下面的节
  222. this.changeItem(i,this.bankList[i].majorId,this.bankList[i].type,'')
  223. break;
  224. }
  225. }
  226. },
  227. getDetail() {
  228. this.$api.commonGoodsDetail(this.id).then(res => {
  229. console.log(res);
  230. this.goodsData = res.data.data;
  231. });
  232. },
  233. /**
  234. * 去做题
  235. */
  236. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  237. console.log(id,goodsId,moduleId,chapterId)
  238. let count = await this.examRecordCount(id);
  239. let answerNum = await this.getExamDetail(id);
  240. //超过答题次数
  241. if (answerNum > 0 && count >= answerNum) {
  242. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  243. return;
  244. }
  245. uni.navigateTo({
  246. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  247. });
  248. },
  249. /**
  250. * 查询试卷历史做题次数
  251. */
  252. examRecordCount(examId) {
  253. return new Promise(resolve => {
  254. this.$api
  255. .examRecordCount({
  256. examId: examId,
  257. goodsId: this.id
  258. })
  259. .then(res => {
  260. resolve(res.data.data);
  261. });
  262. });
  263. },
  264. /**
  265. * @param {Object} exam_id
  266. * 获取试卷可以做的次数
  267. */
  268. getExamDetail(exam_id) {
  269. return new Promise(resolve => {
  270. this.$api.getExamDetail(exam_id).then(res => {
  271. resolve(res.data.data.answerNum);
  272. });
  273. });
  274. },
  275. /**
  276. * 获取用户商品统计数据
  277. */
  278. goodsBankQuestionNum() {
  279. this.$api.goodsBankQuestionNum(this.id).then(res => {
  280. this.goodsCount = res.data.data;
  281. });
  282. },
  283. goodsBankList() {
  284. this.$api
  285. .goodsBankList({
  286. goodsId: this.id
  287. })
  288. .then(res => {
  289. console.log(res);
  290. this.bankList = res.data.data;
  291. });
  292. },
  293. getCollectNum() {
  294. this.$api
  295. .goodsCollectExamList({
  296. goodsId: this.id
  297. })
  298. .then(res => {
  299. let total = 0;
  300. res.data.rows.forEach(item => {
  301. total += item.questionNum;
  302. });
  303. this.collectTotal = total;
  304. });
  305. },
  306. getWrongNum() {
  307. this.$api
  308. .wrongRecordList({
  309. goodsId: this.id
  310. })
  311. .then(res => {
  312. let total = 0;
  313. res.data.rows.forEach(item => {
  314. total += item.wrongQuestionNum;
  315. });
  316. this.wrongTotal = total;
  317. });
  318. },
  319. clickModule(id, index) {
  320. if (this.bankList[index].list) {
  321. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  322. return;
  323. }
  324. this.$api
  325. .goodsChapterList({
  326. moduleExamId: id,
  327. goodsId:this.id
  328. })
  329. .then(res => {
  330. this.$set(this.bankList[index], 'showList', true);
  331. this.$set(this.bankList[index], 'list', res.data.data);
  332. });
  333. },
  334. changeItem(index1, id, type, index2) {
  335. if (type == 1) {
  336. if (this.bankList[index1].list[index2].list) {
  337. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  338. return;
  339. }
  340. this.$api
  341. .bankExamExamList({
  342. chapterExamId: id,
  343. goodsId:this.id
  344. })
  345. .then(res => {
  346. this.$set(this.bankList[index1].list[index2], 'showList', true);
  347. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  348. });
  349. } else if (type == 2) {
  350. if (this.bankList[index1].list) {
  351. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  352. return;
  353. }
  354. this.$api
  355. .bankExamExamList({
  356. chapterExamId: id,
  357. goodsId: this.id
  358. })
  359. .then(res => {
  360. this.$set(this.bankList[index1], 'showList', true);
  361. this.$set(this.bankList[index1], 'list', res.data.data);
  362. });
  363. }
  364. }
  365. }
  366. };
  367. </script>
  368. <style>
  369. page {
  370. background-color: #eaeef1;
  371. }
  372. </style>
  373. <style lang="scss" scope>
  374. .top {
  375. padding: 16rpx 16rpx 0;
  376. display: flex;
  377. justify-content: space-between;
  378. .left {
  379. width: 326rpx;
  380. height: 180rpx;
  381. background: #ffffff;
  382. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  383. border-radius: 16rpx;
  384. background: #fff;
  385. padding: 20rpx;
  386. .title {
  387. font-size: 24rpx;
  388. line-height: 24rpx;
  389. color: #333333;
  390. }
  391. .progress {
  392. margin-top: 10rpx;
  393. display: flex;
  394. .item-left {
  395. flex: 1;
  396. border-right: 1rpx solid #eeeeee;
  397. .desc {
  398. text {
  399. line-height: 24rpx;
  400. font-size: 24rpx;
  401. color: #999999;
  402. }
  403. }
  404. .percent {
  405. margin-top: 10rpx;
  406. line-height: 64rpx;
  407. font-size: 64rpx;
  408. font-weight: bold;
  409. color: #007aff;
  410. }
  411. .per {
  412. font-size: 30rpx;
  413. color: #007aff;
  414. }
  415. }
  416. .item-right {
  417. padding-left: 10rpx;
  418. flex: 1;
  419. text {
  420. line-height: 24rpx;
  421. font-size: 24rpx;
  422. color: #999999;
  423. }
  424. .orange {
  425. line-height: 24rpx;
  426. font-size: 24rpx;
  427. font-weight: bold;
  428. color: #ff9500;
  429. }
  430. .down {
  431. margin-top: 40rpx;
  432. }
  433. }
  434. }
  435. }
  436. .right {
  437. width: 180rpx;
  438. height: 180rpx;
  439. background: #ffffff;
  440. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  441. background: #fff;
  442. padding: 20rpx;
  443. border-radius: 16rpx;
  444. .title {
  445. font-size: 24rpx;
  446. line-height: 24rpx;
  447. color: #333333;
  448. }
  449. .number {
  450. font-weight: bold;
  451. text-align: center;
  452. margin-top: 46rpx;
  453. font-size: 64rpx;
  454. line-height: 64rpx;
  455. color: #007aff;
  456. }
  457. }
  458. }
  459. .courseName {
  460. font-size: 30rpx;
  461. color:#666;
  462. white-space: nowrap;
  463. overflow: hidden;
  464. text-overflow: ellipsis;
  465. }
  466. .moduleItem {
  467. height: 80rpx;
  468. color: #333333;
  469. font-size: 32rpx;
  470. line-height: 80rpx;
  471. font-weight: bold;
  472. display: flex;
  473. justify-content: space-between;
  474. }
  475. .icon_up {
  476. width: 32rpx;
  477. height: 32rpx;
  478. }
  479. .title-list {
  480. background: #eaeef1;
  481. padding: 16rpx 16rpx 124rpx;
  482. .content {
  483. .list {
  484. background: #fff;
  485. margin-bottom: 30rpx;
  486. overflow: hidden;
  487. border-radius: 16rpx;
  488. padding: 10rpx 16rpx;
  489. .module {
  490. font-size: 30rpx;
  491. color: #333333;
  492. .icon {
  493. margin-right: 10rpx;
  494. }
  495. }
  496. .section {
  497. font-size: 28rpx;
  498. font-family: PingFang SC;
  499. font-weight: bold;
  500. color: #666;
  501. white-space: nowrap;
  502. overflow: hidden;
  503. text-overflow: ellipsis;
  504. margin: 20rpx 0;
  505. display: flex;
  506. align-items: center;
  507. }
  508. .article {
  509. height: 80rpx;
  510. display: flex;
  511. align-items: center;
  512. font-size: 26rpx;
  513. color: #666666;
  514. border-bottom: 1rpx solid #eeeeee;
  515. display: flex;
  516. .flex_auto {
  517. flex: 1;
  518. }
  519. &:nth-last-of-type(1) {
  520. border: 0;
  521. }
  522. &.active {
  523. color: #007aff;
  524. .btn {
  525. width: 96rpx;
  526. height: 48rpx;
  527. line-height: 48rpx;
  528. text-align: center;
  529. color: #fff;
  530. font-size: 30rpx;
  531. border-radius: 24rpx;
  532. background: #007aff;
  533. margin-left: 36rpx;
  534. border-radius: 24rpx;
  535. }
  536. }
  537. }
  538. }
  539. }
  540. }
  541. </style>