海南旅游项目 前端仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

109 lines
2.4 KiB

4 years ago
  1. <template>
  2. <view>
  3. <view class="card" v-for="(item, index) in list" :key="index" @click="goDetails(item.id)">
  4. <view class="lf-row-between lf-m-b-20">
  5. <view class="lf-color-black lf-flex">
  6. <text class="hot" v-if="item.is_read == 0"></text>
  7. <!-- <text class="gray" v-else></text> -->
  8. <text class="lf-font-28">收到一条新消息</text>
  9. </view>
  10. <view class="lf-color-gray lf-font-22">{{item.created_at}} </view>
  11. </view>
  12. <view class="lf-font-24 lf-color-555">{{item.title}}</view>
  13. </view>
  14. <!-- 加载 -->
  15. <view class="loading-more">
  16. <text v-if="list.length" :class="{'loading-more-text': loadingClass}">{{ loadingText }}</text>
  17. <lf-nocontent v-else></lf-nocontent>
  18. </view>
  19. <!-- 回到顶部 -->
  20. <u-back-top :scroll-top="pageScrollTop" :custom-style="{background: 'rgba(51, 51 51, 0.3)'}"></u-back-top>
  21. </view>
  22. </template>
  23. <script>
  24. export default {
  25. data(){
  26. return {
  27. list: [],
  28. loadingClass: true,
  29. loadingText: '正在加载中',
  30. page: 1,
  31. isPage: false
  32. }
  33. },
  34. onShow(){
  35. this.getMessageList()
  36. },
  37. methods: {
  38. goDetails(id) {
  39. this.$url('/pages/message/detail?news_id='+id)
  40. },
  41. getMessageList() {
  42. this.$http(this.API.API_MESSAGELIST,{page: this.page}).then(res => {
  43. let isPage = res.data.next_page_url == null?false:true;
  44. this.isPage = isPage;
  45. if(!isPage){
  46. this.loadingClass = false;
  47. this.loadingText = '没有更多数据啦~';
  48. }
  49. if(this.page == 1){
  50. this.list = res.data.data;
  51. }else{
  52. this.list.push(...res.data.data);
  53. }
  54. uni.stopPullDownRefresh();
  55. console.log(this.list)
  56. }).catch(err => {
  57. })
  58. }
  59. },
  60. onReachBottom(){
  61. if(this.isPage){
  62. this.page = this.page + 1;
  63. this.getMessageList();
  64. }
  65. },
  66. onPullDownRefresh(){
  67. this.getMessageList()
  68. }
  69. }
  70. </script>
  71. <style>
  72. page{
  73. background-color: #F6F6F6;
  74. }
  75. </style>
  76. <style lang="scss" scoped="scoped">
  77. .card{
  78. margin: 0 auto;
  79. margin-top: 30rpx;
  80. width: 686rpx;
  81. height: max-content;
  82. background-color: #FFFFFF;
  83. padding: 20rpx;
  84. border-radius: 20rpx;
  85. box-sizing: border-box;
  86. .hot{
  87. display: inline-block;
  88. margin-right: 10rpx;
  89. width: 15rpx;
  90. height: 15rpx;
  91. border-radius: 50rpx;
  92. background-color: #FF0000;
  93. }
  94. .gray {
  95. display: inline-block;
  96. margin-right: 10rpx;
  97. width: 15rpx;
  98. height: 15rpx;
  99. border-radius: 50rpx;
  100. background-color: #999;
  101. }
  102. }
  103. .lf-font-22{
  104. font-size: 22rpx;
  105. }
  106. </style>