index.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  3. <HMfilterDropdown :filterData="filterData" :defaultSelected="filterDropdownValue" @confirm="confirmCate">
  4. </HMfilterDropdown>
  5. <view class="paper-contains">
  6. <!-- 考场列表 -->
  7. <view class="paper-card" v-for="(item, index) in list" :key="index">
  8. <navigator :url="'detail?id='+item.id" hover-class="none">
  9. <tui-card :title="{text: item.name, size: 30, color: '#7A7A7A'}"
  10. :tag="{text: item.cates ? item.cates.name : '-', size: 24}" :header="item.name">
  11. <template v-slot:body>
  12. <view class="tui-default">
  13. <view class="">
  14. {{item.contents}}
  15. </view>
  16. </view>
  17. </template>
  18. <template v-slot:footer>
  19. <view class="tui-default">
  20. <view class="">
  21. 考试时间:{{item.start_time|format_date}} - {{item.end_time|format_date}}
  22. </view>
  23. <text>报名方式:</text>
  24. <text class="cu-tag" :class="[getSignupModeClass(item)]">{{item.signup_mode_text}}</text>
  25. <view class="cu-capsule round m-l-30" v-if="item.is_makeup">
  26. <view class='cu-tag bg-blue '>
  27. 可补考
  28. </view>
  29. <view class="cu-tag line-blue">
  30. {{item.makeup_count}}次
  31. </view>
  32. </view>
  33. <!-- <text class="cu-tag m-l-30" :class="[getMakeupModeClass(item)]">{{item.makeup_mode_text}}</text> -->
  34. </view>
  35. </template>
  36. </tui-card>
  37. </navigator>
  38. </view>
  39. <!-- 加载状态条 -->
  40. <view class="cu-load bg-grey" :class="loadFlag" v-show="!has_more"></view>
  41. </view>
  42. <tabbar></tabbar>
  43. <!-- <scroll-view scroll-x class="bg-white nav" scroll-with-animation :scroll-left="scrollLeft">
  44. <view class="cu-item" :class="index==tabCur?'text-green cur':''" v-for="(item,index) in 10" :key="index" @tap="tabSelect" :data-id="index">
  45. Tab{{index}}
  46. </view>
  47. </scroll-view> -->
  48. </view>
  49. </template>
  50. <script>
  51. import HMfilterDropdown from '@/components/HM-filterDropdown/HM-filterDropdown.vue';
  52. export default {
  53. components: {
  54. 'HMfilterDropdown': HMfilterDropdown,
  55. },
  56. data() {
  57. return {
  58. // scrollLeft: 0,
  59. // tabCur: 0,
  60. filterData: [],
  61. filterDropdownValue: '',
  62. cate_id: null,
  63. sort: null,
  64. list: [],
  65. has_more: false,
  66. current_page: 1,
  67. loadFlag: 'loading',
  68. }
  69. },
  70. onLoad(e) {
  71. this.getCate()
  72. this.getRoom()
  73. },
  74. async onReachBottom() {
  75. console.log("onReachBottom")
  76. if (this.has_more) {
  77. this.current_page++
  78. this.getRoom()
  79. }
  80. },
  81. computed: {
  82. // 报名方式样式
  83. getSignupModeClass(item) {
  84. return function(item) {
  85. switch (item.signup_mode) {
  86. case 'NORMAL':
  87. return 'bg-green'
  88. case 'PASSWORD':
  89. return 'bg-bule'
  90. case 'AUDIT':
  91. return 'bg-purple'
  92. }
  93. }
  94. },
  95. // 补考方式样式
  96. getMakeupModeClass(item) {
  97. return function(item) {
  98. if (item.is_makeup) {
  99. return 'bg-green'
  100. }
  101. return 'bg-bule'
  102. }
  103. },
  104. },
  105. methods: {
  106. // 获取分类
  107. getCate() {
  108. this.http('cate/filter', {
  109. kind: 'ROOM'
  110. }).then(res => {
  111. this.filterData = res.data
  112. })
  113. },
  114. // 获取考场
  115. getRoom() {
  116. this.loadFlag = 'loading'
  117. let params = {
  118. page: this.current_page
  119. }
  120. if (this.cate_id) {
  121. params['cate_id'] = this.cate_id
  122. }
  123. if (this.sort) {
  124. params['sort'] = this.sort
  125. }
  126. this.http('room/index', params).then(res => {
  127. if (res && res.data) {
  128. this.list = this.list.concat(res.data.list.data)
  129. console.log('list', this.list)
  130. this.has_more = res.data.list.has_more
  131. this.current_page = res.data.list.current_page
  132. this.loadFlag = 'over'
  133. }
  134. })
  135. },
  136. // 选择分类
  137. confirmCate(event) {
  138. console.log('confirm cate', event)
  139. let cate_id = 0
  140. for (let i = 0; i < event.value[0].length; i++) {
  141. cate_id = event.value[0].pop()
  142. if (cate_id) {
  143. break
  144. }
  145. }
  146. if (!cate_id && event.value[0][0]) {
  147. cate_id = event.value[0][0]
  148. }
  149. let sort = ''
  150. if (event?.value[1]) {
  151. sort = event?.value[1][0]
  152. }
  153. if (cate_id != this.cate_id || sort != this.sort) {
  154. this.cate_id = cate_id
  155. this.sort = sort
  156. this.list = []
  157. this.getRoom()
  158. }
  159. },
  160. // tabSelect(e) {
  161. // this.tabCur = e.currentTarget.dataset.id;
  162. // this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
  163. // }
  164. }
  165. }
  166. </script>
  167. <style>
  168. .paper-contains {
  169. margin-top: 50px;
  170. }
  171. .paper-card {
  172. margin: 20rpx 0;
  173. }
  174. .tui-title {
  175. width: 100%;
  176. padding: 70rpx 30rpx 30rpx 30rpx;
  177. box-sizing: border-box;
  178. font-size: 30rpx;
  179. line-height: 30rpx;
  180. color: #666;
  181. }
  182. .tui-default {
  183. padding: 20rpx 30rpx;
  184. }
  185. .tui-article {
  186. position: relative;
  187. }
  188. .tui-article-img {
  189. width: 100%;
  190. height: 300rpx;
  191. display: block;
  192. }
  193. .tui-article-title {
  194. position: absolute;
  195. left: 0;
  196. bottom: 0;
  197. color: #fff;
  198. font-size: 32rpx;
  199. font-weight: 500;
  200. box-sizing: border-box;
  201. padding: 20rpx 30rpx;
  202. background: linear-gradient(to bottom, transparent, rgba(0, 0, 0, 0.6));
  203. }
  204. .tui-cell-title {
  205. font-size: 32rpx;
  206. font-weight: 500;
  207. padding: 0 10rpx;
  208. word-break: break-all;
  209. word-wrap: break-word;
  210. }
  211. .tui-cell-img {
  212. height: 160rpx;
  213. width: 160rpx;
  214. }
  215. .tui-flex {
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-between;
  219. }
  220. .tui-mr {
  221. margin-right: 20rpx;
  222. }
  223. .tui-flex-pic {
  224. display: flex;
  225. display: -webkit-flex;
  226. justify-content: space-between;
  227. flex-direction: row;
  228. flex-wrap: wrap;
  229. box-sizing: border-box;
  230. background: #fff;
  231. padding: 0 120rpx;
  232. }
  233. .tui-flex-pic image {
  234. width: 32%;
  235. margin-bottom: 2%;
  236. }
  237. .tui-content {
  238. padding: 0rpx 30rpx 20rpx 120rpx;
  239. box-sizing: border-box;
  240. font-size: 34rpx;
  241. font-weight: 400;
  242. color: #333;
  243. }
  244. .tui-color-gray {
  245. color: #ccc;
  246. }
  247. .tui-pleft {
  248. padding-left: 120rpx;
  249. }
  250. </style>