Commit a650e7aba4725b31b3820e074f723bad99d558df
1 parent
528f78b5
增加刷新功能
Showing
1 changed file
with
133 additions
and
1 deletions
src/components/tabBox/tabBox.vue
| @@ -11,17 +11,23 @@ | @@ -11,17 +11,23 @@ | ||
| 11 | :htmls="item.content"> | 11 | :htmls="item.content"> |
| 12 | </html-box> | 12 | </html-box> |
| 13 | <!-- 精品推荐 --> | 13 | <!-- 精品推荐 --> |
| 14 | + <!-- 精品推荐 --> | ||
| 15 | + <div class="boutique-list" v-infinite-scroll="loadBoutique" infinite-scroll-disabled="paging.boutique.loading" :infinite-scroll-distance="paging.distance"> | ||
| 14 | <img-list-box | 16 | <img-list-box |
| 15 | v-if="item.style == '1'" | 17 | v-if="item.style == '1'" |
| 16 | @detail="toDetail" | 18 | @detail="toDetail" |
| 17 | :imgLists="item.img"> | 19 | :imgLists="item.img"> |
| 18 | </img-list-box> | 20 | </img-list-box> |
| 21 | + </div> | ||
| 19 | <!-- 商品推荐 --> | 22 | <!-- 商品推荐 --> |
| 23 | + <!-- 商品推荐 --> | ||
| 24 | + <div class="column-commodity-list" v-infinite-scroll="loadCommodity" infinite-scroll-disabled="paging.commodity.loading" :infinite-scroll-distance="paging.distance"> | ||
| 20 | <column-commodity-list-box | 25 | <column-commodity-list-box |
| 21 | v-if="item.style == '15'" | 26 | v-if="item.style == '15'" |
| 22 | @detail="toCommodityDetail" | 27 | @detail="toCommodityDetail" |
| 23 | :columnLists="item"> | 28 | :columnLists="item"> |
| 24 | </column-commodity-list-box> | 29 | </column-commodity-list-box> |
| 30 | + </div> | ||
| 25 | <!--优惠专区--> | 31 | <!--优惠专区--> |
| 26 | <discountZone v-if="item.style == '1'" @more="toDetail" @toDetail="toDetail" | 32 | <discountZone v-if="item.style == '1'" @more="toDetail" @toDetail="toDetail" |
| 27 | :discountZoneInfo="item"> | 33 | :discountZoneInfo="item"> |
| @@ -44,6 +50,17 @@ | @@ -44,6 +50,17 @@ | ||
| 44 | return { | 50 | return { |
| 45 | active: 0, | 51 | active: 0, |
| 46 | tabbaromponents: null, // 组件库 | 52 | tabbaromponents: null, // 组件库 |
| 53 | + paging: { // 分页 | ||
| 54 | + boutique: { | ||
| 55 | + loading: true, | ||
| 56 | + page: 1 | ||
| 57 | + }, | ||
| 58 | + commodity: { | ||
| 59 | + loading: true, | ||
| 60 | + page: 1 | ||
| 61 | + }, | ||
| 62 | + distance: 50 | ||
| 63 | + } | ||
| 47 | } | 64 | } |
| 48 | }, | 65 | }, |
| 49 | props:["tabbar"], | 66 | props:["tabbar"], |
| @@ -58,7 +75,8 @@ | @@ -58,7 +75,8 @@ | ||
| 58 | this.tabbaromponents = this.tabbar.find((item)=>{ | 75 | this.tabbaromponents = this.tabbar.find((item)=>{ |
| 59 | return item.title === "关爱屋" | 76 | return item.title === "关爱屋" |
| 60 | }); | 77 | }); |
| 61 | - console.log(this.tabbaromponents) | 78 | + // 获取领头雁电商精品推荐 |
| 79 | + this.getActivityAdsGoods(this.paging.boutique.page); | ||
| 62 | }, | 80 | }, |
| 63 | methods: { | 81 | methods: { |
| 64 | onChange(name, title) { | 82 | onChange(name, title) { |
| @@ -95,6 +113,120 @@ | @@ -95,6 +113,120 @@ | ||
| 95 | // 调用通用跳转 | 113 | // 调用通用跳转 |
| 96 | this.toDetail(item); | 114 | this.toDetail(item); |
| 97 | }, | 115 | }, |
| 116 | + /** | ||
| 117 | + * 上拉加载“精品推荐” | ||
| 118 | + */ | ||
| 119 | + loadBoutique() { | ||
| 120 | + | ||
| 121 | + // 判断是“精品推荐”页才加载 | ||
| 122 | + if (this.activeTabIndex === 1) { | ||
| 123 | + | ||
| 124 | + // 设置“精品推荐”页码 | ||
| 125 | + this.$set(this.paging.boutique, "page", ++this.paging.boutique.page); | ||
| 126 | + | ||
| 127 | + // 调用接口 | ||
| 128 | + this.getActivityAdsGoods(this.paging.boutique.page); | ||
| 129 | + } | ||
| 130 | + }, | ||
| 131 | + /** | ||
| 132 | + * 店铺商品推荐 | ||
| 133 | + * @param {int} page [页码] | ||
| 134 | + */ | ||
| 135 | + shopRecommendGoods(page) { | ||
| 136 | + | ||
| 137 | + // 判断必要参数 | ||
| 138 | + if (this.shopId) { | ||
| 139 | + | ||
| 140 | + // 加载中 | ||
| 141 | + this.$set(this.paging.commodity, "loading", true); | ||
| 142 | + | ||
| 143 | + // 加载中提示 | ||
| 144 | + Indicator.open('加载中...'); | ||
| 145 | + | ||
| 146 | + // 请求接口 | ||
| 147 | + this.http("/Api/" + (this.getApiVersion().index) + "/shopRecommendGoods", { | ||
| 148 | + shop_id: this.shopId, | ||
| 149 | + page: page | ||
| 150 | + }, this.shopRecommendGoodsCallback, { | ||
| 151 | + method: "POST" | ||
| 152 | + }); | ||
| 153 | + } | ||
| 154 | + }, | ||
| 155 | + | ||
| 156 | + /** | ||
| 157 | + * 店铺商品推荐回调 | ||
| 158 | + * @param {object} res [服务器返回数据] | ||
| 159 | + * @param {object} ext [扩展参数] | ||
| 160 | + */ | ||
| 161 | + shopRecommendGoodsCallback(res, ext) { | ||
| 162 | + | ||
| 163 | + // 加载完成 | ||
| 164 | + Indicator.close(); | ||
| 165 | + | ||
| 166 | + // 返回处理 | ||
| 167 | + if (res.code == 200) { | ||
| 168 | + | ||
| 169 | + // 解构数据 | ||
| 170 | + let {data: datas} = res; | ||
| 171 | + | ||
| 172 | + /* 设置商品推荐数据 开始 */ | ||
| 173 | + | ||
| 174 | + // 判断是否有数据 | ||
| 175 | + if (datas.list && datas.list.length) { | ||
| 176 | + | ||
| 177 | + // 追加列表 | ||
| 178 | + this.$set(this.commoditys, "list", [...this.commoditys.list, ...datas.list]); | ||
| 179 | + | ||
| 180 | + // 设置还有需要加载的内容 | ||
| 181 | + this.$set(this.paging.commodity, "loading", false); | ||
| 182 | + | ||
| 183 | + // 如果当前显示“全部商品”,设置swiper高度 | ||
| 184 | + if (this.activeTabIndex === 2) { | ||
| 185 | + | ||
| 186 | + this.$nextTick(() => { | ||
| 187 | + | ||
| 188 | + setTimeout(() => { | ||
| 189 | + | ||
| 190 | + // 重新设置swiper高度 | ||
| 191 | + this.$set(this.swiperExce, "offsetHeight", this.$refs.commodity.offsetHeight); | ||
| 192 | + }, 500); | ||
| 193 | + }); | ||
| 194 | + } | ||
| 195 | + } else { | ||
| 196 | + | ||
| 197 | + // 没有需要加载的内容,停止上拉加载 | ||
| 198 | + this.$set(this.paging.commodity, "loading", true); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + /* 设置商品推荐数据 结束 */ | ||
| 202 | + | ||
| 203 | + } else if (res.code == 400) { | ||
| 204 | + | ||
| 205 | + // 获取商品推荐失败 | ||
| 206 | + Toast(res.message); | ||
| 207 | + } else { | ||
| 208 | + | ||
| 209 | + // 获取商品推荐失败 | ||
| 210 | + Toast("获取商品推荐失败"); | ||
| 211 | + } | ||
| 212 | + }, | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * 上拉加载“商品推荐” | ||
| 216 | + */ | ||
| 217 | + loadCommodity() { | ||
| 218 | + | ||
| 219 | + // 判断是“精品推荐”页才加载 | ||
| 220 | + if (this.activeTabIndex === 2 && this.shopId) { | ||
| 221 | + | ||
| 222 | + // 设置“精品推荐”页码 | ||
| 223 | + this.$set(this.paging.commodity, "page", ++this.paging.commodity.page); | ||
| 224 | + | ||
| 225 | + // 调用接口 | ||
| 226 | + this.shopRecommendGoods(this.paging.commodity.page); | ||
| 227 | + } | ||
| 228 | + }, | ||
| 229 | + | ||
| 98 | } | 230 | } |
| 99 | } | 231 | } |
| 100 | </script> | 232 | </script> |