question_detail.vue 16 KB

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