question_detail.vue 11 KB

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