news.js 2.8 KB

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