wuxw
2019-04-29 0894b9328ae1c11146175b492ae348bbd4b13404
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/**
    分页组件
**/
(function(vc){
    vc.extends({
        data:{
            paginationInfo:{
                total:0,
                currentPage:1
            }
        },
        _initEvent:function(){
             vc.component.$on('pagination_info_event',function(_paginationInfo){
                    vc.component.paginationInfo.total = _paginationInfo.total;
                    vc.component.paginationInfo.currentPage = _paginationInfo.currentPage;
                });
 
             vc.on('pagination','init',function(_paginationInfo){
                 vc.component.paginationInfo.total = _paginationInfo.total;
                 vc.component.paginationInfo.currentPage = _paginationInfo.currentPage;
             });
        },
        methods:{
            previous:function(){
                // 当前页为 1时 不触发消息
                if(vc.component.paginationInfo.currentPage <=1){
                    return;
                }
                vc.component.paginationInfo.currentPage = vc.component.paginationInfo.currentPage -1;
                vc.component.$emit('pagination_page_event',vc.component.paginationInfo.currentPage);
            },
            next:function(){
                if(vc.component.paginationInfo.currentPage >=vc.component.paginationInfo.total){
                    return ;
                }
                vc.component.paginationInfo.currentPage = vc.component.paginationInfo.currentPage +1;
                vc.component.$emit('pagination_page_event',vc.component.paginationInfo.currentPage);
 
            },
            current:function(_page){
                if(_page > vc.component.paginationInfo.total){
                    return ;
                }
                vc.component.paginationInfo.currentPage = _page;
 
                vc.component.$emit('pagination_page_event',vc.component.paginationInfo.currentPage);
 
            }
        }
    });
})(window.vc);