index.vue 3.0 KB

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