grade.vue 4.8 KB

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