question_detail.vue 18 KB

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