cart.vue 4.2 KB

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