Commit 4756f016 authored by Junling Bu's avatar Junling Bu
Browse files

chore[litemall-vue]: 样式微调

parent 36085337
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
:goods="skuGoods" :goods="skuGoods"
:goodsId="goods.info.id" :goodsId="goods.info.id"
@buy-clicked="buyGoods" @buy-clicked="buyGoods"
@add-cart="addCart" @add-cart="addCart"
/> />
<van-popup v-model="propsPopup" position="bottom"> <van-popup v-model="propsPopup" position="bottom">
<popup-props :propsStr="props_str"></popup-props> <popup-props :propsStr="props_str"></popup-props>
...@@ -83,13 +83,13 @@ export default { ...@@ -83,13 +83,13 @@ export default {
goods: { goods: {
userHasCollect: 0, userHasCollect: 0,
info: { info: {
gallery:[] gallery: []
} }
}, },
sku: { sku: {
tree: [], tree: [],
list: [], list: [],
price: '1.00', // 默认价格(单位元) price: '1.00' // 默认价格(单位元)
}, },
skuGoods: { skuGoods: {
// 商品标题 // 商品标题
...@@ -109,8 +109,7 @@ export default { ...@@ -109,8 +109,7 @@ export default {
}; };
}, },
computed: {
computed: {
props_str() { props_str() {
let props_arr = []; let props_arr = [];
_.each(this.goods.attribute, json => { _.each(this.goods.attribute, json => {
...@@ -129,17 +128,14 @@ computed: { ...@@ -129,17 +128,14 @@ computed: {
this.showSku = true; this.showSku = true;
}, },
initData() { initData() {
goodsDetail({id: this.itemId}).then( goodsDetail({ id: this.itemId }).then(res => {
res => { this.goods = res.data.data;
this.goods = res.data.data; this.skuAdapter();
this.skuAdapter(); });
}
);
cartGoodsCount().then(res => { cartGoodsCount().then(res => {
this.cartInfo = res.data.data; this.cartInfo = res.data.data;
}); });
}, },
toCart() { toCart() {
this.$router.push({ this.$router.push({
...@@ -147,18 +143,16 @@ computed: { ...@@ -147,18 +143,16 @@ computed: {
}); });
}, },
addCollect() { addCollect() {
collectAddOrDelete({valueId: this.itemId, type: 0}).then(res => { collectAddOrDelete({ valueId: this.itemId, type: 0 }).then(res => {
if(this.goods.userHasCollect === 1){ if (this.goods.userHasCollect === 1) {
this.goods.userHasCollect = 0 this.goods.userHasCollect = 0;
} } else {
else{ this.goods.userHasCollect = 1;
this.goods.userHasCollect = 1
this.$toast({ this.$toast({
message: '收藏成功', message: '收藏成功',
duration: 1500 duration: 1500
}); });
} }
}); });
}, },
getProductId(s1, s2) { getProductId(s1, s2) {
...@@ -169,8 +163,7 @@ computed: { ...@@ -169,8 +163,7 @@ computed: {
_.each(specification.valueList, specValue => { _.each(specification.valueList, specValue => {
if (specValue.id === s1) { if (specValue.id === s1) {
s1_name = specValue.value; s1_name = specValue.value;
} } else if (specValue.id === s2) {
else if (specValue.id === s2) {
s2_name = specValue.value; s2_name = specValue.value;
} }
}); });
...@@ -216,18 +209,16 @@ computed: { ...@@ -216,18 +209,16 @@ computed: {
message: '目前仅支持两规格', message: '目前仅支持两规格',
duration: 1500 duration: 1500
}); });
return return;
} } else if (_.has(data.selectedSkuComb, 's2')) {
else if (_.has(data.selectedSkuComb, 's2')) {
params.productId = this.getProductId( params.productId = this.getProductId(
data.selectedSkuComb.s1, data.selectedSkuComb.s1,
data.selectedSkuComb.s2 data.selectedSkuComb.s2
); );
} else {
params.productId = this.getProductIdByOne(data.selectedSkuComb.s1);
} }
else { cartAdd(params).then(() => {
params.productId = this.getProductIdByOne(data.selectedSkuComb.s1)
}
cartAdd(params).then(() => {
this.cartInfo = this.cartInfo + data.selectedNum; this.cartInfo = this.cartInfo + data.selectedNum;
this.$toast({ this.$toast({
message: '已添加至购物车', message: '已添加至购物车',
...@@ -248,22 +239,20 @@ computed: { ...@@ -248,22 +239,20 @@ computed: {
message: '目前仅支持两规格', message: '目前仅支持两规格',
duration: 1500 duration: 1500
}); });
return return;
} } else if (_.has(data.selectedSkuComb, 's2')) {
else if (_.has(data.selectedSkuComb, 's2')) {
params.productId = this.getProductId( params.productId = this.getProductId(
data.selectedSkuComb.s1, data.selectedSkuComb.s1,
data.selectedSkuComb.s2 data.selectedSkuComb.s2
); );
} else {
params.productId = this.getProductIdByOne(data.selectedSkuComb.s1);
} }
else { cartFastAdd(params).then(res => {
params.productId = this.getProductIdByOne(data.selectedSkuComb.s1) let cartId = res.data.data;
} setLocalStorage({ CartId: cartId });
cartFastAdd(params).then(res => { that.showSku = false;
let cartId = res.data.data; this.$router.push({ name: 'placeOrderEntity' });
setLocalStorage({CartId: cartId})
that.showSku = false;
this.$router.push({ name: 'placeOrderEntity'});
}); });
}, },
skuAdapter() { skuAdapter() {
...@@ -284,23 +273,23 @@ computed: { ...@@ -284,23 +273,23 @@ computed: {
this.skuGoods = { this.skuGoods = {
title: this.goods.info.name, title: this.goods.info.name,
picture: this.goods.info.picUrl picture: this.goods.info.picUrl
} };
}, },
setSkuList() { setSkuList() {
var sku_list = []; var sku_list = [];
_.each(this.goods.productList, v => { _.each(this.goods.productList, v => {
var sku_list_obj = {}; var sku_list_obj = {};
_.each(v.specifications, (specificationName, index) => { _.each(v.specifications, (specificationName, index) => {
sku_list_obj[ sku_list_obj['s' + (~~index + 1)] = this.findSpecValueIdByName(
's' + (~~index + 1) specificationName
] = this.findSpecValueIdByName(specificationName); );
});
sku_list_obj.price = v.price * 100;
sku_list_obj.stock_num = v.number;
sku_list.push(sku_list_obj);
}); });
sku_list_obj.price = v.price * 100;
sku_list_obj.stock_num = v.number;
sku_list.push(sku_list_obj);
});
return sku_list; return sku_list;
}, },
findSpecValueIdByName(name) { findSpecValueIdByName(name) {
...@@ -312,7 +301,7 @@ computed: { ...@@ -312,7 +301,7 @@ computed: {
return; return;
} }
}); });
if(id !== 0){ if (id !== 0) {
return; return;
} }
}); });
...@@ -329,7 +318,7 @@ computed: { ...@@ -329,7 +318,7 @@ computed: {
id: vv.id, id: vv.id,
name: vv.value, name: vv.value,
imUrl: vv.picUrl imUrl: vv.picUrl
}) });
}); });
specifications.push({ specifications.push({
...@@ -341,7 +330,7 @@ computed: { ...@@ -341,7 +330,7 @@ computed: {
return specifications; return specifications;
} }
}, },
components: { components: {
[Popup.name]: Popup, [Popup.name]: Popup,
...@@ -351,9 +340,9 @@ computed: { ...@@ -351,9 +340,9 @@ computed: {
[GoodsAction.name]: GoodsAction, [GoodsAction.name]: GoodsAction,
[GoodsActionButton.name]: GoodsActionButton, [GoodsActionButton.name]: GoodsActionButton,
[GoodsActionIcon.name]: GoodsActionIcon, [GoodsActionIcon.name]: GoodsActionIcon,
[popupProps.name]: popupProps [popupProps.name]: popupProps
} }
} };
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
...@@ -402,8 +391,10 @@ computed: { ...@@ -402,8 +391,10 @@ computed: {
.item_desc { .item_desc {
background-color: #fff; background-color: #fff;
p { /deep/ p {
padding: 0 10px; padding: 0 10px;
margin-block-start: 0 !important;
margin-block-end: 0 !important;
} }
/deep/ img { /deep/ img {
max-width: 100%; max-width: 100%;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment