question_detail.vue 16 KB

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