news.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. var app = new Vue({
  2. el: '#app',
  3. data: {
  4. submitStatus: false,
  5. // 幻灯片列表
  6. advertList: [],
  7. // 资讯列表
  8. noticeList: [],
  9. // 用户信息
  10. memberInfo: {},
  11. },
  12. created: function () {
  13. this.getMemberInfo();
  14. this.getAdvertList();
  15. this.getNoticeList();
  16. },
  17. updated: function(){
  18. // 顶部轮播图
  19. var mySwiper = new Swiper ('.swiper-container', {
  20. // 如果需要分页器
  21. autoplay:true,
  22. pagination: {
  23. el: '.swiper-pagination'
  24. }
  25. });
  26. // 新闻资讯
  27. var swiper = new Swiper('.notice-box', {
  28. autoplay:true,
  29. delay: 1000,
  30. direction: 'vertical'
  31. });
  32. },
  33. methods: {
  34. // 获取用户信息
  35. getMemberInfo: function(){
  36. var _this = this;
  37. $.post('/weixin/member/getMemberInfo', {}, function (res) {
  38. if (res.code == 'success') {
  39. _this.memberInfo = res.data
  40. }else if(res.code == 'login'){
  41. login(res.data.url);
  42. }
  43. }, "json");
  44. },
  45. // 获取幻灯片,列表
  46. getAdvertList: function(){
  47. var _this = this;
  48. $.showLoading("数据加载中");
  49. $.post('/weixin/index/getAdvertList', {type:2}, function (res) {
  50. $.hideLoading();
  51. if (res.code == 'success') {
  52. _this.advertList = res.data
  53. }else if(res.code == 'login'){
  54. login(res.data.url);
  55. }
  56. }, "json");
  57. },
  58. // 获取资讯列表
  59. getNoticeList: function(){
  60. var _this = this;
  61. $.showLoading("数据加载中");
  62. $.post('/weixin/news/getNoticeList', {pageSize: 50}, function (res) {
  63. $.hideLoading();
  64. if (res.code == 'success') {
  65. _this.noticeList = res.data
  66. }else if(res.code == 'login'){
  67. login(res.data.url);
  68. }
  69. }, "json");
  70. }
  71. }
  72. });