question_detail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. <template>
  2. <view>
  3. <view class="top">
  4. <navigator :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 :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 :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)">做题</view>
  75. </view>
  76. </view>
  77. <u-line v-if="item1.length > 1"></u-line>
  78. </view>
  79. </template>
  80. </template>
  81. <template v-if="item1.type == 2">
  82. <view class="section" @click="changeItem(index1, item1.majorId, item1.type)">
  83. <!-- <image src="/static/icon/up1.png" class="icon_up" v-if="!item1.showList"></image>
  84. <image src="/static/icon/down1.png" class="icon_up" v-if="item1.showList"></image> -->
  85. <u-icon name="arrow-up" color="#999" size="24" v-if="item1.showList"></u-icon>
  86. <u-icon name="arrow-down" color="#999" size="24" v-if="!item1.showList"></u-icon>
  87. <text style="margin-left:34rpx;">{{ item1.name }}</text>
  88. </view>
  89. <view v-if="item1.showList">
  90. <view class="article active" style="margin-left:64rpx;" v-for="(article, index2) in item1.list" :key="index2">
  91. <view class="flex_auto">{{ item1.name }}</view>
  92. <view class="btn" @click="toDo(article.examId, goodsData.goodsId, 0, item1.majorId)">做题</view>
  93. </view>
  94. </view>
  95. </template>
  96. <template v-if="item1.type == 3">
  97. <view class="article active">
  98. <view class="flex_auto">{{ item1.name }}</view>
  99. <view class="btn" @click="toDo(item1.majorId, goodsData.goodsId, 0, 0)">做题</view>
  100. </view>
  101. </template>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import { mapGetters } from 'vuex';
  109. export default {
  110. data() {
  111. return {
  112. goodsData: {},
  113. bankList: [],
  114. id: '',
  115. goodsCount: {
  116. totalNum: 0
  117. }
  118. };
  119. },
  120. onUnload() {},
  121. computed: { ...mapGetters(['userInfo']) },
  122. onLoad(option) {
  123. this.id = option.id;
  124. this.getDetail();
  125. this.goodsBankList();
  126. // this.getCollectNum();
  127. // this.getWrongNum()
  128. this.goodsBankQuestionNum();
  129. },
  130. onShow() {},
  131. methods: {
  132. getDetail() {
  133. this.$api.commonGoodsDetail(this.id).then(res => {
  134. console.log(res);
  135. this.goodsData = res.data.data;
  136. });
  137. },
  138. /**
  139. * 去做题
  140. */
  141. async toDo(id, goodsId, moduleId = 0, chapterId = 0) {
  142. console.log(id,goodsId,moduleId,chapterId)
  143. let count = await this.examRecordCount(id);
  144. let answerNum = await this.getExamDetail(id);
  145. //超过答题次数
  146. if (answerNum > 0 && count >= answerNum) {
  147. this.$u.toast('该试卷只能答题' + answerNum + '次!');
  148. return;
  149. }
  150. uni.navigateTo({
  151. url: '/pages2/bank/questionBank?id=' + id + '&goodsid=' + goodsId + '&moduleId=' + moduleId + '&chapterId=' + chapterId + ''
  152. });
  153. },
  154. /**
  155. * 查询试卷历史做题次数
  156. */
  157. examRecordCount(examId) {
  158. return new Promise(resolve => {
  159. this.$api
  160. .examRecordCount({
  161. examId: examId,
  162. goodsId: this.id
  163. })
  164. .then(res => {
  165. resolve(res.data.data);
  166. });
  167. });
  168. },
  169. /**
  170. * @param {Object} exam_id
  171. * 获取试卷可以做的次数
  172. */
  173. getExamDetail(exam_id) {
  174. return new Promise(resolve => {
  175. this.$api.getExamDetail(exam_id).then(res => {
  176. resolve(res.data.data.answerNum);
  177. });
  178. });
  179. },
  180. /**
  181. * 获取用户商品统计数据
  182. */
  183. goodsBankQuestionNum() {
  184. this.$api.goodsBankQuestionNum(this.id).then(res => {
  185. this.goodsCount = res.data.data;
  186. });
  187. },
  188. goodsBankList() {
  189. this.$api
  190. .goodsBankList({
  191. goodsId: this.id
  192. })
  193. .then(res => {
  194. console.log(res);
  195. this.bankList = res.data.data;
  196. });
  197. },
  198. getCollectNum() {
  199. this.$api
  200. .goodsCollectExamList({
  201. goodsId: this.id
  202. })
  203. .then(res => {
  204. let total = 0;
  205. res.data.rows.forEach(item => {
  206. total += item.questionNum;
  207. });
  208. this.collectTotal = total;
  209. });
  210. },
  211. getWrongNum() {
  212. this.$api
  213. .wrongRecordList({
  214. goodsId: this.id
  215. })
  216. .then(res => {
  217. let total = 0;
  218. res.data.rows.forEach(item => {
  219. total += item.wrongQuestionNum;
  220. });
  221. this.wrongTotal = total;
  222. });
  223. },
  224. clickModule(id, index) {
  225. if (this.bankList[index].list) {
  226. this.$set(this.bankList[index], 'showList', !this.bankList[index].showList);
  227. return;
  228. }
  229. this.$api
  230. .goodsChapterList({
  231. moduleExamId: id
  232. })
  233. .then(res => {
  234. this.$set(this.bankList[index], 'showList', true);
  235. this.$set(this.bankList[index], 'list', res.data.data);
  236. });
  237. },
  238. changeItem(index1, id, type, index2) {
  239. if (type == 1) {
  240. console.log();
  241. if (this.bankList[index1].list[index2].list) {
  242. console.log(2);
  243. this.$set(this.bankList[index1].list[index2], 'showList', !this.bankList[index1].list[index2].showList);
  244. return;
  245. }
  246. this.$api
  247. .goodsExamList({
  248. chapterExamId: id
  249. })
  250. .then(res => {
  251. console.log(3);
  252. this.$set(this.bankList[index1].list[index2], 'showList', true);
  253. this.$set(this.bankList[index1].list[index2], 'list', res.data.data);
  254. });
  255. } else if (type == 2) {
  256. if (this.bankList[index1].list) {
  257. this.$set(this.bankList[index1], 'showList', !this.bankList[index1].showList);
  258. return;
  259. }
  260. this.$api
  261. .goodsExamList({
  262. chapterExamId: id
  263. })
  264. .then(res => {
  265. this.$set(this.bankList[index1], 'showList', true);
  266. this.$set(this.bankList[index1], 'list', res.data.data);
  267. });
  268. }
  269. }
  270. }
  271. };
  272. </script>
  273. <style>
  274. page {
  275. background-color: #eaeef1;
  276. }
  277. </style>
  278. <style lang="scss" scope>
  279. .top {
  280. padding: 16rpx 16rpx 0;
  281. display: flex;
  282. justify-content: space-between;
  283. .left {
  284. width: 326rpx;
  285. height: 180rpx;
  286. background: #ffffff;
  287. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  288. border-radius: 16rpx;
  289. background: #fff;
  290. padding: 20rpx;
  291. .title {
  292. font-size: 24rpx;
  293. line-height: 24rpx;
  294. color: #333333;
  295. }
  296. .progress {
  297. margin-top: 10rpx;
  298. display: flex;
  299. .item-left {
  300. flex: 1;
  301. border-right: 1rpx solid #eeeeee;
  302. .desc {
  303. text {
  304. line-height: 24rpx;
  305. font-size: 24rpx;
  306. color: #999999;
  307. }
  308. }
  309. .percent {
  310. margin-top: 10rpx;
  311. line-height: 64rpx;
  312. font-size: 64rpx;
  313. font-weight: bold;
  314. color: #007aff;
  315. }
  316. .per {
  317. font-size: 30rpx;
  318. color: #007aff;
  319. }
  320. }
  321. .item-right {
  322. padding-left: 10rpx;
  323. flex: 1;
  324. text {
  325. line-height: 24rpx;
  326. font-size: 24rpx;
  327. color: #999999;
  328. }
  329. .orange {
  330. line-height: 24rpx;
  331. font-size: 24rpx;
  332. font-weight: bold;
  333. color: #ff9500;
  334. }
  335. .down {
  336. margin-top: 40rpx;
  337. }
  338. }
  339. }
  340. }
  341. .right {
  342. width: 180rpx;
  343. height: 180rpx;
  344. background: #ffffff;
  345. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  346. background: #fff;
  347. padding: 20rpx;
  348. border-radius: 16rpx;
  349. .title {
  350. font-size: 24rpx;
  351. line-height: 24rpx;
  352. color: #333333;
  353. }
  354. .number {
  355. font-weight: bold;
  356. text-align: center;
  357. margin-top: 46rpx;
  358. font-size: 64rpx;
  359. line-height: 64rpx;
  360. color: #007aff;
  361. }
  362. }
  363. }
  364. .courseName {
  365. font-size: 24rpx;
  366. color:#666;
  367. white-space: nowrap;
  368. overflow: hidden;
  369. text-overflow: ellipsis;
  370. }
  371. .moduleItem {
  372. height: 80rpx;
  373. color: #333333;
  374. font-size: 32rpx;
  375. line-height: 80rpx;
  376. font-weight: bold;
  377. display: flex;
  378. justify-content: space-between;
  379. }
  380. .icon_up {
  381. width: 32rpx;
  382. height: 32rpx;
  383. }
  384. .title-list {
  385. background: #eaeef1;
  386. padding: 16rpx 16rpx 124rpx;
  387. .content {
  388. .list {
  389. background: #fff;
  390. margin-bottom: 30rpx;
  391. overflow: hidden;
  392. border-radius: 16rpx;
  393. padding: 10rpx 16rpx;
  394. .module {
  395. font-size: 30rpx;
  396. color: #333333;
  397. .icon {
  398. margin-right: 10rpx;
  399. }
  400. }
  401. .section {
  402. font-size: 24rpx;
  403. font-family: PingFang SC;
  404. font-weight: bold;
  405. color: #666;
  406. white-space: nowrap;
  407. overflow: hidden;
  408. text-overflow: ellipsis;
  409. margin: 20rpx 0;
  410. display: flex;
  411. align-items: center;
  412. }
  413. .article {
  414. height: 80rpx;
  415. display: flex;
  416. align-items: center;
  417. font-size: 24rpx;
  418. color: #666666;
  419. border-bottom: 1rpx solid #eeeeee;
  420. display: flex;
  421. .flex_auto {
  422. flex: 1;
  423. }
  424. &:nth-last-of-type(1) {
  425. border: 0;
  426. }
  427. &.active {
  428. color: #007aff;
  429. .btn {
  430. width: 96rpx;
  431. height: 48rpx;
  432. line-height: 48rpx;
  433. text-align: center;
  434. color: #fff;
  435. font-size: 30rpx;
  436. border-radius: 24rpx;
  437. background: #007aff;
  438. margin-left: 36rpx;
  439. border-radius: 24rpx;
  440. }
  441. }
  442. }
  443. }
  444. }
  445. }
  446. </style>