collection.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view style="width: 100;height: 100%;background-color: #f6f6f6;padding: 20rpx 30rpx;">
  3. <view class="list" v-for="item,index in listArray" :key='index' @click="open(item.article.id,item.article.title)">
  4. <view class="text">
  5. <view class="title">{{item.article.title}}</view>
  6. <view class="type">{{item.article.created_at}}</view>
  7. </view>
  8. <view class="img">
  9. <image :src="item.article.banner_url" class="i" mode="aspectFit"></image>
  10. </view>
  11. </view>
  12. <u-empty text="暂无数据" mode="order" :show="show" margin-top="250"></u-empty>
  13. </view>
  14. </template>
  15. <script>
  16. export default {
  17. data() {
  18. return {
  19. listArray: [],
  20. pageindex: 1,
  21. show: false
  22. }
  23. },
  24. mounted() {
  25. this.getcollectionList()
  26. },
  27. methods: {
  28. //点击文章
  29. open(id, title) {
  30. uni.navigateTo({
  31. url: '/pages/common_tools/collection/collection_details?id=' + id + '&title=' + title
  32. // url: '/pages/customer/customer-datails?n=' + n
  33. })
  34. },
  35. getcollectionList: async function() {
  36. let res = await this.$request.post("/api/v1/collection/collectList", {
  37. page: this.pageindex,
  38. type: 2
  39. })
  40. console.log(res)
  41. if (res.status == 0) {
  42. if (this.pageindex > res.data.last_page) {
  43. uni.showToast({
  44. title: "没有更多了",
  45. icon: "none"
  46. })
  47. } else {
  48. this.listArray = this.listArray.concat(res.data.data)
  49. this.pageindex++
  50. }
  51. }
  52. if (this.listArray.length == 0) {
  53. this.show = true
  54. } else {
  55. this.show = false
  56. }
  57. }
  58. },
  59. }
  60. </script>
  61. <style lang="scss">
  62. //每一条文章
  63. .list {
  64. margin-bottom: 20rpx;
  65. border-radius: 12rpx;
  66. background-color: #ffffff;
  67. padding: 25rpx 20rpx;
  68. display: flex;
  69. box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.04);
  70. .text {
  71. width: 60%;
  72. height: 165rpx;
  73. padding-right: 25rpx;
  74. .title {
  75. height: 80%;
  76. font-size: 30rpx;
  77. font-weight: bold;
  78. // overflow: hidden; //超出一行文字自动隐藏
  79. // text-overflow: ellipsis; //文字隐藏后添加省略号
  80. // white-space: nowrap; //强制不换行
  81. }
  82. .type {
  83. font-size: 26rpx;
  84. color: #666666;
  85. font-weight: 400;
  86. height: 20%;
  87. bottom: 0;
  88. }
  89. }
  90. .img {
  91. width: 40%;
  92. height: 100%;
  93. .i {
  94. width: 272rpx;
  95. height: 157rpx;
  96. }
  97. }
  98. }
  99. </style>