item.vue 2.6 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 { itemList} from '@/api/index.js';
  18. export default {
  19. data() {
  20. return {
  21. list: []
  22. }
  23. },
  24. onShow() {
  25. this.loadData()
  26. },
  27. filters: {
  28. time(val) {
  29. if( val / 1000000000000 < 1){
  30. val = val*1000
  31. }
  32. let date = new Date(val)
  33. console.log(val,date)
  34. let Y = date.getFullYear()
  35. let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth()+1) :( date.getMonth()+1)
  36. let D = date.getDate()< 10 ? '0' + date.getDate() : date.getDate()
  37. let h = date.getHours()< 10 ? '0' + date.getHours() : date.getHours()
  38. let m = date.getMinutes()< 10 ? '0' + date.getMinutes() : date.getMinutes()
  39. let s = date.getSeconds()< 10 ? '0' + date.getSeconds() : date.getSeconds()
  40. return Y + '-' + M + '-' + D + ' ' + h +':' + m + ':' + s
  41. }
  42. },
  43. methods:{
  44. navTo(url) {
  45. uni.navigateTo({
  46. url
  47. })
  48. },
  49. // getList() {
  50. // this.list = [
  51. // {
  52. // id: 1, image: '', title: '大爱无疆!71旬老人捐款100W余元给红十字会善行中国', add_time: 1624279338
  53. // },
  54. // {
  55. // id: 2, image: '', title: '大爱无疆!71旬老人捐款100W余元给红十字会善行中国', add_time: 1624279338
  56. // },
  57. // {
  58. // id: 3, image: '', title: '大爱无疆!71旬老人捐款100W余元给红十字会善行中国', add_time: 1624279338
  59. // }
  60. // ]
  61. // },
  62. loadData(){
  63. let obj = this;
  64. itemList().then(({ data }) => {
  65. console.log(data);
  66. obj.list = data;
  67. });
  68. },
  69. Jump(id) {
  70. uni.navigateTo({
  71. url:"/pages/applic/info?id="+id
  72. })
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. // .item {}
  79. .love-item {
  80. margin: 0 auto;
  81. width: 702rpx;
  82. height: 208rpx;
  83. border-bottom: 1px solid #EEEEEE;
  84. display: flex;
  85. justify-content: space-between;
  86. align-items: center;
  87. image {
  88. width: 200rpx;
  89. height: 160rpx;
  90. background-color: #eee;
  91. }
  92. .content {
  93. height: 160rpx;
  94. padding-left: 16rpx;
  95. display: flex;
  96. flex-direction: column;
  97. justify-content: space-between;
  98. .title {
  99. font-size: 30rpx;
  100. font-family: PingFang SC;
  101. font-weight: 500;
  102. color: #333333;
  103. // line-height: 39px;
  104. }
  105. .time {
  106. font-size: 26rpx;
  107. font-family: PingFang SC;
  108. font-weight: 500;
  109. color: #999999;
  110. }
  111. }
  112. }
  113. </style>