index.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 class="white-background">
  19. <wuc-tab :tab-list="order_sort" :tabCur="current_index" @change="tabChange"
  20. tab-class="text-black bg-white list_top" select-class="text-blue text-xl"></wuc-tab>
  21. </view>
  22. <view class="index-content">
  23. <view class="index-tiku">
  24. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
  25. :down="downOption" :up="upOption">
  26. <block v-for="(item, index) in list" :key="index">
  27. <view class="index-tiku-content"
  28. @tap="$openrul('/pages/my/wrongQuestion/detail?id=' + item.id + '&from_type=' + current_id)">
  29. <view class="pub-flex-1">
  30. <view class="index-tiku-content-flex">
  31. <view class="index-tiku-content-top">
  32. <view>{{current_id == 1 ? item.unit_name : item.library_name}}</view>
  33. <view class="error_num">错{{item.error_num}}题</view>
  34. </view>
  35. </view>
  36. <view class="index-tiku-content-flex">
  37. <view class="index-tiku-content-bottom">
  38. <view>来源:{{current_id == 1 ? '章节练习' : '真题练习'}}
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. <view class="iconfont icon-arrow"></view>
  44. </view>
  45. </block>
  46. </mescroll-body>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  53. import {
  54. mapState
  55. } from 'vuex'
  56. import WucTab from '@/components/wuc-tab/wuc-tab.vue';
  57. export default {
  58. mixins: [MescrollMixin], // 使用mixin
  59. data() {
  60. return {
  61. mescroll: null, // mescroll实例对象 (此行可删,mixins已默认)
  62. // 下拉刷新的配置(可选, 绝大部分情况无需配置)
  63. downOption: {
  64. use: false, // 是否启用下拉刷新; 默认true
  65. auto: false, // 是否在初始化完毕之后自动执行下拉刷新的回调; 默认true
  66. native: false // 启用系统自带的下拉组件,默认false;仅mescroll-body生效,mescroll-uni无效(native: true, 则需在pages.json中配置"enablePullDownRefresh":true)
  67. },
  68. // 上拉加载的配置(可选, 绝大部分情况无需配置)
  69. upOption: {
  70. page: {
  71. num: 0,
  72. size: 10 // 每页数据的数量,默认10
  73. },
  74. noMoreSize: 5, // 配置列表的总数量要大于等于5条才显示'-- END --'的提示
  75. empty: {
  76. tip: '暂无相关数据'
  77. }
  78. },
  79. // 列表数据
  80. list: [],
  81. order_sort: [{
  82. name: '章节练习',
  83. goods_type: '1'
  84. },
  85. {
  86. name: '真题练习',
  87. goods_type: '2'
  88. }
  89. ],
  90. current_id: '1',
  91. current_index: 0,
  92. }
  93. },
  94. onShow() {
  95. this.canReset && this.mescroll.resetUpScroll()
  96. this.canReset = true
  97. },
  98. onLoad(opts) {
  99. this.pages_params = opts
  100. },
  101. mounted() {},
  102. computed: {
  103. ...mapState(['subject'])
  104. },
  105. components: {
  106. WucTab,
  107. },
  108. methods: {
  109. /*上拉加载的回调*/
  110. async upCallback(page) {
  111. let pageNum = page.num; // 页码, 默认从1开始
  112. let pageSize = page.size; // 页长, 默认每页10条
  113. let url
  114. if (this.current_id == 1) {
  115. //章节练习
  116. url = this.$myHttp.urlMap.wrongQuestion
  117. } else if (this.current_id == 2) {
  118. // 历年真题
  119. url = this.$myHttp.urlMap.zhenti_wrongQuestion
  120. }
  121. let res = await this.$myHttp.post({
  122. url: url,
  123. data: {
  124. subject_id: this.subject.id,
  125. page: pageNum,
  126. limit: pageSize
  127. },
  128. needLogin: true
  129. })
  130. if (res.code == 1) {
  131. // 接口返回的当前页数据列表 (数组)
  132. let curPageData = res.data.data;
  133. // 接口返回的当前页数据长度 (如列表有26个数据,当前页返回8个,则curPageLen=8)
  134. let curPageLen = curPageData.length;
  135. // 接口返回的总页数 (如列表有26个数据,每页10条,共3页; 则totalPage=3)
  136. // let totalPage = data.xxx;
  137. // 接口返回的总数据量(如列表有26个数据,每页10条,共3页; 则totalSize=26)
  138. let totalSize = res.data.total;
  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. tabChange(index) {
  149. this.list = []
  150. this.current_index = index;
  151. this.current_id = this.order_sort[index].goods_type;
  152. this.mescroll.resetUpScroll(false)
  153. }
  154. }
  155. }
  156. </script>
  157. <style>
  158. page {
  159. background: #f6f7f9;
  160. }
  161. .index-content {
  162. width: 100%;
  163. margin: 0 auto;
  164. display: flex;
  165. flex-direction: column;
  166. background: #fff;
  167. }
  168. .index-tiku-content {
  169. width: 92%;
  170. margin: 0 auto;
  171. display: flex;
  172. flex-direction: row;
  173. align-items: center;
  174. font-size: 16px;
  175. padding: 14px 0;
  176. border-bottom: solid 1px #f5f5f5;
  177. justify-content: space-between;
  178. }
  179. .index-tiku-content-flex {
  180. width: 100%;
  181. display: flex;
  182. justify-content: space-between;
  183. align-items: center;
  184. }
  185. .index-tiku-content .icon-arrow {
  186. padding-left: 13px;
  187. color: #b3b3b3;
  188. }
  189. .index-tiku-content .index-tiku-content-flex:first-child {
  190. padding-bottom: 6px;
  191. }
  192. .index-tiku-content .index-tiku-content-flex:last-child {
  193. font-size: 14px;
  194. color: #d0d0d0;
  195. }
  196. .index-tiku-content-top {
  197. display: flex;
  198. align-items: center;
  199. }
  200. .index-tiku-content-top img {
  201. width: 20px;
  202. height: 22px;
  203. margin-right: 10px;
  204. }
  205. .index-tiku-content-bottom {
  206. display: flex;
  207. align-items: flex-start;
  208. flex-direction: column;
  209. }
  210. .error_num {
  211. background: #ececec;
  212. color: #3c7bfc;
  213. padding: 2px 10px;
  214. font-size: 12px;
  215. margin-left: 8px;
  216. border-radius: 14px 14px 14px 0;
  217. word-break: keep-all;
  218. }
  219. .zhenti-title {
  220. font-size: 16px;
  221. color: #000;
  222. }
  223. </style>