notice.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {extend name="public/container"}
  2. {block name="title"}消息通知{/block}
  3. {block name="content"}
  4. <div class="text-list" id="notice-list" v-cloak="">
  5. <section ref="bsDom">
  6. <ul style="-webkit-overflow-scrolling : touch;">
  7. <li v-for="item in noticelist.lists" :nid="item.id">
  8. <div class="admin">
  9. <span class="icon" v-if="item.is_see == 0"></span>
  10. {{item.user}}
  11. <span class="add_time">{{item.add_time}}</span>
  12. </div>
  13. <div class="text-wrapper">
  14. <div class="title">{{item.title}}</div>
  15. <div class="text-box">{{item.content}}</div>
  16. </div>
  17. <div class="link-more">
  18. <span class="more-btn" @click="seeNotice">查看全文>></span>
  19. </div>
  20. </li>
  21. <p class="loading-line" v-show="noticelist.loading == 1"><i></i><span>正在加载中</span><i></i></p>
  22. <p class="loading-line" v-show="noticelist.loading == 0 && noticelist.lastpage == 0"><i></i><span>加载更多</span><i></i></p>
  23. <p class="loading-line" v-show="noticelist.loading == 0 && noticelist.lastpage == 1"><i></i><span>没有更多了</span><i></i></p>
  24. </ul>
  25. </section>
  26. </div>
  27. <script type="text/javascript">
  28. (function(){
  29. require(['vue','axios','better-scroll','helper','store'],function(Vue,axios,BScroll,$h,storeApi){
  30. new Vue({
  31. el:"#notice-list",
  32. data:{
  33. noticelist: {lists: [],page: 0,lastpage: 0,loading: 0,limit:8},
  34. scroll:null
  35. },
  36. methods: {
  37. initNoticeList: function(){
  38. this.noticelist.lists = [];
  39. this.noticelist.page = 0;
  40. this.noticelist.lastpage = 0;
  41. this.noticelist.loading = 0;
  42. this.getNoticeList();
  43. },
  44. getNoticeList: function(){
  45. var that = this;
  46. if(that.noticelist.loading || that.noticelist.lastpage)return;
  47. that.noticelist.loading = 1;//开启加载开关
  48. storeApi.getNoticeList({
  49. page:that.noticelist.page,
  50. limit:that.noticelist.limit
  51. },function(res){
  52. that.noticelist.loading = 0;
  53. if(res.data.code == 200){
  54. var re_data = res.data.data;
  55. that.noticelist.lastpage = re_data.lastpage;
  56. that.noticelist.lists = that.noticelist.lists.concat(re_data.list);
  57. if(!re_data.lastpage)that.noticelist.page++;//如果不是最后一页当前页码加1
  58. that.$nextTick(function(){
  59. that.scroll.refresh();
  60. that.scroll.finishPullUp();
  61. });
  62. }
  63. },function(){that.noticelist.loading = false});
  64. },
  65. bScrollInit: function(){
  66. var that = this;
  67. this.$refs.bsDom.style.height = document.documentElement.clientHeight +'px';
  68. this.$refs.bsDom.style.overflow = 'hidden';
  69. this.scroll = new BScroll(this.$refs.bsDom,{click:true,probeType:1,cancelable:false,deceleration:0.005,snapThreshold:0.01});
  70. this.scroll.on('pullingUp',function(){
  71. that.noticelist.loading == 0 && that.getNoticeList();
  72. })
  73. },
  74. seeNotice: function(event){
  75. var element = $(event.target).parents("li");
  76. if(element.find(".admin .icon").length > 0){
  77. storeApi.seeNotice({
  78. nid:element.attr("nid")
  79. },function(res){
  80. if(res.data.code == 200)element.find(".admin .icon").remove();
  81. },function(){ $h.loadClear(); });
  82. this.initText(element);
  83. }else{
  84. this.initText(element);
  85. }
  86. },
  87. initText: function(element){
  88. var status = element.find(".text-box").hasClass('active');
  89. if(status){
  90. element.find(".text-box").removeClass("active");
  91. $(event.target).text("查看全文>>");
  92. $(event.target).css("color","#fc641c");
  93. this.scroll.refresh();
  94. }else{
  95. element.find(".text-box").addClass('active');
  96. $(event.target).text("点击收起>>");
  97. $(event.target).css("color","#1cb0fc");
  98. this.scroll.refresh();
  99. }
  100. }
  101. },
  102. mounted:function(){
  103. this.bScrollInit();
  104. this.initNoticeList();
  105. }
  106. })
  107. })
  108. })();
  109. </script>
  110. {/block}