Authored by ccbikai

Merge branch 'develop' of git.yoho.cn:fe/yohoblk-wap into develop

... ... @@ -95,6 +95,15 @@ const component = {
params.method = 'app.favorite.cancel';
}
if (!req.user.uid) {
// 未登陆
res.json({
code: 403
});
return;
}
model.favorite(params).then(result => {
res.json(result);
}).catch(next);
... ...
<template>
<ul class="feature-options">
<li v-for="item in options">
<button :class="{ 'button-solid': value && value === item.value}"
<button :class="{ 'button-solid': item.value && value.value === item.value}"
:disabled="item.disabled"
@click="selectOption(item.value)"
@click="selectOption(item)"
class="button feature-button">
{{item.text}}
</button>
... ... @@ -38,7 +38,7 @@
},
data() {
return {
value: ''
value: {}
};
},
watch: {
... ...
... ... @@ -165,6 +165,7 @@
const selection = {};
const colorSizes = {};
const stocks = {};
const self = this;
// 更新颜色
this.colors = this.entity.goodsList.filter((goods)=> {
... ... @@ -174,7 +175,7 @@
// 缩略图
thumbnails[goods.colorId] = goods.colorImage;
// 更新颜色对应尺码
// 更新颜色对应尺码 生成colorId 与 size的 映射
colorSizes[goods.colorId] = goods.goodsSizeBoList.map((size)=> {
if (!stocks[goods.colorId]) {
stocks[goods.colorId] = 0;
... ... @@ -183,11 +184,21 @@
// 默认选中有库存的第一个颜色尺码
if (size.goodsSizeStorageNum > 0) {
if (!selection.color) {
selection.color = goods.colorId;
self.selection.color = selection.color = {
text: goods.colorName,
value: goods.colorId,
disabled: false
};
}
if (!selection.size && size.goodsSizeStorageNum > 0) {
selection.size = size.goodsSizeSkuId;
self.selection.size = selection.size = {
text: size.sizeName,
value: size.goodsSizeSkuId,
goodsId: size.goodsId,
disabled: false
};
}
// 计算所有尺码的库存
... ... @@ -209,7 +220,7 @@
};
});
this.sizes = colorSizes[selection.color];
this.sizes = colorSizes[selection.color.value];
this.colorSizes = colorSizes;
this.thumbnails = thumbnails;
... ... @@ -258,24 +269,24 @@
});
if (oldSizes && oldSizes.length > 0) {
const newSizes = this.colorSizes[opt];
const newSizes = this.colorSizes[opt.value];
const matchedSize = newSizes.filter((item)=> {
return !item.disabled && item.text === oldSizes[0].text;
});
if (matchedSize && matchedSize.length > 0) {
return matchedSize[0].value;
return matchedSize[0];
}
}
}
return null;
})(this.selection.color, this.selection.size),
})(self.selection.color.value, self.selection.size.value),
thumbnail: this.thumbnails[opt]
};
this.sizes = this.colorSizes[opt];
this.sizes = this.colorSizes[opt.value];
Object.assign(this.selection, selection);
});
... ... @@ -305,32 +316,9 @@
return;
}
this.onAddToCart(this.selection, this.entity.pid);
},
getFullSelection() {
let size;
this.sizes.forEach((item)=> {
if (item.value === this.selection.size) {
size = item;
}
});
const param = Object.assign({goodsId: this.entity.id}, this.selection);
let color;
this.colors.indexOf((item)=> {
if (item.value === this.selection.color) {
color = item;
}
});
return {
size: size,
color: color,
productId: this.entity.id
};
this.onAddToCart(param);
}
}
};
... ...
... ... @@ -139,7 +139,7 @@
},
// 商品 feature改变
whenFeatureChange(selection, pid) {
whenFeatureChange(selection) {
const index = this.indexMap[pid];
this.showFeatureSelector = false;
... ...
... ... @@ -168,7 +168,7 @@
<div class="control-box">
<button class="button control-button" style="flex: 1">
<a style="position:relative">
<a href="javascript:void(0);" @click="yoho.goShopingCart()">
<i class="icon icon-bag"></i>
<span v-if="cartCount > 0" class="badge badge-tr">{{cartCount}}</span>
</a>
... ... @@ -395,6 +395,7 @@
module.exports = {
data() {
return {
yoho: yoho,
intro: {},
entity: {
brand: {
... ... @@ -407,7 +408,6 @@
},
showFeatureSelector: false,
cartCount: 0,
yoho: yoho,
/**
* 加入购物车回调
... ... @@ -416,7 +416,7 @@
*/
onAddToCart: (selection)=> {
$.post('/product/cart.json', {
productSku: selection.size,
productSku: selection.size.value,
buyNumber: 1
}).then((result)=> {
if (yoho.goShopingKey && result.data.shopping_key) {
... ... @@ -467,6 +467,9 @@
if (result.code === 200) {
tip('取消收藏成功');
this.entity.isCollect = 'N';
} else if (result.code === 403) {
// 未登陆
yoho.goLogin();
}
});
} else {
... ...