cat1.vue 4.6 KB

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