|
|
<template>
|
|
|
<div class="shopping-bag">
|
|
|
<div class="shopping-bag" @click="yoho.goShopingCart()">
|
|
|
<div class="background"></div>
|
|
|
|
|
|
<!--<button class="button control-button">-->
|
|
|
<!--<span @click="yoho.goShopingCart()" style="position: relative;">-->
|
|
|
<!--<span class="shopbag"></span>-->
|
|
|
<!--<span v-if="isApp && cartCount > 0" class="badge badge-tr">{{cartCount >= 100 ? '99+': cartCount}}</span>-->
|
|
|
<!--</span>-->
|
|
|
<!--</button>-->
|
|
|
<!--<button class="button control-button" @click="toggleFavorite()">-->
|
|
|
<!--<span v-if="entity.is_collect === 'Y' " class="icon icon-focused"></span>-->
|
|
|
<!--<span v-else class="focus"></span>-->
|
|
|
<!--</button>-->
|
|
|
<!--<button class="button button-solid add-to-cart"-->
|
|
|
<!--@click="showAddToCart()"-->
|
|
|
<!--:disabled="isSoldOut">-->
|
|
|
<!--<span v-if="isSoldOut">-->
|
|
|
<!--已售完-->
|
|
|
<!--</span>-->
|
|
|
<!--<span v-else="">-->
|
|
|
<!--加入购物袋-->
|
|
|
<!--</span>-->
|
|
|
<!--</button>-->
|
|
|
<div class="bag"></div>
|
|
|
<span v-if="cartCount > 0" class="number" :class="{over: cartCount > 99}">
|
|
|
{{cartCount > 99 ? '99+' : cartCount}}
|
|
|
</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
<style>
|
|
|
.shopping-bag {
|
|
|
position: fixed;
|
|
|
bottom: 100px;
|
|
|
left: 50px;
|
|
|
text-align: center;
|
|
|
|
|
|
.background {
|
|
|
width: 108px;
|
|
|
height: 108px;
|
|
|
opacity: .3;
|
|
|
border-radius: 50%;
|
|
|
background-color: #000;
|
|
|
}
|
|
|
|
|
|
.bag {
|
|
|
position: absolute;
|
|
|
top: 50%;
|
|
|
left: 50%;
|
|
|
width: 48px;
|
|
|
height: 48px;
|
|
|
margin-left: -24px;
|
|
|
margin-top: -26px;
|
|
|
background: resolve("product/shopping-bag.png");
|
|
|
background-size: contain;
|
|
|
}
|
|
|
|
|
|
.number {
|
|
|
position: absolute;
|
|
|
width: 36px;
|
|
|
height: 36px;
|
|
|
top: 0;
|
|
|
right: 0;
|
|
|
color: #fff;
|
|
|
font-size: 20px;
|
|
|
line-height: 36px;
|
|
|
text-align: center;
|
|
|
border-radius: 50%;
|
|
|
background-color: #d0021b;
|
|
|
|
|
|
&.over {
|
|
|
font-size: 14px;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</style>
|
|
|
<script>
|
...
|
...
|
@@ -36,36 +60,12 @@ |
|
|
module.exports = {
|
|
|
name: 'shopping-bag',
|
|
|
props: {
|
|
|
shareImg: String
|
|
|
cartCount: [Number, String]
|
|
|
},
|
|
|
data() {
|
|
|
return {};
|
|
|
},
|
|
|
methods: {
|
|
|
share() {
|
|
|
yoho.goShare({
|
|
|
title: this.shareTitle || '',
|
|
|
des: '我在BLK发现了一个不错的商品,快来看看吧!',
|
|
|
img: location.protocol + this.shareImg,
|
|
|
url: location.href
|
|
|
});
|
|
|
},
|
|
|
toggleFavorite: function() {
|
|
|
$.post('/product/favorite.json', {
|
|
|
operation: this.entity.is_collect === 'Y' ? 'remove' : 'add',
|
|
|
id: this.entity.product_id
|
|
|
}).then((result)=> {
|
|
|
if (result.code === 200) {
|
|
|
tip(this.entity.is_collect === 'Y' ? '取消收藏成功' : '收藏成功');
|
|
|
this.entity.is_collect = this.entity.is_collect === 'Y' ? 'N' : 'Y';
|
|
|
yoho.store.set('productReload', true);
|
|
|
} else if (result.code === 401) {
|
|
|
yoho.goLogin('', () => {
|
|
|
this.toggleFavorite();
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
return {
|
|
|
yoho: yoho
|
|
|
};
|
|
|
}
|
|
|
};
|
|
|
</script> |
...
|
...
|
|