NoticeList.cshtml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. 
  2. @{
  3. ViewBag.Title = "NoticeList";
  4. Layout = "~/Views/MobileProblem/_APPMain.cshtml";
  5. }
  6. <style>
  7. .mui-table h4, .mui-table h5, .mui-table .mui-h5, .mui-table .mui-h6, .mui-table p {
  8. margin-top: 0;
  9. }
  10. .mui-table h4 {
  11. line-height: 21px;
  12. font-weight: 500;
  13. }
  14. .mui-table .oa-icon {
  15. position: absolute;
  16. right: 0;
  17. bottom: 0;
  18. }
  19. .mui-table .oa-icon-star-filled {
  20. color: #f14e41;
  21. }
  22. h5,.mui-h5{
  23. font-size:11px
  24. }
  25. .mui-table-view:before,.mui-table-view:after{
  26. background-color:transparent
  27. }
  28. </style>
  29. <div id="vue" v-cloak>
  30. <header class="mui-bar mui-bar-nav" >
  31. <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" style="color:#ffffff"></a>
  32. <h1 class="mui-title" style="color:white">公告列表</h1>
  33. </header>
  34. <div class="mui-content mui-scroll-wrapper" id="pullrefresh">
  35. <div class="mui-scroll">
  36. <div style="margin-top:10px" >
  37. <ul class="mui-table-view mui-table-view-striped mui-table-view-condensed">
  38. <li v-for="item in NoticeData" class="mui-table-view-cell" v-on:click="Deatil(item.ID)">
  39. <div class="mui-table" >
  40. <div class="mui-table-cell mui-col-xs-10">
  41. <h4 class="mui-ellipsis">{{item.标题}}</h4>
  42. <h5>发布人:{{item.添加人}}</h5>
  43. <p class="mui-h6 mui-ellipsis" >{{item.内容}}</p>
  44. </div>
  45. <div class="mui-table-cell mui-col-xs-2 mui-text-right">
  46. <span class="mui-h5">{{item.发布时间小时}}</span>
  47. </div>
  48. </div>
  49. </li>
  50. </ul>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <script>
  56. var vm = new Vue({
  57. el: '#vue',
  58. data: {
  59. NoticeData: [],
  60. Pages: 0
  61. },
  62. watch: {
  63. },
  64. methods: {
  65. ///进入详细页面
  66. Deatil: function (id) {
  67. window.location.href = '/MobileProblem/NoticesDetail/' + id
  68. },
  69. pullupRefresh: function () {
  70. var that = this;
  71. that.Pages++;
  72. setTimeout(function () {
  73. var self = mui('#pullrefresh').pullRefresh(); //参数为true代表没有更多数据了。
  74. mui.get('/Notice/HomeGetList',
  75. {
  76. SelectConditon: that.searchText,
  77. page: that.Pages,
  78. rows: 7
  79. }, function (data) {
  80. //获得服务器响应
  81. var info = data.rows;
  82. if (info.length == 0) {//当datas.length为0时,表示没有数据了
  83. self.endPullupToRefresh(true);//当为true时,底部出现没有更多数据,并且不能滑动
  84. } else {
  85. for (var di in info) {
  86. var dd = info[di];
  87. dd.内容 = that.IgnoHtml(dd.内容)
  88. dd.发布时间小时 = that.GetTime(dd.发布时间小时)
  89. }
  90. that.NoticeData = info
  91. self.endPullupToRefresh(false);//当为false或空时,底部出现正在加载,滑动到下一页
  92. }
  93. }, 'json');
  94. }, 1500);
  95. },
  96. IgnoHtml(data) {
  97. var arrEntities = {
  98. 'lt': '<',
  99. 'gt': '>',
  100. 'nbsp': ' ',
  101. 'amp': '&',
  102. 'quot': '"'
  103. };
  104. var t = data.replace(/<[^>]+>/g, "").replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) {
  105. return arrEntities[t];
  106. });
  107. return t
  108. },
  109. GetTime(val) {
  110. if (val < 1) {
  111. return parseInt(val * 60) + "分钟前";
  112. } else if (val < 24) {
  113. return val + "小时前";
  114. } else if (48 > val > 24) {
  115. return "昨天";
  116. } else {
  117. return parseInt(val / 24) + '天' + '前';
  118. }
  119. }
  120. },
  121. mounted: function () {
  122. var that = this;
  123. mui.init({
  124. pullRefresh: {
  125. container: '#pullrefresh',
  126. up: {
  127. auto: true,
  128. contentrefresh: '正在加载公告...',
  129. callback: that.pullupRefresh,
  130. }
  131. }
  132. });
  133. mui(".mui-scroll").on('tap', '.mui-table-view-cell', function (event) {
  134. this.click();
  135. });
  136. }
  137. })
  138. </script>