Authored by 李奇

fixed: 列表页添加购物车

... ... @@ -175,7 +175,7 @@
}
.right-btn {
font-size: 38px;
font-size: 17PX;
margin-right: 30px;
}
}
... ...
... ... @@ -5,6 +5,7 @@
<product-list :data="productList" :state="listState"></product-list>
</div>
<filter-box :val="order" :filter="filterConfig" v-if="enableOrder" ref="filter"></filter-box>
<shopping-bag :cart-count="cartCount" v-if="isApp"></shopping-bag>
</div>
</template>
<style>
... ... @@ -35,6 +36,8 @@
import shopTop from 'product/shop/shop-top.vue'; // 店铺头部信息
import ProductList from 'component/product/list.vue';
import FilterBox from 'component/product/filter/index.vue';
import ShoppingBag from 'component/product/shopping-bag.vue';
const $shop = $('#shop');
... ... @@ -44,6 +47,7 @@
export default {
data() {
return {
isApp: yoho.isApp,
noheader: false,
shareData: {}, // 分享相关数据
shopInfo: {}, // 店铺介绍相关数据
... ... @@ -64,6 +68,7 @@
inSearching: false,
enableOrder: false,
order: '',
cartCount: 0
};
},
computed: {
... ... @@ -178,13 +183,22 @@
this.page = 0;
this.productList = [];
this.search();
},
refreshCart: function() {
$.get('/product/cart-count.json').then(result=> {
if (result.code === 200) {
this.cartCount = result.data.cart_goods_count;
}
});
}
},
components: {
topBar,
shopTop,
ProductList,
FilterBox
FilterBox,
ShoppingBag
},
created() {
const self = this;
... ... @@ -219,6 +233,12 @@
self.filter = val;
self.$refs.filter.isVisible = false;
});
// 读取购物车数量
if (this.isApp) {
this.refreshCart();
bus.$on('app.shoppingcart.refresh', this.refreshCart);
}
}
};
... ...