question_detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  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. clearInterval(this.timer)
  134. this.$api.lockDelLock({
  135. action:'bank'
  136. }).then(res => {
  137. })
  138. },
  139. computed: { ...mapGetters(['userInfo']) },
  140. onLoad(option) {
  141. this.orderGoodsId = option.orderGoodsId
  142. this.id = option.id;
  143. this.getDetail();
  144. this.getLock()
  145. this.timer = setInterval(this.getLock,10000)
  146. // this.goodsBankList();
  147. // this.getCollectNum();
  148. // this.getWrongNum()
  149. },
  150. onShow() {
  151. this.goodsBankQuestionNum();
  152. this.goodsBank();
  153. },
  154. methods: {
  155. getLock() {
  156. this.$api.lockLockAction({
  157. action:'bank'
  158. }).then(res => {
  159. })
  160. },
  161. /**
  162. * 继续做题
  163. */
  164. continueDo(recordId,examId,goodsId,chapterId = 0,moduleId = 0) {
  165. uni.navigateTo({
  166. url:'/pages2/bank/questionBankContinue?orderGoodsId='+this.orderGoodsId+'&recordId=' +recordId +'&id=' +examId +'&goodsid=' +goodsId +'&chapterId='+chapterId+'&moduleId='+moduleId
  167. })
  168. },
  169. /**
  170. * 重做
  171. * @param {Object} recordId
  172. * @param {Object} examId
  173. * @param {Object} goodsId
  174. * @param {Object} chapterExamId
  175. */
  176. async doRepeat(recordId,examId,goodsId,chapterExamId=0,moduleId=0) {
  177. let count = await this.examRecordCount(examId);
  178. let answerNum = await this.getExamDetail(examId);
  179. //超过答题次数
  180. if (answerNum > 0 && count >= answerNum) {
  181. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  182. return;
  183. }
  184. uni.showModal({
  185. title: '提示',
  186. content: '是否清空答案重做?',
  187. cancelText:'查看上次',
  188. cancelColor:'',
  189. confirmText:'重做',
  190. confirmColor:'',
  191. success: (res) => {
  192. if (res.confirm) {
  193. uni.navigateTo({
  194. url:'/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' +examId +'&goodsid=' +goodsId +'&moduleId='+moduleId+'&chapterId=' +chapterExamId
  195. })
  196. } else if (res.cancel) {
  197. uni.navigateTo({
  198. url:'/pages2/bank/questionBankAllExplain?id=' + examId +
  199. '&goodsid=' + goodsId +
  200. '&moduleId=' + moduleId +
  201. '&chapterId=' + chapterExamId +
  202. '&recordId='+ recordId+
  203. '&orderGoodsId='+this.orderGoodsId
  204. })
  205. console.log('查看上次答题');
  206. }
  207. }
  208. });
  209. },
  210. /**
  211. * 获取课程目录
  212. */
  213. goodsBank() {
  214. this.$api.goodsBank({
  215. orderGoodsId:this.orderGoodsId,
  216. goodsId: this.id
  217. }).then(res => {
  218. this.bankList = res.data.data;
  219. if(this.firstEnter) {
  220. this.showAllCharpter();
  221. this.firstEnter = false;
  222. }
  223. });
  224. },
  225. /**
  226. * 展示第一个章下的节内容
  227. */
  228. showAllCharpter() {
  229. for(let i = 0; i < this.bankList.length; i++) {
  230. if(this.bankList[i].type == 1) { //第一个是模块直接展开,再展开章下面的节
  231. this.$api
  232. .goodsChapterList({
  233. moduleExamId: this.bankList[i].majorId
  234. })
  235. .then(res => {
  236. this.$set(this.bankList[i], 'showList', true);
  237. this.$set(this.bankList[i], 'list', res.data.data);
  238. if(this.bankList[i].list.length) {
  239. this.changeItem(i,this.bankList[i].list[0].chapterExamId,this.bankList[i].type,0,this.bankList[i].majorId)
  240. }
  241. });
  242. break;
  243. } else if(this.bankList[i].type == 2) { //第一个章展开下面的节
  244. this.changeItem(i,this.bankList[i].majorId,this.bankList[i].type,'',0)
  245. break;
  246. }
  247. }
  248. },
  249. getDetail() {
  250. this.$api.commonGoodsDetail(this.id).then(res => {
  251. console.log(res);
  252. this.goodsData = res.data.data;
  253. });
  254. },
  255. /**
  256. * 去做题
  257. */
  258. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  259. console.log(id,goodsId,moduleId,chapterId)
  260. let count = await this.examRecordCount(id);
  261. let answerNum = await this.getExamDetail(id);
  262. //超过答题次数
  263. if (answerNum > 0 && count >= answerNum) {
  264. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  265. return;
  266. }
  267. uni.navigateTo({
  268. url: '/pages2/bank/questionBank?orderGoodsId='+this.orderGoodsId+'&id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  269. });
  270. },
  271. /**
  272. * 查询试卷历史做题次数
  273. */
  274. examRecordCount(examId) {
  275. return new Promise(resolve => {
  276. this.$api
  277. .examRecordCount({
  278. examId: examId,
  279. orderGoodsId: this.orderGoodsId
  280. })
  281. .then(res => {
  282. resolve(res.data.data);
  283. });
  284. });
  285. },
  286. /**
  287. * @param {Object} exam_id
  288. * 获取试卷可以做的次数
  289. */
  290. getExamDetail(exam_id) {
  291. return new Promise(resolve => {
  292. this.$api.getExamDetail(exam_id).then(res => {
  293. resolve(res.data.data.answerNum);
  294. });
  295. });
  296. },
  297. /**
  298. * 获取用户商品统计数据
  299. */
  300. goodsBankQuestionNum() {
  301. this.$api.goodsBankQuestionNum(this.orderGoodsId).then(res => {
  302. this.goodsCount = res.data.data;
  303. });
  304. },
  305. goodsBankList() {
  306. this.$api
  307. .goodsBankList({
  308. goodsId: this.id
  309. })
  310. .then(res => {
  311. console.log(res);
  312. this.bankList = res.data.data;
  313. });
  314. },
  315. getCollectNum() {
  316. this.$api
  317. .goodsCollectExamList({
  318. orderGoodsId: this.orderGoodsId
  319. })
  320. .then(res => {
  321. let total = 0;
  322. res.data.rows.forEach(item => {
  323. total += item.questionNum;
  324. });
  325. this.collectTotal = total;
  326. });
  327. },
  328. getWrongNum() {
  329. this.$api
  330. .wrongRecordList({
  331. orderGoodsId: this.orderGoodsId
  332. })
  333. .then(res => {
  334. let total = 0;
  335. res.data.rows.forEach(item => {
  336. total += item.wrongQuestionNum;
  337. });
  338. this.wrongTotal = total;
  339. });
  340. },
  341. clickModule(id, index) {
  342. if (this.bankList[index].list) {
  343. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  344. return;
  345. }
  346. this.$api
  347. .goodsChapterList({
  348. moduleExamId: id,
  349. orderGoodsId: this.orderGoodsId,
  350. goodsId: this.id
  351. })
  352. .then(res => {
  353. this.$set(this.bankList[index], 'showList', true);
  354. this.$set(this.bankList[index], 'list', res.data.data);
  355. });
  356. },
  357. changeItem(index1, id, type, index2,moduleExamId) {
  358. if (type == 1) {
  359. if (this.bankList[index1].list[index2].list) {
  360. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  361. return;
  362. }
  363. this.$api
  364. .bankExamExamList({
  365. moduleExamId:moduleExamId,
  366. orderGoodsId: this.orderGoodsId,
  367. chapterExamId: id,
  368. goodsId: this.id
  369. })
  370. .then(res => {
  371. this.$set(this.bankList[index1].list[index2], 'showList', true);
  372. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  373. });
  374. } else if (type == 2) {
  375. if (this.bankList[index1].list) {
  376. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  377. return;
  378. }
  379. this.$api
  380. .bankExamExamList({
  381. moduleExamId:moduleExamId,
  382. orderGoodsId: this.orderGoodsId,
  383. chapterExamId: id,
  384. goodsId: this.id
  385. })
  386. .then(res => {
  387. this.$set(this.bankList[index1], 'showList', true);
  388. this.$set(this.bankList[index1], 'list', res.data.data);
  389. });
  390. }
  391. }
  392. }
  393. };
  394. </script>
  395. <style>
  396. page {
  397. background-color: #eaeef1;
  398. }
  399. </style>
  400. <style lang="scss" scope>
  401. .top {
  402. padding: 16rpx 16rpx 0;
  403. display: flex;
  404. justify-content: space-between;
  405. .left {
  406. width: 326rpx;
  407. height: 180rpx;
  408. background: #ffffff;
  409. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  410. border-radius: 16rpx;
  411. background: #fff;
  412. padding: 20rpx;
  413. .title {
  414. font-size: 24rpx;
  415. line-height: 24rpx;
  416. color: #333333;
  417. }
  418. .progress {
  419. margin-top: 10rpx;
  420. display: flex;
  421. .item-left {
  422. flex: 1;
  423. border-right: 1rpx solid #eeeeee;
  424. .desc {
  425. text {
  426. line-height: 24rpx;
  427. font-size: 24rpx;
  428. color: #999999;
  429. }
  430. }
  431. .percent {
  432. margin-top: 10rpx;
  433. line-height: 64rpx;
  434. font-size: 64rpx;
  435. font-weight: bold;
  436. color: #007aff;
  437. }
  438. .per {
  439. font-size: 30rpx;
  440. color: #007aff;
  441. }
  442. }
  443. .item-right {
  444. padding-left: 10rpx;
  445. flex: 1;
  446. text {
  447. line-height: 24rpx;
  448. font-size: 24rpx;
  449. color: #999999;
  450. }
  451. .orange {
  452. line-height: 24rpx;
  453. font-size: 24rpx;
  454. font-weight: bold;
  455. color: #ff9500;
  456. }
  457. .down {
  458. margin-top: 40rpx;
  459. }
  460. }
  461. }
  462. }
  463. .right {
  464. width: 180rpx;
  465. height: 180rpx;
  466. background: #ffffff;
  467. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  468. background: #fff;
  469. padding: 20rpx;
  470. border-radius: 16rpx;
  471. .title {
  472. font-size: 24rpx;
  473. line-height: 24rpx;
  474. color: #333333;
  475. }
  476. .number {
  477. font-weight: bold;
  478. text-align: center;
  479. margin-top: 46rpx;
  480. font-size: 64rpx;
  481. line-height: 64rpx;
  482. color: #007aff;
  483. }
  484. }
  485. }
  486. .courseName {
  487. font-size: 24rpx;
  488. color:#333;
  489. white-space: nowrap;
  490. overflow: hidden;
  491. text-overflow: ellipsis;
  492. }
  493. .moduleItem {
  494. height: 80rpx;
  495. color: #333333;
  496. font-size: 24rpx;
  497. line-height: 80rpx;
  498. font-weight: bold;
  499. display: flex;
  500. justify-content: space-between;
  501. border-bottom: 1rpx solid #eee;
  502. }
  503. .icon_up {
  504. width: 32rpx;
  505. height: 32rpx;
  506. }
  507. .title-list {
  508. background: #eaeef1;
  509. padding: 16rpx 16rpx 124rpx;
  510. .content {
  511. .list {
  512. background: #fff;
  513. margin-bottom: 30rpx;
  514. overflow: hidden;
  515. border-radius: 16rpx;
  516. padding: 10rpx 16rpx;
  517. .module {
  518. font-size: 30rpx;
  519. color: #333333;
  520. .icon {
  521. margin-right: 10rpx;
  522. }
  523. }
  524. .section {
  525. font-size: 24rpx;
  526. font-family: PingFang SC;
  527. font-weight: bold;
  528. color: #333;
  529. white-space: nowrap;
  530. overflow: hidden;
  531. text-overflow: ellipsis;
  532. padding: 20rpx 0;
  533. display: flex;
  534. align-items: center;
  535. border-bottom: 1rpx solid #eee;
  536. }
  537. .article {
  538. height: 80rpx;
  539. display: flex;
  540. align-items: center;
  541. font-size: 30rpx;
  542. color: #666666;
  543. border-bottom: 1rpx solid #eeeeee;
  544. display: flex;
  545. .flex_auto {
  546. flex: 1;
  547. }
  548. &:nth-last-of-type(1) {
  549. border: 0;
  550. }
  551. &.active {
  552. color: #007aff;
  553. .btn {
  554. width: 96rpx;
  555. height: 48rpx;
  556. line-height: 48rpx;
  557. text-align: center;
  558. color: #fff;
  559. font-size: 30rpx;
  560. border-radius: 24rpx;
  561. background: #007aff;
  562. margin-left: 36rpx;
  563. border-radius: 24rpx;
  564. &.disabled {
  565. opacity: 0.6;
  566. }
  567. }
  568. }
  569. }
  570. }
  571. }
  572. }
  573. </style>