certificatesList.vue 4.5 KB

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