artList.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="item">
  3. <view class="love-item" v-for="item in list" :key="item.id" @click="Jump(item.id)">
  4. <image :src="item.image_input[0]" mode=""></image>
  5. <view class="content">
  6. <view class="title">
  7. {{item.title}}
  8. </view>
  9. <view class="time">
  10. {{item.add_time | time}}
  11. </view>
  12. </view>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import { getArtList} from '@/api/index.js';
  18. export default {
  19. data() {
  20. return {
  21. list: [],
  22. id: 0,
  23. }
  24. },
  25. onLoad(opt) {
  26. if(opt.id) {
  27. this.id = opt.id
  28. }
  29. this.loadData()
  30. },
  31. onShow() {
  32. },
  33. filters: {
  34. time(val) {
  35. if( val / 1000000000000 < 1){
  36. val = val*1000
  37. }
  38. let date = new Date(val)
  39. console.log(val,date)
  40. let Y = date.getFullYear()
  41. let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth()+1) :( date.getMonth()+1)
  42. let D = date.getDate()< 10 ? '0' + date.getDate() : date.getDate()
  43. let h = date.getHours()< 10 ? '0' + date.getHours() : date.getHours()
  44. let m = date.getMinutes()< 10 ? '0' + date.getMinutes() : date.getMinutes()
  45. let s = date.getSeconds()< 10 ? '0' + date.getSeconds() : date.getSeconds()
  46. return Y + '-' + M + '-' + D + ' ' + h +':' + m + ':' + s
  47. }
  48. },
  49. methods:{
  50. navTo(url) {
  51. uni.navigateTo({
  52. url
  53. })
  54. },
  55. loadData(){
  56. let obj = this;
  57. getArtList({
  58. page: 1,
  59. limit: 100
  60. },obj.id).then(({ data }) => {
  61. console.log(data);
  62. obj.list = data;
  63. });
  64. },
  65. Jump(id) {
  66. uni.navigateTo({
  67. url:"/pages/index/artDetail?id="+id
  68. })
  69. },
  70. }
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. // .item {}
  75. .item {
  76. background-color: #fff;
  77. }
  78. .love-item {
  79. margin: 0 auto;
  80. width: 702rpx;
  81. height: 208rpx;
  82. border-bottom: 1px solid #EEEEEE;
  83. display: flex;
  84. justify-content: flex-start;
  85. align-items: center;
  86. image {
  87. width: 160rpx;
  88. height: 160rpx;
  89. background-color: #eee;
  90. }
  91. .content {
  92. height: 160rpx;
  93. padding-left: 16rpx;
  94. display: flex;
  95. flex-direction: column;
  96. justify-content: space-between;
  97. .title {
  98. font-size: 30rpx;
  99. font-family: PingFang SC;
  100. font-weight: 500;
  101. color: #333333;
  102. // line-height: 39px;
  103. }
  104. .time {
  105. font-size: 26rpx;
  106. font-family: PingFang SC;
  107. font-weight: 500;
  108. color: #999999;
  109. }
  110. }
  111. }
  112. </style>