1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <template>
- <view class="cart-fix" @click="toCart">
- <u-image width="70rpx" height="70rpx" src="/static/cart.png"></u-image>
- <u-badge absolute :offset="[15,10]" type="error" :count="count"></u-badge>
- </view>
- </template>
- <script>
- export default {
- computed: {
- count() {
- let arr = this.$store.state.vuex_cartList
- let count = 0
- arr.map(item=>{
- count = count + item.shoppingCartGoodsList.length
- })
- return count
- },
- },
- methods: {
- toCart() {
- if(this.count > 0){
- uni.navigateTo({
- url:"/pages/cart/cart"
- })
- }else{
- uni.showToast({
- icon:'none',
- title:'购物车是空的,请先加入商品'
- })
- }
- }
- },
- }
- </script>
- <style lang="scss">
- .cart-fix{
- position: fixed;
- z-index: 100000;
- background: rgba($color: #ffffff, $alpha: 0.7);
- padding: 10upx;
- border-radius: 100%;
- bottom: 40%;
- right: 2%;
- box-shadow: 3upx 3upx 8upx #ccc;
- }
- </style>
|