home.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <template>
  2. <view class="uni-flex uni-column">
  3. <view class="uni-flex uni-flex-item articles uni-list">
  4. <view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(n,key) in news" :key="key" @click="goNew(n)">
  5. <view class="uni-media-list">
  6. <image class="uni-media-list-logo" lazy-load mode="widthFix" :src="n.pic"></image>
  7. <view class="uni-media-list-body">
  8. <view class="uni-media-list-text-top uni-ellipsis">{{n.title}}</view>
  9. <view class="uni-media-list-text-bottom">
  10. <text>[{{n.class}}] </text>
  11. <text>{{n.createDate}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <!-- 1 -->
  18. <load-more :loadingType="loadingType" :contentText="contentText"></load-more>
  19. </view>
  20. </template>
  21. <script>
  22. // 2
  23. import loadMore from '@/components/uni-load-more.vue';
  24. // 3
  25. var index;
  26. export default {
  27. data() {
  28. return {
  29. // --4
  30. type: 0,
  31. news: [],
  32. loadingType: 0,
  33. contentText: {
  34. contentdown: "上拉显示更多",
  35. contentrefresh: "正在加载...",
  36. contentnomore: "没有更多数据了"
  37. },
  38. // --4
  39. };
  40. },
  41. onPullDownRefresh() {
  42. this.getData();
  43. setTimeout(function() {
  44. uni.stopPullDownRefresh();
  45. }, 1000);
  46. },
  47. onLoad() {
  48. // 5
  49. index = 1;
  50. this.getData();
  51. },
  52. methods: {
  53. // 6
  54. getData() {
  55. if (this.loadingType !== 0) {
  56. return;
  57. }
  58. this.loadingType = 1;
  59. uni.request({
  60. url: this.webUrl + 'News',
  61. method: 'POST',
  62. data: {
  63. pageIndex: index,
  64. type: this.type
  65. },
  66. header: {
  67. 'content-type': 'application/x-www-form-urlencoded'
  68. },
  69. success: res => {
  70. if (res.data.result.uniArticles.length > 0) {
  71. this.news = this.news.concat(res.data.result.uniArticles);
  72. } else {
  73. this.loadingType = 2;
  74. return;
  75. }
  76. if (index == parseInt(res.data.result.pages)) {
  77. this.loadingType = 2;
  78. return;
  79. } else {
  80. this.loadingType = 0;
  81. }
  82. index++;
  83. },
  84. fail: () => {},
  85. complete: () => {}
  86. });
  87. },
  88. },
  89. onReachBottom() {
  90. // 7
  91. this.getData();
  92. },
  93. components: {
  94. // 8
  95. loadMore
  96. }
  97. }
  98. </script>
  99. <style>
  100. .home .news-center .contentsItem {
  101. width: 100%;
  102. border-top: 1px solid #e2e2e2;
  103. }
  104. .home .news-center .item-contents {
  105. padding: 50upx 45upx;
  106. }
  107. .home .news-center .item-contents .item-contents-wrap {
  108. position: relative;
  109. margin: 0 auto;
  110. width: 660upx;
  111. height: 380upx;
  112. display: block;
  113. }
  114. .home .news-center .item-contents image {
  115. margin: 0 auto;
  116. width: 660upx;
  117. height: 380upx;
  118. display: block;
  119. }
  120. .home .news-center .item-contents .contentsMessage {
  121. margin: 0 auto;
  122. width: 660upx;
  123. box-sizing: border-box;
  124. padding: 25upx 20upx;
  125. background: #e9e9e9;
  126. }
  127. .home .news-center .contentsMessage .Msgs {
  128. width: 620upx;
  129. }
  130. .home .news-center .contentsMessage .Msgs .lfMsg {
  131. font-size: 26upx;
  132. /* #ifdef H5 */
  133. font-size: 26upx;
  134. /* #endif */
  135. color: #505050;
  136. width: 490upx;
  137. overflow: hidden;
  138. text-overflow: ellipsis;
  139. white-space: nowrap;
  140. }
  141. .home .news-center .contentsMessage .lfMsgs-wrap{
  142. margin-top: 10upx;
  143. }
  144. .home .news-center .contentsMessage .lfMsgs {
  145. font-size: 24upx;
  146. /* #ifdef H5 */
  147. font-size: 24upx;
  148. /* #endif */
  149. color: #909090;
  150. text-spacing: 5upx;
  151. }
  152. .home .news-center .contentsMessage .Msgs .rtMsg {
  153. font-size: 26upx;
  154. /* #ifdef H5 */
  155. font-size: 26upx;
  156. /* #endif */
  157. color: #909090;
  158. justify-content: flex-end;
  159. }
  160. .home .news-center .contentsMessage .Msgs .Msgs-artitle {
  161. width: 100%;
  162. margin-top: 10upx;
  163. margin-bottom: 30upx;
  164. font-size: 26upx;
  165. /* #ifdef H5 */
  166. font-size: 26upx;
  167. /* #endif */
  168. color: #909090;
  169. overflow: hidden;
  170. text-overflow: ellipsis;
  171. white-space: nowrap;
  172. }
  173. .image {
  174. position: absolute;
  175. }
  176. </style>