海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
3.6 KiB

4 years ago
  1. <template>
  2. <view>
  3. <!-- 图片轮播 -->
  4. <swiper :current="current" :indicator-dots="banners.length > 1 ? true : false" :circular="true" class="swiper-box" indicator-active-color="#1998FE">
  5. <swiper-item v-for="(item, index) in banners" :key="index">
  6. <image mode="aspectFill" :src="item" style="width: 100%; height: 100%;" @click="lookImg(index)"></image>
  7. </swiper-item>
  8. </swiper>
  9. <!-- 活动列表 -->
  10. <view class="content">
  11. <view class="item" v-for="(item,index) in list" :key="index">
  12. <view class="cover" @click="enterDetail(index)">
  13. <image :src="item.picture" class="lf-w-100 lf-h-100" mode="aspectFill"></image>
  14. </view>
  15. <view style="width: 420rpx;">
  16. <view class="lf-font-28 lf-color-333 lf-line-2">{{item.title}}</view>
  17. <view class="lf-font-24 lf-color-gray lf-line-2" style="min-height: 64rpx;">本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩本套票只包含两个成人不可带小孩</view>
  18. <view class="lf-flex lf-m-t-25">
  19. <lf-price :price="item.price"></lf-price>
  20. <text class="lf-font-24 lf-color-gray lf-line-through lf-m-l-15">¥{{item.original_price}}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- 加载 -->
  26. <view class="loading-more">
  27. <text v-if="list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  28. <lf-nocontent v-else></lf-nocontent>
  29. </view>
  30. <!-- 回到顶部 -->
  31. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  32. </view>
  33. </template>
  34. <script>
  35. export default {
  36. data(){
  37. return {
  38. current: 0,
  39. banners: [{id: 1, cover: 'https://picsum.photos/375/490'}],
  40. list: [],
  41. loadingClass: false,
  42. loadingText: '已加载全部数据~',
  43. page: 1,
  44. isPage: true,
  45. pageSize: 20,
  46. special_id: 0
  47. }
  48. },
  49. onLoad(e){
  50. this.special_id = e.special_id
  51. this.getActivityList();
  52. },
  53. methods: {
  54. lookImg(index){
  55. this.$u.throttle(() => {
  56. let goods_banner = this.banners || [];
  57. let banners = goods_banner.map(item => item);
  58. uni.previewImage({
  59. urls: banners,
  60. current: index
  61. })
  62. }, 200);
  63. },
  64. getActivityList(){
  65. this.$http(this.API.API_SPECIALLIST,{id:this.special_id}).then(res => {
  66. let isPage = res.data.next_page_url == null?false:true;
  67. this.isPage = isPage;
  68. let list = res.data.product
  69. this.banners = res.data.picture
  70. if(!isPage){
  71. this.loadingClass = false;
  72. this.loadingText = '已加载全部数据~';
  73. }
  74. if(this.page == 1){
  75. this.list = list;
  76. }else{
  77. this.list.push(...list);
  78. }
  79. })
  80. },
  81. // 进入商品详情页
  82. enterDetail(index){
  83. let goods_id = this.list[index].id;
  84. this.$url('/pages/goodsDetail/index?goods_id='+ goods_id);
  85. }
  86. },
  87. onReachBottom(){
  88. if(this.isPage){
  89. this.page = this.page + 1;
  90. this.getActivityList();
  91. }
  92. },
  93. onPullDownRefresh(){
  94. this.page = 1;
  95. this.isPage = true;
  96. this.loadingClass = true;
  97. this.loadingText = '正在加载中';
  98. this.getActivityList();
  99. uni.stopPullDownRefresh();
  100. }
  101. }
  102. </script>
  103. <style lang="scss" scoped="scoped">
  104. .swiper-box{
  105. width: 750rpx;
  106. height: 490rpx;
  107. background-color: #FFFFFF;
  108. }
  109. .content{
  110. padding: 0 32rpx;
  111. box-sizing: border-box;
  112. width: 750rpx;
  113. height: max-content;
  114. .item{
  115. width: 100%;
  116. height: auto;
  117. border-bottom: 1rpx solid #E5E5E5;
  118. padding: 30rpx 0;
  119. display: flex;
  120. &:last-child{
  121. border-bottom: none;
  122. }
  123. .cover{
  124. width: 250rpx;
  125. height: 210rpx;
  126. border-radius: 20rpx;
  127. overflow: hidden;
  128. margin-right: 15rpx;
  129. }
  130. }
  131. }
  132. </style>