Authored by 李奇

新品到着添加购物袋

... ... @@ -83,7 +83,7 @@ const model = {
* 判断是否收藏
* @param params
*/
isFavorite(params){
isFavorite(params) {
return api.get('/favorite', Object.assign({
method: 'app.favorite.isFavoriteNew'
}, params));
... ...
... ... @@ -143,7 +143,7 @@ module.exports = {
},
clearChosenVal(){
this.show = false;
this.chosen = {};
this.chosen = [];
this.chosenVal = '';
this.allChoices = this.initialChoices.slice();
bus.$emit('subChosen.change', typeMap[this.name], this.chosen);
... ...
... ... @@ -239,21 +239,18 @@ module.exports = {
bus.$emit('subFilter.change', sub, filter);
},
subChosenChange(name, chosen) {
let keyArr = Object.keys(chosen);
if (keyArr.length) {
if (chosen.length) {
let id, nm;
this.values[name] = [];
_.each(keyArr, key => {
_.each(chosen, item => {
id = name !== 'group_sort' ?
chosen[key].id :
chosen[key].relation_parameter.sort;
item.id :
item.relation_parameter.sort;
nm = name !== 'group_sort' ?
chosen[key].name :
chosen[key].category_name;
item.name :
item.category_name;
this.values[name].push({
id,
... ...
... ... @@ -3,6 +3,7 @@
<cheader title="新品抢先看"></cheader>
<list-filter :val="order" :filter="filterConfig" v-if="enableOrder"></list-filter>
<List :data="productList" :state="listState" class="list-items"></List>
<shopping-bag :cart-count="cartCount" v-if="isApp"></shopping-bag>
</div>
</template>
<script>
... ... @@ -16,6 +17,7 @@
const tip = require('common/tip');
const cheader = require('component/header.vue');
const list = require('component/product/list.vue');
const shoppingBag = require('component/product/shopping-bag.vue');
const listFilter = require('component/product/filter/index.vue');
let locationQuery = qs(decodeURIComponent(location.search.replace(/^\?/, '')));
... ... @@ -29,6 +31,7 @@
el: '#product-new',
data: function() {
return {
isApp: yoho.isApp,
isiOS: yoho.isiOS,
sortName: locationQuery.sort_name,
filterConfig: null,
... ... @@ -45,7 +48,8 @@
// state
inSearching: false, // 请求中
enableOrder: false,
order: ''
order: '',
cartCount: 0
};
},
computed: {
... ... @@ -70,7 +74,8 @@
components: {
cheader,
list,
listFilter
listFilter,
shoppingBag
},
methods: {
search: function() {
... ... @@ -124,6 +129,14 @@
this.page = 0;
this.$set('productList', []);
this.search();
},
refreshCart: function() {
$.get('/product/cart-count.json').then(result=> {
if (result.code === 200) {
this.cartCount = result.data.cart_goods_count;
}
});
}
},
watch: {
... ... @@ -150,6 +163,11 @@
self.$set('filter', val);
});
// 读取购物车数量
if (this.isApp) {
this.refreshCart();
}
this.search();
}
};
... ...