index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <view>
  3. <!--#ifdef APP-PLUS-->
  4. <view class="lz-status_bar">
  5. <view class="lz-top_view"></view>
  6. </view>
  7. <!--#endif-->
  8. <!-- #ifndef MP-WEIXIN -->
  9. <view class="kaoshi-head">
  10. <view class="kaoshi-head-top">
  11. <view class="kaoshi-head-left" @tap="$navigateBack">
  12. <view class="iconfont icon-zuojiantou"></view>
  13. </view>
  14. <view class="kaoshi-head-m">考试记录</view>
  15. </view>
  16. </view>
  17. <!--#endif-->
  18. <view>
  19. <view class="index-content">
  20. <view class="index-tiku">
  21. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  22. :down="downOption" :up="upOption">
  23. <block v-for="(item, index) in list" :key="index">
  24. <view class="index-tiku-box">
  25. <view class="index-tiku-content">
  26. <view class="index-tiku-content-flex">
  27. <view class="index-tiku-content-top">
  28. <view>{{item.exam_name}}</view>
  29. </view>
  30. <view class="pub-orange">{{item.score}}分</view>
  31. </view>
  32. <view class="index-tiku-content-flex">
  33. <view class="index-tiku-content-bottom">
  34. <view class="pub-gray">考试时间:{{item.up_time}}</view>
  35. </view>
  36. <view class="record-type" v-if="item.type == 2">模拟考试</view>
  37. <view class="record-type" v-if="item.type == 1">正式考试</view>
  38. </view>
  39. </view>
  40. <view class="index-tiku-content-b">
  41. <view class="index-tiku-content-flex">
  42. <view class="index-tiku-content-bottom">
  43. <view class="pub-s-gray">排名</view>
  44. <view class="kt-r"
  45. @tap="$openrul('/pages/my/recording/list?exam_id=' + item.exam_id + '&begin_time=' + item.begin_time + '&score=' + item.score)">
  46. 查看排行榜</view>
  47. </view>
  48. <view class="pub-s-gray">第{{item.pm}}名</view>
  49. </view>
  50. </view>
  51. </view>
  52. </block>
  53. </mescroll-body>
  54. </view>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. import {
  61. mapState
  62. } from 'vuex'
  63. import WucTab from '@/components/wuc-tab/wuc-tab.vue';
  64. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  65. export default {
  66. mixins: [MescrollMixin], // 使用mixin
  67. data() {
  68. return {
  69. order_sort: [{
  70. name: '模拟考试',
  71. goods_type: '1'
  72. },
  73. {
  74. name: '正式考试',
  75. goods_type: '2'
  76. }
  77. ],
  78. current_id: '0',
  79. current_index: 0,
  80. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  81. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  82. downOption: {
  83. use: true, // 是否启用下拉刷新; 默认true
  84. auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
  85. native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
  86. },
  87. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  88. upOption: {
  89. page: {
  90. num: 0,
  91. size: 10 // 每页数据的数量,默认10
  92. },
  93. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  94. empty: {
  95. tip: '暂无相关数据'
  96. }
  97. },
  98. // 列表数据
  99. list: [],
  100. }
  101. },
  102. onShow() {},
  103. mounted() {
  104. },
  105. computed: {
  106. ...mapState(['subject']),
  107. },
  108. components: {
  109. WucTab
  110. },
  111. methods: {
  112. async upCallback(page) {
  113. let pageNum = page.num; // 页码, 默认从1开始
  114. let pageSize = page.size; // 页长, 默认每页10条
  115. let res = await this.$myHttp.post({
  116. url: this.$myHttp.urlMap.record,
  117. data: {
  118. subject_id: this.subject.id,
  119. page: pageNum,
  120. limit: pageSize
  121. },
  122. needLogin: true
  123. })
  124. if (res.code == 1) {
  125. // 接口返回的当前页数据列表 (数组)
  126. let curPageData = res.data.data;
  127. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  128. let curPageLen = curPageData.length;
  129. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  130. // let totalPage = data.xxx;
  131. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  132. let totalSize = res.data.total;
  133. for (let index in curPageData) {
  134. curPageData[index].up_time = this.$myUtils.$common.formatDate(
  135. curPageData[index].up_time * 1000,
  136. "Y年M月D日 h:m:s"
  137. );
  138. }
  139. this.mescroll.endBySize(curPageLen, totalSize);
  140. if (page.num == 1) this.list = []; //如果是第一页需手动置空列表
  141. this.list = this.list.concat(curPageData); //追加新数据
  142. } else {
  143. this.mescroll.endErr()
  144. }
  145. // 此处仍可以继续写其他接口请求...
  146. // 调用其他方法...
  147. },
  148. }
  149. }
  150. </script>
  151. <style>
  152. page {
  153. background: #f6f6f6;
  154. }
  155. .index-tiku {
  156. width: 98%;
  157. margin: 0 auto;
  158. }
  159. .index-tiku-title {
  160. width: 92%;
  161. margin: 0 auto;
  162. padding: 15px 0 8px 0;
  163. font-weight: bold;
  164. font-size: 18px;
  165. }
  166. .index-tiku-box{
  167. background: #fff;
  168. margin: 14px 8px;
  169. border-radius: 10px;
  170. box-shadow: 2px 4px 10px rgb(0 0 0 / 8%);
  171. }
  172. .index-tiku-content {
  173. width: 92%;
  174. margin: 0 auto;
  175. display: flex;
  176. flex-direction: column;
  177. font-size: 16px;
  178. padding: 14px 0;
  179. border-bottom: solid 1px #f5f5f5;
  180. }
  181. .index-tiku-content-flex {
  182. width: 100%;
  183. display: flex;
  184. justify-content: space-between;
  185. align-items: center;
  186. }
  187. .index-tiku-content .index-tiku-content-flex:first-child {
  188. padding-bottom: 6px;
  189. }
  190. .index-tiku-content .index-tiku-content-flex:last-child {
  191. font-size: 14px;
  192. }
  193. .index-tiku-content-top {
  194. display: flex;
  195. align-items: center;
  196. }
  197. .index-tiku-content-top img {
  198. width: 20px;
  199. height: 22px;
  200. margin-right: 10px;
  201. }
  202. .index-tiku-content-bottom {
  203. display: flex;
  204. align-items: center;
  205. font-size: 12px;
  206. }
  207. .icon-jiantou8 {
  208. color: #a5a5a5;
  209. font-size: 15px;
  210. }
  211. .index-tiku-content-b {
  212. width: 100%;
  213. font-size: 14px;
  214. }
  215. .index-tiku-content-b .index-tiku-content-flex {
  216. padding: 12px 0;
  217. width: 92%;
  218. line-height: 17px;
  219. margin: 0 auto;
  220. }
  221. .index-tiku-content-b-border {
  222. border-bottom: solid 14px #efeff4;
  223. }
  224. .kt-r {
  225. border: solid 1px #fd850a;
  226. color: #fd850a;
  227. font-size: 12px;
  228. padding:4px 9px;
  229. border-radius: 4px;
  230. margin-left: 10px;
  231. }
  232. .record-type {
  233. background: #ececec;
  234. color: #3c7bfc;
  235. padding: 5px 12px;
  236. font-size: 12px;
  237. margin-left: 8px;
  238. border-radius: 14px 14px 14px 0;
  239. }
  240. </style>