index.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <view class="news">
  3. <mescroll-body height="100%" ref="mescrollRef" bottom="0" @init="mescrollInit" @down="downCallback" :up="upOption" @up="upCallback">
  4. <view class="list">
  5. <view class="list-item" v-for="(item,index) in list" :key="index" @click="toDetail(item.id)">
  6. <view class="time">{{item.sendTime}}</view>
  7. <view class="new-card">
  8. <view class="news-cons">
  9. <view class="name">{{item.title}}</view>
  10. <view class="text ellipsis-2">
  11. <u-parse :content="item.msg" class="unscl ellipsis-2"></u-parse>
  12. </view>
  13. </view>
  14. <view class="news-detail">
  15. <view class="txt">查看详情</view>
  16. <re-image imgSrc="/retail/mall/icon_more.png" width="24" height="24"></re-image>
  17. </view>
  18. </view>
  19. </view>
  20. </view>
  21. <no-data :statusType="3" :top="0" tipsText="暂无数据" v-if="!isInit&&!list.length"></no-data>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import MescrollMixin from "@/plugins/mescroll/components/mescroll-uni/mescroll-mixins.js"
  27. import MescrollBody from '@/plugins/mescroll/components/mescroll-uni/mescroll-uni.vue'
  28. import { msgPage } from '@/apis/news.js'
  29. export default {
  30. components:{
  31. MescrollBody
  32. },
  33. data(){
  34. return{
  35. isInit: true, // 初次进入页面
  36. list: [],
  37. }
  38. },
  39. onShow(){
  40. if(!this.isInit){
  41. this.initPage()
  42. }
  43. },
  44. mixins: [MescrollMixin],
  45. methods: {
  46. // 初始化
  47. initPage() {
  48. this.mescroll.resetUpScroll()
  49. this.mescroll.scrollTo(0, 300)
  50. },
  51. async upCallback(page){
  52. const res = await msgPage({
  53. current:page.num,
  54. size:page.size,
  55. })
  56. if (res) {
  57. //设置列表数据
  58. if (page.num === 1) { //如果是第一页需手动制空列表
  59. this.list = res.records
  60. } else {
  61. this.list = this.list.concat(res.records) //追加新数据
  62. }
  63. this.mescroll.endSuccess(res.records.length, res.total > this.list.length)
  64. }else{
  65. this.mescroll.endErr()
  66. }
  67. uni.hideLoading()
  68. this.isInit = false
  69. },
  70. // 跳转到信息详情
  71. toDetail(id){
  72. uni.navigateTo({
  73. url:'/pages/system/index?id=' + id
  74. })
  75. }
  76. },
  77. }
  78. </script>
  79. <style lang="scss" scoped>
  80. .news{
  81. padding: 0 20rpx;
  82. .list{
  83. // height: 100%;
  84. .list-item{
  85. margin-top: 48rpx;
  86. .time{
  87. text-align: center;
  88. font-size: 26rpx;
  89. margin-bottom: 20rpx;
  90. color: #989897;
  91. }
  92. .new-card{
  93. background-color: #fff;
  94. border-radius: 16rpx;
  95. .news-cons{
  96. padding: 32rpx 32rpx 24rpx;
  97. border-bottom: 2rpx solid #F0F2F4;
  98. .name{
  99. font-size: 32rpx;
  100. font-weight: 500;
  101. color: #363531;
  102. margin-bottom: 16rpx;
  103. }
  104. .text{
  105. font-size: 28rpx;
  106. color: #7C7C7B;
  107. overflow: hidden;
  108. .unscl{
  109. overflow: hidden;
  110. }
  111. }
  112. }
  113. .news-detail{
  114. display: flex;
  115. justify-content: space-between;
  116. align-items: center;
  117. padding: 24rpx 26rpx 32rpx 22rpx;
  118. .txt{
  119. font-size: 28rpx;
  120. font-weight: 400;
  121. color: #363531;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. }
  128. </style>