category.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <template>
  2. <view class="content">
  3. <view class="main">
  4. <view v-for="(item, index) in list">
  5. <view class="first" v-if="index == 0" @click="navToList(item.id)">
  6. <view class="title">{{item.title}}</view>
  7. <view class="image"><image :src="item.image_input[0]" mode=""></image></view>
  8. <view class="time">更新时间:{{item.add_time}}</view>
  9. </view>
  10. <view class="item flex" @click="navToList(item.id)" v-else>
  11. <view class="item-left"><image :src="item.image_input[0]" mode=""></image></view>
  12. <view class="item-right">
  13. <view class="item-font clamp">{{item.title}}</view>
  14. <view class="item-time">更新时间:{{item.add_time}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { article } from '@/api/user.js';
  23. export default {
  24. data() {
  25. return {
  26. list: []
  27. };
  28. },
  29. onLoad() {
  30. this.loadData();
  31. },
  32. methods: {
  33. // 载入数据
  34. async loadData() {
  35. let obj = this;
  36. article({page:1,limit:1000},4).then(({data}) =>{
  37. this.list = data
  38. })
  39. },
  40. navToList(id) {
  41. uni.navigateTo({
  42. url: '/pages/category/detail?id=' + id
  43. });
  44. }
  45. }
  46. };
  47. </script>
  48. <style lang="scss">
  49. page,
  50. .content {
  51. height: auto;
  52. min-height: 100%;
  53. background: #f5f5f5;
  54. }
  55. .main {
  56. margin-top: 20rpx;
  57. background: #ffffff;
  58. .first {
  59. padding: 50rpx 0 18rpx;
  60. margin: 0 22rpx;
  61. border-bottom: 1px solid #e0e0e0;
  62. .title {
  63. font-size: 32rpx;
  64. font-family: PingFang SC;
  65. font-weight: bold;
  66. color: #333333;
  67. }
  68. .image {
  69. width: 710rpx;
  70. height: 400rpx;
  71. background: #4cd964;
  72. margin-top: 20rpx;
  73. image {
  74. width: 100%;
  75. height: 100%;
  76. }
  77. }
  78. .time {
  79. margin-top: 20rpx;
  80. font-size: 26rpx;
  81. font-family: PingFang SC;
  82. font-weight: 500;
  83. color: #666666;
  84. }
  85. }
  86. .item {
  87. padding: 26rpx 0 18rpx;
  88. margin: 0 22rpx;
  89. justify-content: flex-start;
  90. align-items: flex-start;
  91. border-bottom: 1px solid #e0e0e0;
  92. .item-left {
  93. width: 224rpx;
  94. height: 160rpx;
  95. image {
  96. width: 100%;
  97. height: 100%;
  98. }
  99. }
  100. .item-right {
  101. width: 458rpx;
  102. height: 160rpx;
  103. margin-left: 24rpx;
  104. padding: 18rpx 0;
  105. display: flex;
  106. flex-direction: column;
  107. justify-content: space-between;
  108. .item-font {
  109. font-size: 32rpx;
  110. font-family: PingFang SC;
  111. font-weight: bold;
  112. color: #333333;
  113. }
  114. .item-time {
  115. font-size: 28rpx;
  116. font-family: PingFang SC;
  117. font-weight: 500;
  118. color: #666666;
  119. }
  120. }
  121. }
  122. }
  123. </style>