index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. // console.log(e.)
  134. if(e.is_create) {
  135. uni.showModal({
  136. title: '提示',
  137. content: '您已报名,无需再次报名'
  138. })
  139. return
  140. }
  141. uni.navigateTo({
  142. url: '/pages/train/sign?id=' + id
  143. });
  144. }
  145. }
  146. };
  147. </script>
  148. <style lang="scss">
  149. page {
  150. background: #f2f2f2;
  151. height: 100%;
  152. padding-bottom: 25rpx;
  153. }
  154. .container {
  155. height: 100%;
  156. .top {
  157. background-color: #ffffff;
  158. height: 88rpx;
  159. display: flex;
  160. align-items: center;
  161. justify-content: center;
  162. font-size: 36rpx;
  163. font-weight: 500;
  164. color: #333333;
  165. }
  166. .swiper-box {
  167. height: 100%;
  168. .list-scroll-content {
  169. height: 100%;
  170. }
  171. }
  172. }
  173. .scroll-list {
  174. width: 100%;
  175. overflow: hidden;
  176. white-space: nowrap;
  177. background-color: #ffffff;
  178. font-size: 32rpx;
  179. .scoll-box {
  180. text-align: center;
  181. display: inline-block;
  182. margin: 0rpx 38rpx;
  183. padding: 15rpx 0rpx;
  184. .scoll-img {
  185. width: 130rpx;
  186. height: 85rpx;
  187. border-radius: 100%;
  188. image {
  189. width: 85rpx;
  190. height: 100%;
  191. border-radius: 100%;
  192. }
  193. }
  194. .scoll-name {
  195. padding-top: 15rpx;
  196. }
  197. &.active {
  198. color: #ef3d28;
  199. border-bottom: 6rpx solid #ef3d28;
  200. }
  201. }
  202. }
  203. .order-item {
  204. width: 100%;
  205. padding: 0rpx 25rpx;
  206. padding-top: 25rpx !important;
  207. .list-cell {
  208. background-color: #ffffff;
  209. border-radius: 20rpx;
  210. width: 100%;
  211. box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.06);
  212. .image {
  213. width: 100%;
  214. height: 300rpx;
  215. border-top-left-radius: 25rpx;
  216. border-top-right-radius: 25rpx;
  217. }
  218. .list-tpl {
  219. padding: 25rpx 25rpx;
  220. padding-bottom: 0rpx !important;
  221. font-size: 34rpx;
  222. color: #222222;
  223. font-weight: 500;
  224. }
  225. .list-tip {
  226. padding: 10rpx 25rpx 35rpx;
  227. font-size: 24rpx;
  228. color: #b4b4b4;
  229. }
  230. .info-box {
  231. padding: 0 25rpx 35rpx;
  232. .list-info {
  233. margin-top: 10rpx;
  234. display: flex;
  235. justify-content: flex-start;
  236. align-items: center;
  237. image{
  238. width: 24rpx;
  239. height: 24rpx;
  240. }
  241. .list-font {
  242. margin-left: 6rpx;
  243. font-size: 24rpx;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. </style>