<template>
	<view class="">
		<view class="cart u-flex u-row-center" @click="$u.route('/shopping/cart',{type:'redirectTo'})">
			<u-icon size="52rpx" class="icon" :name="staticUrl+'/img/cartico.png'"></u-icon>
			<u-badge type="error" max="99" :value="cartTotal" :absolute="true" :offset="[0,5]"></u-badge>
		</view>
	</view>
</template>

<script>
	export default {
		name:'cartfixed',
		data() {
			return {
				cartTotal:0,
				staticUrl:this.$commonConfig.staticUrl,
			}
		},
		onShow() {
		},
		onLoad() {
		},
		mounted(){
			this.getCartList()
		},
		methods: {
			getCartList(){
				this.$u.api.cartList().then(res=>{
					this.cartTotal = res.data.total;
					console.log('getCartList',res);
					}).catch(err=>{
					console.log('getCartList',err.data);
				})
			},
			addToCart(num){
				this.getCartList()
				// this.cartTotal += num;
				console.log('addToCart',num);
			}
		}
	}
</script>

<style lang="scss" scoped>
.cart{
	position: fixed;
	width: 100rpx;
	height: 100rpx;
	border-radius: 50%;
	right: 20rpx;
	bottom: 300rpx;
	background: #FFFFFF;
	box-shadow: 0px 0px 10px 0px rgba(0,0,0,0.12);
}
</style>
