Commit c7cac04955e324880cda13b20139350d86a8ef99

Authored by zhiyangdu
1 parent a650e7ab

数据联调

src/components/columnCommodityListBox/columnCommodityListBox.vue
... ... @@ -68,7 +68,7 @@
68 68 export default {
69 69 data() {
70 70 return {
71   -
  71 +
72 72 };
73 73 },
74 74 props: ["columnLists"],
... ... @@ -88,7 +88,7 @@
88 88 */
89 89 getDecimal() {
90 90 return (number) => {
91   -
  91 +
92 92 // 拆分数字
93 93 let numberArr = number.toString().split(".");
94 94  
... ... @@ -101,8 +101,11 @@
101 101 }
102 102 }
103 103 },
  104 + created(){
  105 + console.log(this.columnLists)
  106 + },
104 107 methods: {
105   -
  108 +
106 109 /**
107 110 * 跳转详情
108 111 * @param {object} item [对象]
... ... @@ -117,4 +120,4 @@
117 120 <!-- Add "scoped" attribute to limit CSS to this component only -->
118 121 <style rel="stylesheet/less" lang='less' scoped>
119 122 @import './columnCommodityListBox';
120   -</style>
121 123 \ No newline at end of file
  124 +</style>
... ...
src/components/tabBox/tabBox.vue
... ... @@ -7,25 +7,25 @@
7 7 <div class="tabbar" v-for="(item, index) in tabbaromponents.ads" :key="index">
8 8 <!-- 关爱屋简介 -->
9 9 <html-box
10   - v-if="item.style == '14'"
  10 + v-if="item.style === '14'"
11 11 :htmls="item.content">
12 12 </html-box>
13 13 <!-- 精品推荐 -->
14 14 <!-- 精品推荐 -->
15   - <div class="boutique-list" v-infinite-scroll="loadBoutique" infinite-scroll-disabled="paging.boutique.loading" :infinite-scroll-distance="paging.distance">
  15 + <!--<div class="boutique-list" v-infinite-scroll="loadBoutique" infinite-scroll-disabled="paging.boutique.loading" :infinite-scroll-distance="paging.distance">-->
16 16 <img-list-box
17   - v-if="item.style == '1'"
  17 + v-if="item.style === '1'"
18 18 @detail="toDetail"
19 19 :imgLists="item.img">
20 20 </img-list-box>
21   - </div>
  21 + <!--</div>-->
22 22 <!-- 商品推荐 -->
23 23 <!-- 商品推荐 -->
24   - <div class="column-commodity-list" v-infinite-scroll="loadCommodity" infinite-scroll-disabled="paging.commodity.loading" :infinite-scroll-distance="paging.distance">
  24 + <div class="column-commodity-list" v-infinite-scroll="loadCommodity" infinite-scroll-disabled="paging.commodity.loading" :infinite-scroll-distance="paging.distance">
25 25 <column-commodity-list-box
26   - v-if="item.style == '15'"
  26 + v-if="item.style === '15'"
27 27 @detail="toCommodityDetail"
28   - :columnLists="item">
  28 + :columnLists="commoditys">
29 29 </column-commodity-list-box>
30 30 </div>
31 31 <!--优惠专区-->
... ... @@ -40,6 +40,7 @@
40 40 </template>
41 41  
42 42 <script>
  43 + import { Toast, Indicator } from "mint-ui";
43 44 import htmlBox from "@/components/htmlBox/htmlBox";
44 45 import imgListBox from "@/components/imgListBox/imgListBox";
45 46 import columnCommodityListBox from "@/components/columnCommodityListBox/columnCommodityListBox";
... ... @@ -50,6 +51,9 @@
50 51 return {
51 52 active: 0,
52 53 tabbaromponents: null, // 组件库
  54 + commoditys: { // 全部推荐
  55 + list: []
  56 + },
53 57 paging: { // 分页
54 58 boutique: {
55 59 loading: true,
... ... @@ -76,7 +80,7 @@
76 80 return item.title === "关爱屋"
77 81 });
78 82 // 获取领头雁电商精品推荐
79   - this.getActivityAdsGoods(this.paging.boutique.page);
  83 +// this.getActivityAdsGoods(this.paging.boutique.page);
80 84 },
81 85 methods: {
82 86 onChange(name, title) {
... ... @@ -84,6 +88,11 @@
84 88 this.tabbaromponents = this.tabbar.find((item)=>{
85 89 return item.title === title
86 90 });
  91 + if(title==='全部商品'){
  92 + // 店铺商品推荐
  93 + this.shopRecommendGoods(this.paging.commodity.page);
  94 + }
  95 +
87 96 },
88 97 /**
89 98 * 调用通用跳转
... ... @@ -114,28 +123,13 @@
114 123 this.toDetail(item);
115 124 },
116 125 /**
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 126 * 店铺商品推荐
133 127 * @param {int} page [页码]
134 128 */
135 129 shopRecommendGoods(page) {
136   -
  130 + console.log(this.tabbaromponents)
137 131 // 判断必要参数
138   - if (this.shopId) {
  132 + if (this.tabbaromponents.ads[0].id) {
139 133  
140 134 // 加载中
141 135 this.$set(this.paging.commodity, "loading", true);
... ... @@ -144,8 +138,8 @@
144 138 Indicator.open('加载中...');
145 139  
146 140 // 请求接口
147   - this.http("/Api/" + (this.getApiVersion().index) + "/shopRecommendGoods", {
148   - shop_id: this.shopId,
  141 + this.http("/Api/" + (this.getApiVersion().index) + "/shopGoodsList", {
  142 + shop_id: this.tabbaromponents.ads[0].id,
149 143 page: page
150 144 }, this.shopRecommendGoodsCallback, {
151 145 method: "POST"
... ... @@ -159,7 +153,6 @@
159 153 * @param {object} ext [扩展参数]
160 154 */
161 155 shopRecommendGoodsCallback(res, ext) {
162   -
163 156 // 加载完成
164 157 Indicator.close();
165 158  
... ... @@ -172,26 +165,13 @@
172 165 /* 设置商品推荐数据 开始 */
173 166  
174 167 // 判断是否有数据
175   - if (datas.list && datas.list.length) {
  168 + if (datas && datas.length) {
176 169  
177 170 // 追加列表
178   - this.$set(this.commoditys, "list", [...this.commoditys.list, ...datas.list]);
  171 + this.$set(this.commoditys, "list", [...this.commoditys.list, ...datas]);
179 172  
180 173 // 设置还有需要加载的内容
181 174 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 175 } else {
196 176  
197 177 // 没有需要加载的内容,停止上拉加载
... ...