news.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ;
  2. var orderPage = new Vue({
  3. el: "#beansPage",
  4. data: {
  5. isRequset:false,
  6. noMore: false,
  7. tabsListIndex:0,
  8. listQuery:{
  9. pageNum:1,
  10. pageSize:20
  11. },
  12. listRecord: 0,
  13. pageInput: '1',
  14. modelType:0,
  15. newsList:[],
  16. },
  17. computed: {
  18. pageTotal: function () {
  19. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  20. return total > 0 ? total : 1;
  21. },
  22. showPageBtn: function () {
  23. var total = Math.ceil(this.listRecord / this.listQuery.pageSize);
  24. total = total > 0 ? total : 1;
  25. var index = this.listQuery.pageNum, arr = [];
  26. if (total <= 6) {
  27. for (var i = 1; i <= total; i++) {
  28. arr.push(i);
  29. }
  30. return arr;
  31. }
  32. if (index <= 3) return [1, 2, 3, 4, 5, 0, total];
  33. if (index >= total - 2) return [1, 0, total - 4, total - 3, total - 2, total - 1, total];
  34. return [1, 0, index - 2, index - 1, index, index + 1, index + 2, 0, total];
  35. }
  36. },
  37. methods: {
  38. toPagination: function (pageNum) {//点击切换分页
  39. if (pageNum <= this.pageTotal) {
  40. this.listQuery.pageNum = pageNum;
  41. this.GetNewsList();
  42. }
  43. },
  44. checkNum: function () {//输入跳转分页
  45. if (this.pageInput > this.pageTotal) {
  46. this.pageInput = this.pageTotal;
  47. } else if (this.pageInput < 1) {
  48. this.pageInput = 1;
  49. }
  50. },
  51. GetNewsList:function(){//查询优惠券列表
  52. var _self = this;
  53. PublicApi.GetNewsList(_self.listQuery,function (response) {
  54. if(response.code == 0){
  55. var data = response.data;
  56. if( data.results && data.results.length>0) {
  57. _self.newsList = [];
  58. _self.newsList = data.results;
  59. _self.listRecord = data.totalRecord;
  60. }else{
  61. _self.newsList = [];
  62. _self.newsList = data.results;
  63. _self.listRecord = data.totalRecord;
  64. }
  65. _self.isRequset = false;
  66. }else{
  67. CAIMEI.Alert(response.msg, '确定', false);
  68. }
  69. })
  70. },
  71. hanldDetails:function (id){// 跳转公告详情
  72. var _self = this;
  73. window.open('/news/details.html?id='+id);
  74. }
  75. },
  76. mounted: function () {
  77. this.GetNewsList();
  78. }
  79. });