index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <view class="container">
  3. <!-- <view class="top">
  4. 普及培训
  5. </view> -->
  6. <swiper class="swiper-box" duration="300" @change="changeTab">
  7. <swiper-item class="tab-content">
  8. <scroll-view class="list-scroll-content" scroll-y>
  9. <!-- 空白页 -->
  10. <empty v-if="loadingType === true && list.length === 0"></empty>
  11. <!-- 订单列表 -->
  12. <view class="order-item" @click="ToDetail(item)" v-for="(item, index) in list" :key="index">
  13. <view class="list-cell">
  14. <image class="image" :src="baseURL + item.image"></image>
  15. <view class="list-tpl">{{ item.title }}</view>
  16. <view class="list-tip">{{ item.info }}</view>
  17. <view class="info-box">
  18. <view class="list-info">
  19. <image src="../../static/img/time.png" mode=""></image>
  20. <view class="list-font">
  21. 开始时间:{{ item.reg_start }}
  22. </view>
  23. </view>
  24. <view class="list-info">
  25. <image src="../../static/img/time.png" mode=""></image>
  26. <view class="list-font">
  27. 结束时间:{{ item.reg_end }}
  28. </view>
  29. </view>
  30. <view class="flex">
  31. <view class="list-info" style="width: 50%;">
  32. <image src="../../static/img/people.png" mode=""></image>
  33. <view class="list-font">
  34. 当前报名人数:{{ item.number }}
  35. </view>
  36. </view>
  37. <view class="list-info" style="width: 50%;">
  38. <image src="../../static/img/people.png" mode=""></image>
  39. <view class="list-font">
  40. 最大报名人数:{{ item.max_number || 0 }}
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </swiper-item>
  49. </swiper>
  50. </view>
  51. </template>
  52. <script>
  53. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  54. import empty from '@/components/empty';
  55. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  56. import { training } from '@/api/index.js';
  57. import { mapState, mapMutations } from 'vuex';
  58. export default {
  59. components: {
  60. uniLoadMore,
  61. empty,
  62. uniPopup
  63. },
  64. data() {
  65. return {
  66. page: 1, //当前页数
  67. limit: 6, //每次信息条数
  68. list: [],
  69. loadingType: 'more' //加载更多状态
  70. };
  71. },
  72. computed: {
  73. ...mapState(['baseURL'])
  74. },
  75. onLoad() {
  76. console.log(22);
  77. this.loadData();
  78. },
  79. methods: {
  80. //获取订单列表
  81. loadData(type) {
  82. //这里是将订单挂载到tab列表下
  83. let obj = this;
  84. if (type != 'refresh') {
  85. console.log(obj.loadingType, '456');
  86. //没有更多数据直接跳出方法
  87. if (obj.loadingType === 'nomore') {
  88. return;
  89. } else {
  90. // 设置当前为数据载入中
  91. obj.loadingType = 'loading';
  92. }
  93. } else {
  94. //当重新加载数据时更新状态为可继续添加数据
  95. obj.loadingType = 'more';
  96. }
  97. training({})
  98. .then(data => {
  99. if (type === 'refresh') {
  100. obj.list = [];
  101. }
  102. data.data.forEach(item => {});
  103. let arr = data.data;
  104. obj.list = obj.list.concat(arr);
  105. console.log(obj.list, 123456);
  106. //判断是否还有下一页,有是more 没有是nomore
  107. if (obj.limit == arr.length) {
  108. obj.page++;
  109. obj.loadingType = 'more';
  110. } else {
  111. obj.loadingType = 'nomore';
  112. }
  113. // 判断是否为刷新数据
  114. if (type === 'refresh') {
  115. console.log('refresh');
  116. // 判断是否为点击搜索按钮跳转加载
  117. if (obj.loading == 1) {
  118. uni.hideLoading();
  119. } else {
  120. uni.stopPullDownRefresh();
  121. }
  122. }
  123. })
  124. .catch(e => {
  125. obj.loadingType = 'nomore';
  126. uni.hideLoading();
  127. });
  128. },
  129. //跳转到详情
  130. ToDetail(e) {
  131. let type = e.type;
  132. let id = e.id;
  133. uni.navigateTo({
  134. url: '/pages/train/sign?id=' + id
  135. });
  136. }
  137. }
  138. };
  139. </script>
  140. <style lang="scss">
  141. page {
  142. background: #f2f2f2;
  143. height: 100%;
  144. padding-bottom: 25rpx;
  145. }
  146. .container {
  147. height: 100%;
  148. .top {
  149. background-color: #ffffff;
  150. height: 88rpx;
  151. display: flex;
  152. align-items: center;
  153. justify-content: center;
  154. font-size: 36rpx;
  155. font-weight: 500;
  156. color: #333333;
  157. }
  158. .swiper-box {
  159. height: 100%;
  160. .list-scroll-content {
  161. height: 100%;
  162. }
  163. }
  164. }
  165. .scroll-list {
  166. width: 100%;
  167. overflow: hidden;
  168. white-space: nowrap;
  169. background-color: #ffffff;
  170. font-size: 32rpx;
  171. .scoll-box {
  172. text-align: center;
  173. display: inline-block;
  174. margin: 0rpx 38rpx;
  175. padding: 15rpx 0rpx;
  176. .scoll-img {
  177. width: 130rpx;
  178. height: 85rpx;
  179. border-radius: 100%;
  180. image {
  181. width: 85rpx;
  182. height: 100%;
  183. border-radius: 100%;
  184. }
  185. }
  186. .scoll-name {
  187. padding-top: 15rpx;
  188. }
  189. &.active {
  190. color: #ef3d28;
  191. border-bottom: 6rpx solid #ef3d28;
  192. }
  193. }
  194. }
  195. .order-item {
  196. width: 100%;
  197. padding: 0rpx 25rpx;
  198. padding-top: 25rpx !important;
  199. .list-cell {
  200. background-color: #ffffff;
  201. border-radius: 20rpx;
  202. width: 100%;
  203. box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.06);
  204. .image {
  205. width: 100%;
  206. height: 300rpx;
  207. border-top-left-radius: 25rpx;
  208. border-top-right-radius: 25rpx;
  209. }
  210. .list-tpl {
  211. padding: 25rpx 25rpx;
  212. padding-bottom: 0rpx !important;
  213. font-size: 34rpx;
  214. color: #222222;
  215. font-weight: 500;
  216. }
  217. .list-tip {
  218. padding: 10rpx 25rpx 35rpx;
  219. font-size: 24rpx;
  220. color: #b4b4b4;
  221. }
  222. .info-box {
  223. padding: 0 25rpx 35rpx;
  224. .list-info {
  225. margin-top: 10rpx;
  226. display: flex;
  227. justify-content: flex-start;
  228. align-items: center;
  229. image{
  230. width: 24rpx;
  231. height: 24rpx;
  232. }
  233. .list-font {
  234. margin-left: 6rpx;
  235. font-size: 24rpx;
  236. }
  237. }
  238. }
  239. }
  240. }
  241. </style>