collection.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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="imghost+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. imghost:""
  23. }
  24. },
  25. mounted() {
  26. this.imghost = this.$imgHost
  27. this.getcollectionList()
  28. },
  29. methods: {
  30. //点击文章
  31. open(id, title) {
  32. uni.navigateTo({
  33. url: '/pages/common_tools/collection/collection_details?id=' + id + '&title=' + title
  34. // url: '/pages/customer/customer-datails?n=' + n
  35. })
  36. },
  37. getcollectionList: async function() {
  38. let res = await this.$request.post("/api/v1/collection/collectList", {
  39. page: this.pageindex,
  40. type: 2
  41. })
  42. console.log(res)
  43. if (res.status == 0) {
  44. if (this.pageindex > res.data.last_page) {
  45. uni.showToast({
  46. title: "没有更多了",
  47. icon: "none"
  48. })
  49. } else {
  50. this.listArray = this.listArray.concat(res.data.data)
  51. this.pageindex++
  52. }
  53. }
  54. if (this.listArray.length == 0) {
  55. this.show = true
  56. } else {
  57. this.show = false
  58. }
  59. }
  60. },
  61. }
  62. </script>
  63. <style lang="scss">
  64. //每一条文章
  65. .list {
  66. margin-bottom: 20rpx;
  67. border-radius: 12rpx;
  68. background-color: #ffffff;
  69. padding: 25rpx 20rpx;
  70. display: flex;
  71. box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.04);
  72. .text {
  73. width: 60%;
  74. height: 165rpx;
  75. padding-right: 25rpx;
  76. .title {
  77. height: 80%;
  78. font-size: 30rpx;
  79. font-weight: bold;
  80. // overflow: hidden; //超出一行文字自动隐藏
  81. // text-overflow: ellipsis; //文字隐藏后添加省略号
  82. // white-space: nowrap; //强制不换行
  83. }
  84. .type {
  85. font-size: 26rpx;
  86. color: #666666;
  87. font-weight: 400;
  88. height: 20%;
  89. bottom: 0;
  90. }
  91. }
  92. .img {
  93. width: 40%;
  94. height: 100%;
  95. .i {
  96. width: 272rpx;
  97. height: 157rpx;
  98. }
  99. }
  100. }
  101. </style>