; var orderPage = new Vue({ el: "#beansPage", data: { isRequset:false, noMore: false, tabsListIndex:0, listQuery:{ pageNum:1, pageSize:20 }, listRecord: 0, pageInput: '1', modelType:0, newsList:[], }, computed: { pageTotal: function () { var total = Math.ceil(this.listRecord / this.listQuery.pageSize); return total > 0 ? total : 1; }, showPageBtn: function () { var total = Math.ceil(this.listRecord / this.listQuery.pageSize); total = total > 0 ? total : 1; var index = this.listQuery.pageNum, arr = []; if (total <= 6) { for (var i = 1; i <= total; i++) { arr.push(i); } return arr; } if (index <= 3) return [1, 2, 3, 4, 5, 0, total]; if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total]; return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total]; } }, methods: { toPagination: function (pageNum) {//点击切换分页 if (pageNum <= this.pageTotal) { this.listQuery.pageNum = pageNum; this.GetNewsList(); } }, checkNum: function () {//输入跳转分页 if (this.pageInput > this.pageTotal) { this.pageInput = this.pageTotal; } else if (this.pageInput < 1) { this.pageInput = 1; } }, GetNewsList:function(){//查询优惠券列表 var _self = this; PublicApi.GetNewsList(_self.listQuery,function (response) { if(response.code == 0){ var data = response.data; if( data.results && data.results.length>0) { _self.newsList = []; _self.newsList = data.results; _self.listRecord = data.totalRecord; }else{ _self.newsList = []; _self.newsList = data.results; _self.listRecord = data.totalRecord; } _self.isRequset = false; }else{ CAIMEI.Alert(response.msg, '确定', false); } }) }, hanldDetails:function (id){// 跳转公告详情 var _self = this; window.open('/news/details.html?id='+id); } }, mounted: function () { this.GetNewsList(); } });