certificatesList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  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.training.image"></image>
  15. <view class="list-tpl">{{ item.training.title }}</view>
  16. </view>
  17. <view class="">
  18. {{ item.training.title }}
  19. </view>
  20. </view>
  21. </scroll-view>
  22. </swiper-item>
  23. </swiper>
  24. </view>
  25. </template>
  26. <script>
  27. import {
  28. mapState,
  29. mapMutations
  30. } from 'vuex';
  31. import uniLoadMore from '@/components/uni-load-more/uni-load-more.vue';
  32. import empty from '@/components/empty';
  33. import uniPopup from '@/components/uni-popup/uni-popup.vue';
  34. import {
  35. myTrainingList
  36. } from '@/api/index.js';
  37. export default {
  38. components: {
  39. uniLoadMore,
  40. empty,
  41. uniPopup
  42. },
  43. data() {
  44. return {
  45. page: 1, //当前页数
  46. limit: 6, //每次信息条数
  47. list: [],
  48. loadingType: 'more', //加载更多状态
  49. };
  50. },
  51. onLoad() {
  52. console.log(22)
  53. this.loadData();
  54. },
  55. computed: {
  56. ...mapState(['baseURL'])
  57. },
  58. methods: {
  59. //获取订单列表
  60. loadData(type) {
  61. //这里是将订单挂载到tab列表下
  62. let obj = this;
  63. if (type != 'refresh') {
  64. console.log(obj.loadingType, '456');
  65. //没有更多数据直接跳出方法
  66. if (obj.loadingType === 'nomore') {
  67. return;
  68. } else {
  69. // 设置当前为数据载入中
  70. obj.loadingType = 'loading';
  71. }
  72. } else {
  73. //当重新加载数据时更新状态为可继续添加数据
  74. obj.loadingType = 'more';
  75. }
  76. myTrainingList({})
  77. .then(data => {
  78. if (type === 'refresh') {
  79. obj.list = [];
  80. }
  81. let arr = data.data
  82. obj.list = obj.list.concat(arr);
  83. //判断是否还有下一页,有是more 没有是nomore
  84. if (obj.limit == arr.length) {
  85. obj.page++;
  86. obj.loadingType = 'more';
  87. } else {
  88. obj.loadingType = 'nomore';
  89. }
  90. // 判断是否为刷新数据
  91. if (type === 'refresh') {
  92. console.log('refresh');
  93. // 判断是否为点击搜索按钮跳转加载
  94. if (obj.loading == 1) {
  95. uni.hideLoading();
  96. } else {
  97. uni.stopPullDownRefresh();
  98. }
  99. }
  100. })
  101. .catch(e => {
  102. obj.loadingType = 'nomore';
  103. uni.hideLoading();
  104. });
  105. },
  106. //跳转到详情
  107. ToDetail(e) {
  108. let type = e.type;
  109. let id = e.id;
  110. uni.navigateTo({
  111. url: '/pages/form/certificates?type=' + type + '&id=' + id
  112. });
  113. }
  114. }
  115. };
  116. </script>
  117. <style lang="scss">
  118. page {
  119. background: #F2F2F2;
  120. height: 100%;
  121. padding-bottom: 25rpx;
  122. }
  123. .container {
  124. height: 100%;
  125. .top {
  126. background-color: #FFFFFF;
  127. height: 88rpx;
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. font-size: 36rpx;
  132. font-weight: 500;
  133. color: #333333;
  134. }
  135. .swiper-box {
  136. height: 100%;
  137. .list-scroll-content {
  138. height: 100%;
  139. }
  140. }
  141. }
  142. .scroll-list {
  143. width: 100%;
  144. overflow: hidden;
  145. white-space: nowrap;
  146. background-color: #ffffff;
  147. font-size: 32rpx;
  148. .scoll-box {
  149. text-align: center;
  150. display: inline-block;
  151. margin: 0rpx 38rpx;
  152. padding: 15rpx 0rpx;
  153. .scoll-img {
  154. width: 130rpx;
  155. height: 85rpx;
  156. border-radius: 100%;
  157. image {
  158. width: 85rpx;
  159. height: 100%;
  160. border-radius: 100%;
  161. }
  162. }
  163. .scoll-name {
  164. padding-top: 15rpx;
  165. }
  166. &.active {
  167. color: #ef3d28;
  168. border-bottom: 6rpx solid #ef3d28;
  169. }
  170. }
  171. }
  172. .order-item {
  173. width: 100%;
  174. padding: 0rpx 25rpx;
  175. padding-top: 25rpx !important;
  176. .list-cell {
  177. // background-color: #ffffff;
  178. border-radius: 20rpx;
  179. width: 100%;
  180. box-shadow: 0px 0px 40px 0px rgba(0, 0, 0, 0.06);
  181. .image {
  182. width: 100%;
  183. height: 300rpx;
  184. border-top-left-radius: 25rpx;
  185. border-top-right-radius: 25rpx;
  186. }
  187. .list-tpl {
  188. padding: 25rpx 25rpx;
  189. padding-bottom: 35rpx !important;
  190. font-size: 34rpx;
  191. color: #222222;
  192. font-weight: 500;
  193. }
  194. }
  195. }
  196. </style>