buy.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view class="buy-page">
  3. <view class="list-wrap">
  4. <view class="flex item" v-for="item in list" :key="item.report_id" @click="goDetail(item)">
  5. <view class="img" :style="'background-image:url('+item.img_url+')'">
  6. <text class="num" v-if="item.unread">{{item.unread}}</text>
  7. </view>
  8. <view class="content-box">
  9. <view class="van-ellipsis title">{{item.title}}</view>
  10. <view :class="['van-ellipsis intro',item.content.substr(0,1)=='【'?'text-indent':'']">{{item.content}}</view>
  11. </view>
  12. <view class="time">{{item.time|showTime}}</view>
  13. </view>
  14. <view style="color:#999;margin:40rpx 0;text-align:center">- 已经到底了 -</view>
  15. </view>
  16. </view>
  17. </template>
  18. <script>
  19. const dayjs=require('@/utils/dayjs.min')
  20. dayjs.locale('zh-cn')
  21. import {apiBuyList} from '@/api/buy.js'
  22. export default {
  23. filters: {
  24. showTime(e){
  25. // 判断是否为今年
  26. const isYear=dayjs(e).isBefore(new Date(), 'year');
  27. if(isYear){
  28. return dayjs(e).format("YYYY年MM月DD日");
  29. }else{
  30. const isDay=dayjs(e).isBefore(new Date(), 'day');
  31. if(isDay){
  32. return dayjs(e).format("MM月DD日");
  33. }else{
  34. const hour=dayjs(e).hour()
  35. return hour<12?`上午 ${dayjs(e).format('hh:mm')}`:`下午 ${dayjs(e).format('hh:mm')}`
  36. }
  37. }
  38. }
  39. },
  40. data () {
  41. return {
  42. list:[]
  43. }
  44. },
  45. onShow() {
  46. this.getList()
  47. },
  48. onPullDownRefresh() {
  49. this.getList()
  50. setTimeout(() => {
  51. uni.stopPullDownRefresh()
  52. }, 1500);
  53. },
  54. methods: {
  55. async getList(){
  56. const res=await apiBuyList()
  57. if(res.code===200){
  58. this.list=res.data
  59. }
  60. },
  61. goDetail(item){
  62. uni.navigateTo({ url: `/pages-buy/detail?classify_id_first=${item.classify_id_first}&activity_id=${item.activity_id}&name=${item.classify_name_first}` })
  63. }
  64. }
  65. }
  66. </script>
  67. <style lang="scss" scoped>
  68. .buy-page{
  69. .list-wrap{
  70. padding: 30rpx 34rpx;
  71. .item{
  72. padding: 30rpx 0;
  73. border-bottom: 1px solid $global-border-color;
  74. align-items: center;
  75. .img{
  76. flex-shrink: 0;
  77. margin-right: 28rpx;
  78. width: 90rpx;
  79. height: 90rpx;
  80. background-color: $global-bg-color-grey;
  81. background-size: cover;
  82. position: relative;
  83. border-radius: 14rpx;
  84. .num{
  85. position: absolute;
  86. top: 0;
  87. right: 0;
  88. transform: translate(50%,-50%);
  89. display: inline-block;
  90. box-sizing: border-box;
  91. min-width: 28rpx;
  92. padding: var(--van-badge-padding);
  93. color: #fff;
  94. font-size: $global-font-size-mini;
  95. line-height: 1.2;
  96. text-align: center;
  97. background: #ee0a24;
  98. border-radius: 28rpx;
  99. padding: 2rpx 4rpx;
  100. }
  101. }
  102. .content-box{
  103. flex: 1;
  104. overflow: hidden;
  105. .title{
  106. font-size: 32rpx;
  107. font-weight: bold;
  108. margin-bottom: 6rpx;
  109. }
  110. .intro{
  111. color: $global-text-color-grey;
  112. font-size: 28rpx;
  113. }
  114. .text-indent{
  115. margin-left: -12rpx;
  116. }
  117. }
  118. .time{
  119. font-size: $global-font-size-sm;
  120. color: $global-text-color-grey;
  121. flex-shrink: 0;
  122. margin-left: 20rpx;
  123. }
  124. }
  125. }
  126. }
  127. </style>