Jacob
4 天以前 bf50dc43351d1a9781a84faf775913e813ea6ecb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<template>
  <div class="quality-recommend">
    <div class="slider-banner swiper">
           <view class="swiper">
               <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
                indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
                   <block v-for="(item,index) in imgUrls" :key="index">
                       <swiper-item>
                           <image :src="item.pic" class="slide-image"></image>
                       </swiper-item>
                   </block>
               </swiper>
           </view>
    </div>
    <div class="title acea-row row-center-wrapper">
      <div class="line"></div>
      <div class="name">
        <span class="iconfont" :class="icon"></span>{{ name }}
      </div>
      <div class="line"></div>
    </div>
       <view class="wrapper">
           <GoodList  :bastList="goodsList" :is-sort="false"></GoodList>
           <view class="txt-bar" v-if="goodsList.length>0 && !isScroll">我是有底线的~</view>
           <emptyPage v-if="goodsList.length==0 && !isScroll" title="暂无数据~"></emptyPage>
       </view>
  </div>
</template>
<script>
import emptyPage from '@/components/emptyPage.vue'
import GoodList from "@/components/goodList";
import { getGroomList } from "@/api/store";
export default {
  name: "HotNewGoods",
  components: {
    GoodList,
       emptyPage,
  },
  props: {},
  data: function() {
    return {
      imgUrls: [],
      goodsList: [],
      name: "",
      icon: "",
           type:0,
           autoplay:true,
           circular:true,
           interval: 3000,
           duration: 500,
           page:1,
           limit:8,
           isScroll:true
    };
  },
  onLoad: function(option) {
   this.type = option.type
    this.titleInfo();
    this.getIndexGroomList();
  },
  methods: {
    titleInfo: function() {
      if (this.type === "1") {
        this.name = "精品推荐";
        this.icon = "icon-jingpintuijian";
               uni.setNavigationBarTitle({
                   title:"精品推荐"
               })
      } else if (this.type === "2") {
        this.name = "热门榜单";
        this.icon = "icon-remen";
               uni.setNavigationBarTitle({
                   title:"热门榜单"
               })
      } else if (this.type === "3") {
        this.name = "首发新品";
        this.icon = "icon-xinpin";
               uni.setNavigationBarTitle({
                   title:"首发新品"
               })
      }else if (this.type === "4") {
        this.name = "促销单品";
        this.icon = "icon-xinpin";
               uni.setNavigationBarTitle({
                   title:"促销单品"
               })
      }
    },
    getIndexGroomList: function() {
           if(!this.isScroll) return
      let that = this;
      let type = this.type;
      getGroomList(type,{
               page:this.page,
               limit:this.limit
           }).then(res => {
          that.imgUrls = res.data.banner;
          that.goodsList = that.goodsList.concat(res.data.list);
                   that.isScroll = res.data.list.length>=that.limit
                   that.page++
        })
        .catch(function(err) {
          that.$util.Tips({ title: (err&&err.message)?err.message:err });
        });
    }
  },
   onReachBottom() {
       this.getIndexGroomList()
   }
};
</script>
<style lang="scss">
   ::v-deep .empty-box{
       background-color: #f5f5f5;
   } 
   .swiper,swiper,swiper-item,.slide-image{
       width: 100%;
       height: 280rpx;
   }
   .quality-recommend {
       .wrapper{
           background: #fff;
       }
       .title {
       height: 120rpx;
       font-size:32rpx;
       color: #282828;
       background-color: #f5f5f5;
           .line{
               width: 230rpx;
               height: 2rpx;
               background-color: #e9e9e9;
           }
       }    
   }
   .txt-bar{
       padding: 20rpx 0;
       text-align: center;
       font-size: 26rpx;
       color: #666;
       background-color: #f5f5f5;
   }
</style>