collection.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. this.listArray = res.data.data
  43. }
  44. if (this.listArray.length == 0) {
  45. this.show = true
  46. } else {
  47. this.show = false
  48. }
  49. }
  50. },
  51. }
  52. </script>
  53. <style lang="scss">
  54. //每一条文章
  55. .list {
  56. margin-bottom: 20rpx;
  57. border-radius: 12rpx;
  58. background-color: #ffffff;
  59. padding: 25rpx 20rpx;
  60. display: flex;
  61. box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.04);
  62. .text {
  63. width: 60%;
  64. height: 165rpx;
  65. padding-right: 25rpx;
  66. .title {
  67. height: 80%;
  68. font-size: 30rpx;
  69. font-weight: bold;
  70. // overflow: hidden; //超出一行文字自动隐藏
  71. // text-overflow: ellipsis; //文字隐藏后添加省略号
  72. // white-space: nowrap; //强制不换行
  73. }
  74. .type {
  75. font-size: 26rpx;
  76. color: #666666;
  77. font-weight: 400;
  78. height: 20%;
  79. bottom: 0;
  80. }
  81. }
  82. .img {
  83. width: 40%;
  84. height: 100%;
  85. .i {
  86. width: 272rpx;
  87. height: 157rpx;
  88. }
  89. }
  90. }
  91. </style>