question_detail.vue 18 KB

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