question_detail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556
  1. <template>
  2. <view>
  3. <view class="top">
  4. <navigator hover-class="none" :url="'/pages2/bank/question_statistics?id=' + id">
  5. <view class="left">
  6. <view class="title">做题统计</view>
  7. <view class="progress">
  8. <view class="item-left">
  9. <view class="desc"><text>总进度</text></view>
  10. <view class="percent">
  11. {{
  12. goodsCount.totalNum > 0
  13. ? ((goodsCount.doNum / goodsCount.totalNum) * 100).toFixed((goodsCount.doNum / goodsCount.totalNum) * 100 == 100 ? 0 : 1)
  14. : 0
  15. }}
  16. <text class="per">%</text>
  17. </view>
  18. </view>
  19. <view class="item-right">
  20. <view class="up">
  21. <text class="orange">已答</text>
  22. <text>/未答</text>
  23. </view>
  24. <view class="down">
  25. <text class="orange">{{ goodsCount.doNum }}</text>
  26. <text>/{{ goodsCount.totalNum - goodsCount.doNum }}</text>
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </navigator>
  32. <navigator hover-class="none" :url="'/pages2/bank/wrongById?goodsid=' + id">
  33. <view class="right">
  34. <view class="title">
  35. 错题集
  36. <u-icon name="arrow-right"></u-icon>
  37. </view>
  38. <view class="number">{{ goodsCount.wrongNum }}</view>
  39. </view>
  40. </navigator>
  41. <navigator hover-class="none" :url="'/pages2/bank/collectById?goodsid=' + id">
  42. <view class="right">
  43. <view class="title">
  44. 收藏集
  45. <u-icon name="arrow-right"></u-icon>
  46. </view>
  47. <view class="number">{{ goodsCount.collectNum }}</view>
  48. </view>
  49. </navigator>
  50. </view>
  51. <view class="title-list">
  52. <view class="content">
  53. <view class="list" v-for="(item1, index1) in bankList" :key="index1">
  54. <template v-if="item1.type == 1">
  55. <view class="moduleItem" @click="clickModule(item1.majorId, index1)">
  56. <view class="courseName">{{ item1.name }}</view>
  57. <view>
  58. <image src="/static/icon/up.png" class="icon_up" v-if="!item1.showList"></image>
  59. <image src="/static/icon/down.png" class="icon_up" v-if="item1.showList"></image>
  60. </view>
  61. </view>
  62. <template v-if="item1.showList">
  63. <view v-for="(item2, index2) in item1.list" :key="index2">
  64. <view class="section" @click="changeItem(index1, item2.chapterExamId, item1.type, index2)">
  65. <image src="/static/icon/up1.png" class="icon_up" v-if="!item2.showList"></image>
  66. <image src="/static/icon/down1.png" class="icon_up" v-if="item2.showList"></image>
  67. <!-- <u-icon name="arrow-up" color="#999" size="24" v-if="item2.showList"></u-icon>
  68. <u-icon name="arrow-down" color="#999" size="24" v-if="!item2.showList"></u-icon> -->
  69. <text style="margin-left:34rpx;">{{ item2.name }}</text>
  70. </view>
  71. <view v-if="item2.showList">
  72. <view class="article active" style="margin-left:62rpx;" v-for="(article, index3) in item2.list" :key="index3">
  73. <view class="flex_auto">{{ article.examName }}</view>
  74. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, item1.majorId, item2.chapterExamId)" v-if="article.recordStatus == -1">做题</view>
  75. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  76. <view class="btn" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item2.chapterExamId, item1.majorId)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  77. </view>
  78. </view>
  79. <u-line v-if="item1.length > 1"></u-line>
  80. </view>
  81. </template>
  82. </template>
  83. <template v-if="item1.type == 2">
  84. <view class="section" @click="changeItem(index1, item1.majorId, item1.type)">
  85. <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  86. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image>
  87. <!-- <u-icon name="arrow-up" color="#999" size="24" v-if="item1.showList"></u-icon>
  88. <u-icon name="arrow-down" color="#999" size="24" v-if="!item1.showList"></u-icon> -->
  89. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  90. </view>
  91. <view v-if="item1.showList">
  92. <view class="article active" style="margin-left:64rpx;" v-for="(article, index2) in item1.list" :key="index2">
  93. <view class="flex_auto">{{ item1.name }}</view>
  94. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == -1">做题</view>
  95. <view class="btn" @click="continueDo(article.recordId,article.examId, goodsData.goodsId, 0, item1.majorId)" v-if="article.recordStatus == 0 && article.doType == 1">继续</view>
  96. <view class="btn" @click="doRepeat(article.recordId,article.examId, goodsData.goodsId, item1.majorId,0)" v-if="article.recordStatus == 1 || (article.recordStatus == 0 && article.doType == 2)">重做</view>
  97. </view>
  98. </view>
  99. </template>
  100. <template v-if="item1.type == 3">
  101. <view class="article active">
  102. <view class="flex_auto">{{ item1.name }}</view>
  103. <view class="btn" @click="toDo(item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == -1">做题</view>
  104. <view class="btn" @click="continueDo(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 0 && item1.doType == 1">继续</view>
  105. <view class="btn" @click="doRepeat(item1.recordId,item1.majorId, goodsData.goodsId, 0, 0)" v-if="item1.recordStatus == 1 || (item1.recordStatus == 0 && item1.doType == 2)">重做</view>
  106. </view>
  107. </template>
  108. </view>
  109. </view>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. import { mapGetters } from 'vuex';
  115. export default {
  116. data() {
  117. return {
  118. goodsData: {},
  119. bankList: [],
  120. id: '',
  121. goodsCount: {
  122. totalNum: 0
  123. }
  124. };
  125. },
  126. onUnload() {},
  127. computed: { ...mapGetters(['userInfo']) },
  128. onLoad(option) {
  129. this.id = option.id;
  130. this.getDetail();
  131. // this.goodsBankList();
  132. // this.getCollectNum();
  133. // this.getWrongNum()
  134. },
  135. onShow() {
  136. this.goodsBankQuestionNum();
  137. this.goodsBank();
  138. },
  139. methods: {
  140. /**
  141. * 继续做题
  142. */
  143. continueDo(recordId,examId,goodsId,chapterId = 0,moduleId = 0) {
  144. uni.navigateTo({
  145. url:'/pages2/bank/questionBankContinue?recordId=' +recordId +'&id=' +examId +'&goodsid=' +goodsId +'&chapterId='+chapterId+'&moduleId='+moduleId
  146. })
  147. },
  148. /**
  149. * 重做
  150. * @param {Object} recordId
  151. * @param {Object} examId
  152. * @param {Object} goodsId
  153. * @param {Object} chapterExamId
  154. */
  155. async doRepeat(recordId,examId,goodsId,chapterExamId=0,moduleId=0) {
  156. let count = await this.examRecordCount(examId);
  157. let answerNum = await this.getExamDetail(examId);
  158. //超过答题次数
  159. if (answerNum > 0 && count >= answerNum) {
  160. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  161. return;
  162. }
  163. uni.showModal({
  164. title: '提示',
  165. content: '是否清空答案重做?',
  166. cancelText:'查看上次',
  167. cancelColor:'',
  168. confirmText:'重做',
  169. confirmColor:'',
  170. success: (res) => {
  171. if (res.confirm) {
  172. uni.navigateTo({
  173. url:'/pages2/bank/questionBank?id=' +examId +'&goodsid=' +goodsId +'&moduleId='+moduleId+'&chapterId=' +chapterExamId
  174. })
  175. } else if (res.cancel) {
  176. uni.navigateTo({
  177. url:'/pages2/bank/questionBankAllExplain?id=' + examId +
  178. '&goodsid=' + goodsId +
  179. '&moduleId=' + moduleId +
  180. '&chapterId=' + chapterExamId +
  181. '&recordId='+ recordId
  182. })
  183. console.log('查看上次答题');
  184. }
  185. }
  186. });
  187. },
  188. /**
  189. * 获取课程目录
  190. */
  191. goodsBank() {
  192. this.$api.goodsBank({
  193. goodsId: this.id
  194. }).then(res => {
  195. this.bankList = res.data.data;
  196. });
  197. },
  198. getDetail() {
  199. this.$api.commonGoodsDetail(this.id).then(res => {
  200. console.log(res);
  201. this.goodsData = res.data.data;
  202. });
  203. },
  204. /**
  205. * 去做题
  206. */
  207. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  208. console.log(id,goodsId,moduleId,chapterId)
  209. let count = await this.examRecordCount(id);
  210. let answerNum = await this.getExamDetail(id);
  211. //超过答题次数
  212. if (answerNum > 0 && count >= answerNum) {
  213. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  214. return;
  215. }
  216. uni.navigateTo({
  217. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  218. });
  219. },
  220. /**
  221. * 查询试卷历史做题次数
  222. */
  223. examRecordCount(examId) {
  224. return new Promise(resolve => {
  225. this.$api
  226. .examRecordCount({
  227. examId: examId,
  228. goodsId: this.id
  229. })
  230. .then(res => {
  231. resolve(res.data.data);
  232. });
  233. });
  234. },
  235. /**
  236. * @param {Object} exam_id
  237. * 获取试卷可以做的次数
  238. */
  239. getExamDetail(exam_id) {
  240. return new Promise(resolve => {
  241. this.$api.getExamDetail(exam_id).then(res => {
  242. resolve(res.data.data.answerNum);
  243. });
  244. });
  245. },
  246. /**
  247. * 获取用户商品统计数据
  248. */
  249. goodsBankQuestionNum() {
  250. this.$api.goodsBankQuestionNum(this.id).then(res => {
  251. this.goodsCount = res.data.data;
  252. });
  253. },
  254. goodsBankList() {
  255. this.$api
  256. .goodsBankList({
  257. goodsId: this.id
  258. })
  259. .then(res => {
  260. console.log(res);
  261. this.bankList = res.data.data;
  262. });
  263. },
  264. getCollectNum() {
  265. this.$api
  266. .goodsCollectExamList({
  267. goodsId: this.id
  268. })
  269. .then(res => {
  270. let total = 0;
  271. res.data.rows.forEach(item => {
  272. total += item.questionNum;
  273. });
  274. this.collectTotal = total;
  275. });
  276. },
  277. getWrongNum() {
  278. this.$api
  279. .wrongRecordList({
  280. goodsId: this.id
  281. })
  282. .then(res => {
  283. let total = 0;
  284. res.data.rows.forEach(item => {
  285. total += item.wrongQuestionNum;
  286. });
  287. this.wrongTotal = total;
  288. });
  289. },
  290. clickModule(id, index) {
  291. if (this.bankList[index].list) {
  292. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  293. return;
  294. }
  295. this.$api
  296. .goodsChapterList({
  297. moduleExamId: id,
  298. goodsId:this.id
  299. })
  300. .then(res => {
  301. this.$set(this.bankList[index], 'showList', true);
  302. this.$set(this.bankList[index], 'list', res.data.data);
  303. });
  304. },
  305. changeItem(index1, id, type, index2) {
  306. if (type == 1) {
  307. if (this.bankList[index1].list[index2].list) {
  308. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  309. return;
  310. }
  311. this.$api
  312. .bankExamExamList({
  313. chapterExamId: id,
  314. goodsId:this.id
  315. })
  316. .then(res => {
  317. this.$set(this.bankList[index1].list[index2], 'showList', true);
  318. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  319. });
  320. } else if (type == 2) {
  321. if (this.bankList[index1].list) {
  322. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  323. return;
  324. }
  325. this.$api
  326. .bankExamExamList({
  327. chapterExamId: id,
  328. goodsId: this.id
  329. })
  330. .then(res => {
  331. this.$set(this.bankList[index1], 'showList', true);
  332. this.$set(this.bankList[index1], 'list', res.data.data);
  333. });
  334. }
  335. }
  336. }
  337. };
  338. </script>
  339. <style>
  340. page {
  341. background-color: #eaeef1;
  342. }
  343. </style>
  344. <style lang="scss" scope>
  345. .top {
  346. padding: 16rpx 16rpx 0;
  347. display: flex;
  348. justify-content: space-between;
  349. .left {
  350. width: 326rpx;
  351. height: 180rpx;
  352. background: #ffffff;
  353. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  354. border-radius: 16rpx;
  355. background: #fff;
  356. padding: 20rpx;
  357. .title {
  358. font-size: 24rpx;
  359. line-height: 24rpx;
  360. color: #333333;
  361. }
  362. .progress {
  363. margin-top: 10rpx;
  364. display: flex;
  365. .item-left {
  366. flex: 1;
  367. border-right: 1rpx solid #eeeeee;
  368. .desc {
  369. text {
  370. line-height: 24rpx;
  371. font-size: 24rpx;
  372. color: #999999;
  373. }
  374. }
  375. .percent {
  376. margin-top: 10rpx;
  377. line-height: 64rpx;
  378. font-size: 64rpx;
  379. font-weight: bold;
  380. color: #007aff;
  381. }
  382. .per {
  383. font-size: 30rpx;
  384. color: #007aff;
  385. }
  386. }
  387. .item-right {
  388. padding-left: 10rpx;
  389. flex: 1;
  390. text {
  391. line-height: 24rpx;
  392. font-size: 24rpx;
  393. color: #999999;
  394. }
  395. .orange {
  396. line-height: 24rpx;
  397. font-size: 24rpx;
  398. font-weight: bold;
  399. color: #ff9500;
  400. }
  401. .down {
  402. margin-top: 40rpx;
  403. }
  404. }
  405. }
  406. }
  407. .right {
  408. width: 180rpx;
  409. height: 180rpx;
  410. background: #ffffff;
  411. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  412. background: #fff;
  413. padding: 20rpx;
  414. border-radius: 16rpx;
  415. .title {
  416. font-size: 24rpx;
  417. line-height: 24rpx;
  418. color: #333333;
  419. }
  420. .number {
  421. font-weight: bold;
  422. text-align: center;
  423. margin-top: 46rpx;
  424. font-size: 64rpx;
  425. line-height: 64rpx;
  426. color: #007aff;
  427. }
  428. }
  429. }
  430. .courseName {
  431. font-size: 24rpx;
  432. color:#666;
  433. white-space: nowrap;
  434. overflow: hidden;
  435. text-overflow: ellipsis;
  436. }
  437. .moduleItem {
  438. height: 80rpx;
  439. color: #333333;
  440. font-size: 32rpx;
  441. line-height: 80rpx;
  442. font-weight: bold;
  443. display: flex;
  444. justify-content: space-between;
  445. }
  446. .icon_up {
  447. width: 32rpx;
  448. height: 32rpx;
  449. }
  450. .title-list {
  451. background: #eaeef1;
  452. padding: 16rpx 16rpx 124rpx;
  453. .content {
  454. .list {
  455. background: #fff;
  456. margin-bottom: 30rpx;
  457. overflow: hidden;
  458. border-radius: 16rpx;
  459. padding: 10rpx 16rpx;
  460. .module {
  461. font-size: 30rpx;
  462. color: #333333;
  463. .icon {
  464. margin-right: 10rpx;
  465. }
  466. }
  467. .section {
  468. font-size: 24rpx;
  469. font-family: PingFang SC;
  470. font-weight: bold;
  471. color: #666;
  472. white-space: nowrap;
  473. overflow: hidden;
  474. text-overflow: ellipsis;
  475. margin: 20rpx 0;
  476. display: flex;
  477. align-items: center;
  478. }
  479. .article {
  480. height: 80rpx;
  481. display: flex;
  482. align-items: center;
  483. font-size: 24rpx;
  484. color: #666666;
  485. border-bottom: 1rpx solid #eeeeee;
  486. display: flex;
  487. .flex_auto {
  488. flex: 1;
  489. }
  490. &:nth-last-of-type(1) {
  491. border: 0;
  492. }
  493. &.active {
  494. color: #007aff;
  495. .btn {
  496. width: 96rpx;
  497. height: 48rpx;
  498. line-height: 48rpx;
  499. text-align: center;
  500. color: #fff;
  501. font-size: 30rpx;
  502. border-radius: 24rpx;
  503. background: #007aff;
  504. margin-left: 36rpx;
  505. border-radius: 24rpx;
  506. }
  507. }
  508. }
  509. }
  510. }
  511. }
  512. </style>