myLike.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <view>
  3. <u-navbar title="我的点赞" >
  4. </u-navbar>
  5. <view class="main">
  6. <template v-for="(item,i) in list">
  7. <view class="like-box" v-if="item" @click="ckInfo(item.id)" :key="i">
  8. <view class="content">
  9. <view class="title">
  10. {{item.title}}
  11. </view>
  12. <view class="else">
  13. <view class="classify">
  14. {{item.typeName}}
  15. </view>
  16. <view class="date">
  17. {{substrDate(item.createTime)}}
  18. </view>
  19. </view>
  20. </view>
  21. <view class="picture">
  22. <img v-if="item.pic" :src="item.pic" alt="">
  23. <img v-else src="@/assets/img/default_img.png" alt="">
  24. </view>
  25. </view>
  26. <view class="like-box" v-else :key="i">
  27. <view class="content">
  28. <view class="title">
  29. <span style="color: red;">当前新闻已被删除</span>
  30. </view>
  31. <view class="else">
  32. <view class="classify">
  33. </view>
  34. <view class="date">
  35. </view>
  36. </view>
  37. </view>
  38. <view class="picture">
  39. <img src="@/assets/img/default_img.png" alt="">
  40. </view>
  41. </view>
  42. </template>
  43. </view>
  44. <u-divider v-if="list.length==recordsTotal"
  45. :isnone="list.length==0" nonetext="你还没有参与点赞"
  46. bg-color="#F2F4F4" border-color="#CFD2D5">已经到底了</u-divider>
  47. </view>
  48. </template>
  49. <script>
  50. import * as API from '@/apis/pagejs/news.js'
  51. export default {
  52. data() {
  53. return {
  54. list:[],
  55. listForm:{
  56. pageIndex:1,
  57. pageSize:20,
  58. },
  59. recordsTotal:0,
  60. }
  61. },
  62. onLoad(op){
  63. this.getList()
  64. },
  65. onReachBottom() {
  66. if (this.list.length < this.recordsTotal) {
  67. this.myLoadmore();
  68. }
  69. },
  70. methods: {
  71. ckInfo(id){
  72. var url="/pages/news/articleDetails?id="+id;
  73. uni.navigateTo({
  74. url:url
  75. })
  76. },
  77. myLoadmore(){
  78. this.listForm.pageIndex += 1;
  79. this.getList();
  80. },
  81. getList(){
  82. uni.showLoading({
  83. title: "加载中",
  84. mask: true,
  85. })
  86. API.newsLikespageList(this.listForm).then((res) => {
  87. uni.hideLoading();
  88. this.list = [
  89. ...this.list,
  90. ...res.data.data
  91. ];
  92. this.recordsTotal = res.data.recordsTotal;
  93. }).catch(error => {
  94. uni.showToast({
  95. title: error,
  96. icon: "none"
  97. })
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .main{
  105. padding: 24rpx 32rpx;
  106. .like-box{
  107. border-radius: 8px;
  108. background-color: rgba(255, 255, 255, 1);
  109. display: flex;
  110. justify-content: space-between;
  111. padding: 24rpx;
  112. margin-bottom: 24rpx;
  113. .content{
  114. width: 390rpx;
  115. display: flex;
  116. flex-direction:column;
  117. justify-content: space-between;
  118. .title{
  119. color: rgba(51, 51, 51, 1);
  120. font-size: 32rpx;
  121. line-height: 46rpx;
  122. font-weight: bold;
  123. font-family: 'Medium';
  124. }
  125. .else{
  126. display: flex;
  127. justify-content: space-between;
  128. color: rgba(119, 119, 119, 1);
  129. font-size: 24rpx;
  130. font-family: 'Regular';
  131. }
  132. }
  133. .picture{
  134. width: 224rpx;
  135. height: 172rpx;
  136. border-radius: 5px;
  137. overflow: hidden;
  138. img{
  139. width: 100%;
  140. height: 100%;
  141. }
  142. }
  143. }
  144. }
  145. </style>