messageList.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <view class="">
  3. <view class="navbar">
  4. <view class="back">
  5. <text class="iconfont icon-fanhui " @click="backLast()"></text>
  6. </view>
  7. <text>通知公告</text>
  8. </view>
  9. <view class="message-list">
  10. <view class="item" v-for="(item,index) in list" :key="index">
  11. <view class="message-time">
  12. {{item.created_at}}
  13. </view>
  14. <view class="list">
  15. <view class="title">
  16. {{item.title}}
  17. </view>
  18. <view class="content">
  19. {{item.body}}
  20. </view>
  21. </view>
  22. </view>
  23. <view class="kong" v-show="isShow">
  24. <image src="../../static/images/kong.png" mode=""></image>
  25. <view class="text">
  26. 暂无通知公告~
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import navBar from '../../components/navBar/navbar.vue';
  34. var app = getApp()
  35. export default {
  36. components:{
  37. navBar
  38. },
  39. data() {
  40. return {
  41. list: [],
  42. page:1,
  43. isShow:false
  44. }
  45. },
  46. onReachBottom() {
  47. console.log('触底时间')
  48. uni.showLoading()
  49. this.page++;
  50. let params = {
  51. id: uni.getStorageSync('userInfo').id,
  52. page: this.page
  53. }
  54. app.request('/messages', params, 'get').then(res => {
  55. let data = res.data.data.data
  56. this.list = this.list.concat(data)
  57. uni.hideLoading()
  58. if (data.length == 0) {
  59. uni.showToast({
  60. title: '到底了~',
  61. icon: 'none'
  62. })
  63. }
  64. })
  65. },
  66. created() {
  67. let params = {
  68. id: uni.getStorageSync('userInfo').id,
  69. }
  70. app.request('/messages', params, 'get').then(res => {
  71. console.log(res)
  72. this.list = res.data.data.data
  73. if(this.list.length==0){
  74. this.isShow=true
  75. }
  76. })
  77. },
  78. methods:{
  79. backLast:function(){
  80. console.log(this.url)
  81. uni.reLaunch({
  82. url:'./index'
  83. })
  84. },
  85. }
  86. }
  87. </script>
  88. <style lang="scss">
  89. .navbar {
  90. font-size: 32upx;
  91. height: 100upx;
  92. line-height: 100upx;
  93. color: #888888;
  94. position: relative;
  95. position: fixed;
  96. top: 0;
  97. z-index: 9999999;
  98. width: 100%;
  99. background-color: #FFFFFF;
  100. text-align: center;
  101. border-bottom: solid 2upx #EFF1F6;
  102. .back {
  103. height: 100upx;
  104. width: 100upx;
  105. text-align: center;
  106. // background-color: #007AFF;
  107. position: absolute;
  108. float: left;
  109. left: 0upx;
  110. font-size: 32upx;
  111. }
  112. }
  113. page {
  114. background-color: #f4f4f4;
  115. .message-list {
  116. width: 90%;
  117. margin: 0 auto;
  118. padding-top: 100upx;
  119. .item {
  120. margin-top: 70upx;
  121. }
  122. .message-time {
  123. font-size: 26upx;
  124. height: 50upx;
  125. width: 300upx;
  126. text-align: center;
  127. margin: 0 auto;
  128. border-radius: 30upx;
  129. margin-bottom: 30upx;
  130. line-height: 50upx;
  131. color: #FFFFFF;
  132. background-color: #c8c8c8;
  133. }
  134. .list {
  135. font-size: 28upx;
  136. background-color: #FFFFFF;
  137. padding: 30upx;
  138. border-radius: 10upx;
  139. margin-top: 20upx;
  140. margin-bottom: 50upx;
  141. .title {
  142. font-weight: bold;
  143. margin-bottom: 20upx;
  144. }
  145. .content {
  146. color: #afafaf;
  147. }
  148. }
  149. }
  150. .kong {
  151. margin-top: 30%;
  152. text-align: center;
  153. image {
  154. width: 300upx;
  155. height: 300upx;
  156. }
  157. .text {
  158. font-size: 34upx;
  159. margin-top: 30upx;
  160. color: #e61916;
  161. }
  162. }
  163. }
  164. </style>