grade.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <view>
  3. <view class="solids-bottom padding-xs flex align-center">
  4. <view class="flex-sub text-left">
  5. <view class="solid-bottom text-sm padding">
  6. <text class="text-grey">* 可点击记录进行其他操作</text>
  7. </view>
  8. </view>
  9. </view>
  10. <view class="grade-list">
  11. <view class="grade-card" v-for="(item, index) in list" :key="index" @click="clickGrade(item)">
  12. <tui-card :title="{text: item.paper ? item.paper.title : '-', size: 30, color: '#7A7A7A'}" :tag="{text: item.cate ? item.cate.name : '-', size: 24}">
  13. <template v-slot:body>
  14. <view class="m-lr-20 grade-content text-sm">
  15. <view class="grid m-t-20">
  16. <view class="" style="width: 45%;">总分数:{{item.total_score}}分</view>
  17. <view>得分数:{{item.score}}分</view>
  18. </view>
  19. <view class="grid">
  20. <view style="width: 45%;">答对数:{{item.right_count}}题</view>
  21. <view>答错数:{{item.error_count}}题</view>
  22. </view>
  23. <view class="m-t-20" :class="is_pass ? ['text-green'] : ['text-red']">{{item.is_pass ? '及格' : '未及格'}}</view>
  24. </view>
  25. </template>
  26. <template v-slot:footer>
  27. <view class="grade-time">
  28. <view class="grade-time-item" style="width: 69%;">
  29. 时间:{{item.createtime|format_date}}
  30. </view>
  31. <view class="grade-time-item">
  32. 用时:{{item.grade_time|format_second}}
  33. </view>
  34. </view>
  35. </template>
  36. </tui-card>
  37. </view>
  38. <!-- 加载状态条 -->
  39. <view class="cu-load bg-grey" :class="loadFlag" v-show="has_more || loadFlag == 'over'"></view>
  40. </view>
  41. <tui-loading v-if="showLoading"></tui-loading>
  42. <tui-no-data imgUrl="/static/img/img_noorder_3x.png" v-if="showNodata">暂无数据</tui-no-data>
  43. <login ref="login" v-on:succ="getList"></login>
  44. <!-- 操作菜单 -->
  45. <tn-action-sheet
  46. v-model="showAction"
  47. :tips="tipsAction"
  48. :list="listAction"
  49. :borderRadius="23"
  50. :cancelBtn="true"
  51. :maskCloseable="true"
  52. @click="clickActionSheetItem"
  53. @close="closedActionSheet"
  54. >
  55. </tn-action-sheet>
  56. </view>
  57. </template>
  58. <script>
  59. export default {
  60. data() {
  61. return {
  62. showLoading: false,
  63. showNodata: true,
  64. keyword: '',
  65. list: [],
  66. loadFlag: 'loading',
  67. current_page: 1,
  68. has_more: false,
  69. gradeItem: null,
  70. // sheet action
  71. showAction: false,
  72. tipsAction: '',
  73. listAction: [],
  74. }
  75. },
  76. onLoad(e) {
  77. this.getList()
  78. },
  79. async onReachBottom() {
  80. console.log("onReachBottom")
  81. if (this.has_more) {
  82. this.current_page++
  83. this.getList()
  84. }
  85. },
  86. methods: {
  87. // 获取记录
  88. getList() {
  89. this.loadFlag = 'loading'
  90. this.has_more = true
  91. this.http('grade/index', {keyword: this.keyword, page:this.current_page}, 'post').then(res => {
  92. console.log('grade res', res)
  93. if (res.code == 0) {
  94. uni.showToast({
  95. title: res.msg,
  96. icon: 'none'
  97. })
  98. return
  99. } else {
  100. this.list = this.list.concat(res.data.list.data)
  101. this.current_page = res.data.list.current_page
  102. this.has_more = res.data.list.has_more
  103. this.loadFlag = !this.has_more ? 'over' : ''
  104. this.showNodata = !this.list.length
  105. }
  106. })
  107. },
  108. // 查看排行榜
  109. showRank(paper_id) {
  110. console.log('paper_id', paper_id)
  111. this.utils.goto('rank?paper_id=' + paper_id)
  112. },
  113. // 点击成绩
  114. clickGrade(item) {
  115. console.log('grade item', item)
  116. this.gradeItem = item
  117. this.tipsAction = {text: item.paper?.title}
  118. let listAction = [
  119. {text: '查看排行榜'}
  120. ]
  121. if (item.error_ids) {
  122. listAction.unshift({text: '查看错题'})
  123. }
  124. this.listAction = listAction
  125. this.showAction = true
  126. },
  127. // 点击菜单选项
  128. clickActionSheetItem(index) {
  129. let item = this.listAction[index]
  130. switch (item.text) {
  131. case '查看排行榜':
  132. this.showRank(this.gradeItem.paper_id)
  133. break
  134. case '查看错题':
  135. this.utils.goto('/pages/wrong/index?question_ids=' + this.gradeItem.error_ids)
  136. break
  137. }
  138. this.closedActionSheet()
  139. },
  140. // 关闭actionSheet
  141. closedActionSheet() {
  142. this.show = false
  143. }
  144. }
  145. }
  146. </script>
  147. <style>
  148. .grade-list {
  149. padding-bottom: 20rpx;
  150. }
  151. .grade-card {
  152. margin: 20rpx 0;
  153. }
  154. .options {
  155. margin: 20rpx 0;
  156. line-height: 50rpx;
  157. }
  158. .grade-time {
  159. margin: 20rpx 0;
  160. padding: 0rpx 15rpx;
  161. display: flex;
  162. flex-wrap: wrap;
  163. justify-content: center;
  164. }
  165. .grade-content {
  166. }
  167. </style>