news-list.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. <template>
  2. <view class="container club clearfix">
  3. <view class="club-main">
  4. <view v-if="isEmpty" class="empty-container">
  5. <image class="club-empty-image" src="https://img.caimei365.com/group1/M00/03/71/Cmis2F3wna6AY2ZjAABpmnBICH4247.png" mode="aspectFit"></image>
  6. <view class="txt">暂无公告~</view>
  7. </view>
  8. <view v-else class="club-list">
  9. <scroll-view scroll-y="true">
  10. <view class="list" v-for="(list, index) in newsList" :key="index" @tap='detail(list.id)'>
  11. <view class="list-left">
  12. <text class="iconfont icon-xiaochengxu"></text>
  13. <text class="txt">{{ list.title }}</text>
  14. </view>
  15. <view class="list-right">{{ list.creationtime }}</view>
  16. </view>
  17. <!--加载loadding-->
  18. <tui-loadmore :visible="loadding" :index="3" type="black" />
  19. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#ffffff'" :text='nomoreText' />
  20. <!--加载loadding-->
  21. </scroll-view>
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import authorize from '@/common/config/authorize.js'
  28. export default {
  29. components:{},
  30. data() {
  31. return {
  32. serviceProviderId:'',
  33. isShowClose:false,
  34. searchInputVal:'',
  35. isEmpty:false,
  36. listQuery:{
  37. pageNum:1,
  38. pageSize:20,
  39. },
  40. nomoreText: '上拉显示更多',
  41. hasNextPage:false,
  42. loadding: false,
  43. pullUpOn: true,
  44. pullFlag: true,
  45. allowDataStatus:true,
  46. wrapperHeight:'100%',
  47. scrollHeight:'',
  48. deleteAddressId:'',
  49. currPage:'',//当前页面
  50. prevPage:'',//上一个页面
  51. tabCurrentIndex:0,
  52. listStatus:1,
  53. newsList:[],
  54. isIphoneX:this.$store.state.isIphoneX,
  55. show_index:0,//控制显示那个组件
  56. }
  57. },
  58. onLoad(){
  59. this.setScrollHeight()
  60. this.GetNewsList()
  61. },
  62. methods: {
  63. setScrollHeight() {
  64. // 窗口高度 - 底部距离
  65. setTimeout(()=> {
  66. const query = wx.createSelectorQuery().in(this)
  67. query.selectAll('.add-btn').boundingClientRect()
  68. query.exec(res => {
  69. if(res[0][0]){
  70. let winHeight = this.$api.getWindowHeight(),
  71. eleTop = res[0][0].top - 1
  72. this.scrollHeight = eleTop
  73. }
  74. })
  75. }, 500)
  76. },
  77. GetNewsList(){
  78. this.CommonService.GetNewsList(this.listQuery).then(response =>{
  79. let data = response.data
  80. if(data.results && data.results.length > 0){
  81. this.isEmpty = false
  82. this.hasNextPage = data.hasNextPage
  83. this.newsList =data.results
  84. this.pullFlag = false
  85. setTimeout(()=>{this.pullFlag = true},500)
  86. if(this.hasNextPage){
  87. this.pullUpOn = false
  88. this.nomoreText = '上拉显示更多'
  89. }else{
  90. this.pullUpOn = true
  91. this.loadding = false
  92. this.nomoreText = '已至底部'
  93. }
  94. }else{
  95. this.isEmpty = true
  96. }
  97. }).catch(error =>{
  98. this.$util.msg(error.msg,2000)
  99. })
  100. },
  101. getOnReachBottomData(){
  102. this.listQuery.pageNum+=1
  103. this.CommonService.GetNewsList(this.listQuery).then(response =>{
  104. let data = response.data
  105. if(data.results && data.results.length > 0){
  106. this.hasNextPage = data.hasNextPage
  107. this.newsList = this.newsList.concat(data.results)
  108. this.pullFlag = false// 防上拉暴滑
  109. setTimeout(()=>{this.pullFlag = true},500)
  110. if(this.hasNextPage){
  111. this.pullUpOn = false
  112. this.nomoreText = '上拉显示更多'
  113. }else{
  114. this.pullUpOn = false
  115. this.loadding = false
  116. this.nomoreText = '已至底部'
  117. }
  118. }
  119. }).catch(error =>{
  120. this.$util.msg(error.msg,2000)
  121. })
  122. },
  123. detail(id){// 跳转公告详情
  124. this.$api.navigateTo(`/pages/service/news-detailes?id=${id}`)
  125. },
  126. },
  127. onReachBottom() {
  128. if(this.hasNextPage){
  129. this.loadding = true
  130. this.pullUpOn = true
  131. this.getOnReachBottomData()
  132. }
  133. },
  134. onPullDownRefresh() {
  135. setTimeout(() => {
  136. this.listQuery.pageNum = 1
  137. this.GetNewsList()
  138. uni.stopPullDownRefresh()
  139. }, 200)
  140. },
  141. onShow() {
  142. }
  143. }
  144. </script>
  145. <style lang='scss'>
  146. page {
  147. height: auto;
  148. }
  149. page,.container{
  150. /* padding-bottom: 120upx; */
  151. background: #FFFFFF;
  152. }
  153. .container{
  154. position: relative;
  155. }
  156. .club-main{
  157. width: 100%;
  158. height: auto;
  159. box-sizing: border-box;
  160. padding: 0 24rpx;
  161. .list{
  162. display: flex;
  163. align-items: center;
  164. width: 100%;
  165. height: 100rpx;
  166. line-height: 100rpx;
  167. background: #FFFFFF;
  168. position: relative;
  169. border-bottom: 1px solid #EBEBEB;
  170. .list-left{
  171. display: flex;
  172. flex: 8;
  173. .icon-xiaochengxu{
  174. font-size: $font-size-22;
  175. color: #999999;
  176. margin-right: 10rpx;
  177. }
  178. .txt{
  179. display: flex;
  180. flex: 1;
  181. font-size: $font-size-26;
  182. color: $text-color;
  183. text-overflow: ellipsis;
  184. overflow: hidden;
  185. display: -webkit-box;
  186. -webkit-line-clamp: 1;
  187. line-clamp: 1;
  188. -webkit-box-orient: vertical;
  189. }
  190. }
  191. .list-right{
  192. font-size: $font-size-24;
  193. color: #999999;
  194. text-align: right;
  195. }
  196. }
  197. }
  198. </style>