cart.vue 5.3 KB

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