question_detail.vue 10 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">
  10. <text>总进度</text>
  11. </view>
  12. <view class="percent">
  13. {{goodsCount.totalNum>0?(goodsCount.doNum/goodsCount.totalNum * 100):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. if(this.goodsData.examConfigList) {
  141. let count = await this.examRecordCount(id);
  142. //超过答题次数
  143. if(count >= this.goodsData.examConfigList) {
  144. uni.showToast({
  145. title:'该试卷只能答题'+this.goodsData.examConfigList+'次!'
  146. })
  147. return
  148. }
  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.examRecordCount({
  160. examId:examId,
  161. goodsId:this.id
  162. }).then(res => {
  163. resolve(res.data.data)
  164. })
  165. })
  166. },
  167. /**
  168. * 获取用户商品统计数据
  169. */
  170. goodsBankQuestionNum(){
  171. this.$api.goodsBankQuestionNum(this.id).then(res => {
  172. this.goodsCount = res.data.data
  173. })
  174. },
  175. goodsBankList() {
  176. this.$api.goodsBankList({
  177. goodsId:this.id
  178. }).then(res => {
  179. console.log(res)
  180. this.bankList = res.data.data;
  181. })
  182. },
  183. getCollectNum() {
  184. this.$api.goodsCollectExamList({
  185. goodsId:this.id
  186. }).then(res => {
  187. let total = 0;
  188. res.data.rows.forEach(item => {
  189. total += item.questionNum;
  190. })
  191. this.collectTotal = total
  192. })
  193. },
  194. getWrongNum() {
  195. this.$api.wrongRecordList({
  196. goodsId:this.id
  197. }).then(res => {
  198. let total = 0;
  199. res.data.rows.forEach(item => {
  200. total += item.wrongQuestionNum;
  201. })
  202. this.wrongTotal = total
  203. })
  204. },
  205. clickModule(id,index) {
  206. if(this.bankList[index].list) {
  207. this.$set(this.bankList[index],'showList',!this.bankList[index].showList)
  208. return;
  209. }
  210. this.$api.goodsChapterList({
  211. moduleExamId:id
  212. }).then(res => {
  213. this.$set(this.bankList[index],'showList',true)
  214. this.$set(this.bankList[index],'list',res.data.data)
  215. })
  216. },
  217. changeItem(index1,id,type) {
  218. if(type == 1) {
  219. if(this.bankList[index1].list[index2].list) {
  220. this.$set(this.bankList[index1].list[index2],'showList',!this.bankList[index1].list[index2].showList)
  221. return;
  222. }
  223. this.$api.goodsExamList({
  224. chapterExamId:id
  225. }).then(res => {
  226. this.$set(this.bankList[index1].list[index2],'showList',true)
  227. this.$set(this.bankList[index1].list[index2],'list',res.data.data)
  228. })
  229. } else if(type == 2) {
  230. if(this.bankList[index1].list) {
  231. this.$set(this.bankList[index1],'showList',!this.bankList[index1].showList)
  232. return;
  233. }
  234. this.$api.goodsExamList({
  235. chapterExamId:id
  236. }).then(res => {
  237. this.$set(this.bankList[index1],'showList',true)
  238. this.$set(this.bankList[index1],'list',res.data.data)
  239. })
  240. }
  241. }
  242. }
  243. };
  244. </script>
  245. <style >
  246. page{
  247. background-color: #EAEEF1;
  248. }
  249. </style>
  250. <style lang="scss" scope>
  251. .top {
  252. padding:16rpx 16rpx 0;
  253. display: flex;
  254. justify-content: space-between;
  255. .left {
  256. width: 326rpx;
  257. height: 180rpx;
  258. background: #FFFFFF;
  259. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  260. border-radius: 16rpx;
  261. background:#fff;
  262. padding:20rpx;
  263. .title {
  264. font-size: 24rpx;
  265. line-height: 24rpx;
  266. color: #333333;
  267. }
  268. .progress {
  269. margin-top:10rpx;
  270. display: flex;
  271. .item-left {
  272. flex:1;
  273. border-right:1rpx solid #EEEEEE;
  274. .desc {
  275. text {
  276. line-height: 24rpx;
  277. font-size: 24rpx;
  278. color: #999999;
  279. }
  280. }
  281. .percent {
  282. margin-top:10rpx;
  283. line-height: 64rpx;
  284. font-size: 64rpx;
  285. font-weight: bold;
  286. color: #007AFF;
  287. }
  288. .per {
  289. font-size: 30rpx;
  290. color: #007AFF;
  291. }
  292. }
  293. .item-right {
  294. padding-left:10rpx;
  295. flex:1;
  296. text {
  297. line-height: 24rpx;
  298. font-size: 24rpx;
  299. color: #999999;
  300. }
  301. .orange {
  302. line-height: 24rpx;
  303. font-size: 24rpx;
  304. font-weight: bold;
  305. color: #FF9500;
  306. }
  307. .down {
  308. margin-top:40rpx;
  309. }
  310. }
  311. }
  312. }
  313. .right {
  314. width: 180rpx;
  315. height: 180rpx;
  316. background: #FFFFFF;
  317. box-shadow: 0px 0px 16rpx 4rpx rgba(145, 156, 178, 0.1);
  318. background:#fff;
  319. padding:20rpx;
  320. .title {
  321. font-size: 24rpx;
  322. line-height: 24rpx;
  323. color: #333333;
  324. }
  325. .number {
  326. font-weight: bold;
  327. text-align: center;
  328. margin-top:46rpx;
  329. font-size: 64rpx;
  330. line-height: 64rpx;
  331. color: #007AFF;
  332. }
  333. }
  334. }
  335. .courseName{
  336. white-space:nowrap;
  337. overflow:hidden;
  338. text-overflow:ellipsis;
  339. }
  340. .moduleItem{
  341. height: 80rpx;
  342. color: #333333;
  343. font-size: 32rpx;
  344. line-height: 80rpx;
  345. font-weight: bold;
  346. display: flex;
  347. justify-content: space-between;
  348. }
  349. .icon_up{
  350. width: 32rpx;
  351. height: 32rpx;
  352. }
  353. .title-list {
  354. background: #EAEEF1;
  355. padding:16rpx 16rpx 124rpx;
  356. .content {
  357. .list {
  358. background:#fff;
  359. margin-bottom:30rpx;
  360. overflow: hidden;
  361. border-radius: 16rpx;
  362. padding:10rpx 16rpx;
  363. .module {
  364. font-size: 30rpx;
  365. color: #333333;
  366. .icon {
  367. margin-right:10rpx;
  368. }
  369. }
  370. .section {
  371. font-size: 30rpx;
  372. font-family: PingFang SC;
  373. font-weight: bold;
  374. color: #333333;
  375. white-space:nowrap;
  376. overflow:hidden;
  377. text-overflow:ellipsis;
  378. margin: 20rpx 0;
  379. display: flex;
  380. align-items: center;
  381. }
  382. .article {
  383. height:80rpx;
  384. display: flex;
  385. align-items: center;
  386. font-size: 24rpx;
  387. color: #666666;
  388. border-bottom: 1rpx solid #EEEEEE;
  389. display: flex;
  390. .flex_auto{
  391. flex:1;
  392. }
  393. &:nth-last-of-type(1) {
  394. border:0;
  395. }
  396. &.active {
  397. color:#007AFF;
  398. .btn {
  399. width: 96rpx;
  400. height: 48rpx;
  401. line-height: 48rpx;
  402. text-align: center;
  403. color:#fff;
  404. font-size: 30rpx;
  405. border-radius:24rpx;
  406. background: #007AFF;
  407. margin-left:36rpx;
  408. border-radius: 24rpx;
  409. }
  410. }
  411. }
  412. }
  413. }
  414. }
  415. </style>