news-list.vue 5.0 KB

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