question_detail.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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,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. 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,this.bankList[i].majorId)
  219. });
  220. break;
  221. } else if(this.bankList[i].type == 2) { //第一个章展开下面的节
  222. this.changeItem(i,this.bankList[i].majorId,this.bankList[i].type,'',0)
  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,moduleExamId) {
  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. moduleExamId:moduleExamId,
  343. chapterExamId: id,
  344. goodsId:this.id
  345. })
  346. .then(res => {
  347. this.$set(this.bankList[index1].list[index2], 'showList', true);
  348. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  349. });
  350. } else if (type == 2) {
  351. if (this.bankList[index1].list) {
  352. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  353. return;
  354. }
  355. this.$api
  356. .bankExamExamList({
  357. moduleExamId:moduleExamId,
  358. chapterExamId: id,
  359. goodsId: this.id
  360. })
  361. .then(res => {
  362. this.$set(this.bankList[index1], 'showList', true);
  363. this.$set(this.bankList[index1], 'list', res.data.data);
  364. });
  365. }
  366. }
  367. }
  368. };
  369. </script>
  370. <style>
  371. page {
  372. background-color: #eaeef1;
  373. }
  374. </style>
  375. <style lang="scss" scope>
  376. .top {
  377. padding: 16rpx 16rpx 0;
  378. display: flex;
  379. justify-content: space-between;
  380. .left {
  381. width: 326rpx;
  382. height: 180rpx;
  383. background: #ffffff;
  384. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  385. border-radius: 16rpx;
  386. background: #fff;
  387. padding: 20rpx;
  388. .title {
  389. font-size: 24rpx;
  390. line-height: 24rpx;
  391. color: #333333;
  392. }
  393. .progress {
  394. margin-top: 10rpx;
  395. display: flex;
  396. .item-left {
  397. flex: 1;
  398. border-right: 1rpx solid #eeeeee;
  399. .desc {
  400. text {
  401. line-height: 24rpx;
  402. font-size: 24rpx;
  403. color: #999999;
  404. }
  405. }
  406. .percent {
  407. margin-top: 10rpx;
  408. line-height: 64rpx;
  409. font-size: 64rpx;
  410. font-weight: bold;
  411. color: #007aff;
  412. }
  413. .per {
  414. font-size: 30rpx;
  415. color: #007aff;
  416. }
  417. }
  418. .item-right {
  419. padding-left: 10rpx;
  420. flex: 1;
  421. text {
  422. line-height: 24rpx;
  423. font-size: 24rpx;
  424. color: #999999;
  425. }
  426. .orange {
  427. line-height: 24rpx;
  428. font-size: 24rpx;
  429. font-weight: bold;
  430. color: #ff9500;
  431. }
  432. .down {
  433. margin-top: 40rpx;
  434. }
  435. }
  436. }
  437. }
  438. .right {
  439. width: 180rpx;
  440. height: 180rpx;
  441. background: #ffffff;
  442. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  443. background: #fff;
  444. padding: 20rpx;
  445. border-radius: 16rpx;
  446. .title {
  447. font-size: 24rpx;
  448. line-height: 24rpx;
  449. color: #333333;
  450. }
  451. .number {
  452. font-weight: bold;
  453. text-align: center;
  454. margin-top: 46rpx;
  455. font-size: 64rpx;
  456. line-height: 64rpx;
  457. color: #007aff;
  458. }
  459. }
  460. }
  461. .courseName {
  462. font-size: 30rpx;
  463. color:#666;
  464. white-space: nowrap;
  465. overflow: hidden;
  466. text-overflow: ellipsis;
  467. }
  468. .moduleItem {
  469. height: 80rpx;
  470. color: #333333;
  471. font-size: 32rpx;
  472. line-height: 80rpx;
  473. font-weight: bold;
  474. display: flex;
  475. justify-content: space-between;
  476. }
  477. .icon_up {
  478. width: 32rpx;
  479. height: 32rpx;
  480. }
  481. .title-list {
  482. background: #eaeef1;
  483. padding: 16rpx 16rpx 124rpx;
  484. .content {
  485. .list {
  486. background: #fff;
  487. margin-bottom: 30rpx;
  488. overflow: hidden;
  489. border-radius: 16rpx;
  490. padding: 10rpx 16rpx;
  491. .module {
  492. font-size: 30rpx;
  493. color: #333333;
  494. .icon {
  495. margin-right: 10rpx;
  496. }
  497. }
  498. .section {
  499. font-size: 28rpx;
  500. font-family: PingFang SC;
  501. font-weight: bold;
  502. color: #666;
  503. white-space: nowrap;
  504. overflow: hidden;
  505. text-overflow: ellipsis;
  506. margin: 20rpx 0;
  507. display: flex;
  508. align-items: center;
  509. }
  510. .article {
  511. height: 80rpx;
  512. display: flex;
  513. align-items: center;
  514. font-size: 28rpx;
  515. color: #666666;
  516. border-bottom: 1rpx solid #eeeeee;
  517. display: flex;
  518. .flex_auto {
  519. flex: 1;
  520. }
  521. &:nth-last-of-type(1) {
  522. border: 0;
  523. }
  524. &.active {
  525. color: #007aff;
  526. .btn {
  527. width: 96rpx;
  528. height: 48rpx;
  529. line-height: 48rpx;
  530. text-align: center;
  531. color: #fff;
  532. font-size: 30rpx;
  533. border-radius: 24rpx;
  534. background: #007aff;
  535. margin-left: 36rpx;
  536. border-radius: 24rpx;
  537. &.disabled {
  538. opacity: 0.6;
  539. }
  540. }
  541. }
  542. }
  543. }
  544. }
  545. }
  546. </style>