var shoppingCart = new Vue({
    el: "#shoppingCart",
    data: {
        userId: 0,
        userIdentity: '',
        userToken: '',
        listLoading: true,
        listData: [],
        invalidData: [],
        totalSize: 0,
        totalCount: 0,
        totalPrice: 0

    },
    computed: {

    },
    methods: {
        getCartLists: function () {
            var _self = this;
            if(this.userId ===0){return;}
            $.getJSON("/cart/list",{userId: this.userId}).done(function (r) {
                if (r.code === 0 && r.data) {
                    _self.listData = r.data.list;
                    _self.invalidData = r.data.invalid;
                    _self.totalSize = r.data.totalSize;
                    _self.totalCount = r.data.totalCount;
                    _self.totalPrice = r.data.totalPrice;
                }
                _self.listLoading = false;
            });
        },
        showThisLadder: function(event){
            if(isPC){return false;}
            var el = event.currentTarget;
            $(el).siblings('.ladder').show();
            fixedBody();
        },
        hideThisLadder: function(event){
            if(isPC){return false;}
            var el = event.currentTarget;
            $(el).parents('.ladder').hide();
            looseBody();
        },

    },
    created: function () {
        if(globalUserData){
            this.userId = globalUserData.userId;
            this.userIdentity = globalUserData.identity;
            this.userToken = globalUserData.token;
        }
        // 获取列表数据
        this.getCartLists();
    },
    mounted: function () {
        var _self = this;
        var minAwayBtm = $("footer").height();
        //处理滚动条控制底部提交fixed
        $(window).scroll(function() {
            var awayBtm = $(document).height() - $(window).scrollTop() - $(window).height();
            if(minAwayBtm <= awayBtm){
                $(".summaryWrap").addClass('fixed');
            }else{
                $(".summaryWrap").removeClass("fixed");
            }
        });
    }
});
