noticeList.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view style="padding:30rpx 0 0 0;height: 100vh;box-sizing: border-box;">
  3. <u-list @scrolltolower="scrolltolower" class="notice-ul" height="100%">
  4. <u-list-item v-for="data in noticeData" :key="data.noticeId">
  5. <view class="notice-area" @click="toNotice(data.noticeId)">
  6. <view class="area-header">
  7. <view style="width: 100%;display: flex;">
  8. <i class="iconfont icon-tongzhi"></i>
  9. <text
  10. style="width: 100%;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">
  11. {{data.noticeTitle}}
  12. </text>
  13. </view>
  14. <text class="up-date">发布时间:{{data.updateTime}}</text>
  15. </view>
  16. <view class="area-content">
  17. <rich-text
  18. :nodes="data.noticeContent"
  19. style="overflow: hidden;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 3;line-height: 68rpx;font-size: 32rpx;">
  20. </rich-text>
  21. </view>
  22. </view>
  23. </u-list-item>
  24. <u-list-item v-if="textShow">
  25. <view style="text-align: center;margin-bottom: 30rpx;">
  26. 已加载全部数据
  27. </view>
  28. </u-list-item>
  29. </u-list>
  30. </view>
  31. </template>
  32. <script>
  33. import { studyList } from '@/api/visitor.js'
  34. export default {
  35. data() {
  36. return {
  37. noticeData:[],
  38. page:1,
  39. total:6,
  40. pageSize:5,
  41. textShow:false
  42. };
  43. },
  44. methods:{
  45. toNotice(id){
  46. uni.navigateTo({
  47. url:'/pages/notice/notice?id='+id,
  48. })
  49. },
  50. handleDate(val){
  51. let date = new Date(val)
  52. let year = date.getFullYear()
  53. let month = date.getMonth()+1
  54. let day = date.getDate()
  55. return year+"-"+month+"-"+day;
  56. },
  57. scrolltolower(){
  58. if(Math.ceil(this.total/this.pageSize)<this.page){
  59. return;
  60. }else if(Math.ceil(this.total/this.pageSize)>=this.page){
  61. this.getNoticeList(this.page,this.pageSize)
  62. }
  63. },
  64. getNoticeList(x,y){
  65. const that = this
  66. uni.showLoading({
  67. icon:"none",
  68. title:"记载中"
  69. })
  70. try{
  71. studyList(x,y).then(res=>{
  72. uni.hideLoading()
  73. if(res.data.rows){
  74. if(that.page===1){
  75. that.noticeData = res.data.rows
  76. }else{
  77. that.noticeData = [...that.noticeData,...res.data.rows]
  78. }
  79. that.total = res.data.total
  80. that.page = that.page +1
  81. if(Math.ceil(that.total/that.pageSize)<that.page){
  82. that.textShow = true
  83. }else{
  84. that.textShow = false
  85. }
  86. }
  87. })
  88. }catch(err){
  89. uni.hideLoading()
  90. }
  91. }
  92. },
  93. onLoad() {
  94. this.getNoticeList(1,this.pageSize)
  95. }
  96. }
  97. </script>
  98. <style lang="scss">
  99. page{
  100. background-color: #f5f6fa;height: 100%;
  101. }
  102. .notice-area{
  103. background-color: #fff;
  104. margin: 0rpx 25rpx 30rpx 25rpx;
  105. padding: 30rpx 32rpx;
  106. border-radius: 30rpx;
  107. box-shadow: 0px 0px 21px 0px rgba(241, 241, 241, 1);
  108. .area-header{
  109. padding-bottom: 10rpx;
  110. font-size: $uni-title-font-size;
  111. font-weight: 500;
  112. color: #323232;
  113. i{
  114. font-size: 50rpx;
  115. padding-right: 10rpx;
  116. color: #228ff6;
  117. }
  118. .up-date{
  119. color: #9b9b9b;
  120. font-size: 26rpx;
  121. font-weight: 500;
  122. }
  123. }
  124. .area-content{
  125. padding-top: 10rpx;
  126. }
  127. }
  128. </style>