message.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="center">
  3. <view class="message">
  4. <view class="item" v-for="l in list" @click="look(l.cate_id)">
  5. <view class="img">
  6. <image :src="l.image" mode=""></image>
  7. </view>
  8. <view class="right">
  9. <view class="top">
  10. <view class="title">{{ l.name }}</view><view class="time">{{ time(l.last_message.add_time) }}</view>
  11. </view>
  12. <view class="bottom">
  13. <view class="concent clamp2">{{ l.last_message.detail }}</view>
  14. <view class="icon" v-show="l.unwatch_message > 0"></view>
  15. </view>
  16. </view>
  17. </view>
  18. </view>
  19. </view>
  20. </template>
  21. <script>
  22. import { messageList } from '@/api/finance.js'
  23. export default {
  24. data(){
  25. return {
  26. list:[],
  27. }
  28. },
  29. onLoad() {
  30. this.loadData()
  31. },
  32. methods: {
  33. loadData() {
  34. messageList({page:1,limit:10}).then(({data}) =>{
  35. this.list = data
  36. console.log(data)
  37. })
  38. },
  39. look(id) {
  40. console.log(id)
  41. },
  42. time (data) {
  43. var date = new Date(data)
  44. var Y = date.getFullYear() + '-'
  45. var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
  46. var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
  47. var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':'
  48. var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()) + ':'
  49. var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds())
  50. return Y + M + D + h + m + s
  51. }
  52. }
  53. }
  54. </script>
  55. <style lang="scss">
  56. .center,page {
  57. height: 100%;
  58. width: 100%;
  59. background: #F8F8F8;
  60. }
  61. .message {
  62. margin-top: 20rpx;
  63. font-family: PingFangSC-Medium;
  64. background-color: #fff;
  65. .item {
  66. display: flex;
  67. padding: 30rpx 0;
  68. margin: 0 30rpx;
  69. border-bottom: solid 1rpx #f8f8f8;
  70. .img {
  71. margin: auto 0;
  72. width: 110rpx;
  73. margin-left: 0rpx;
  74. image {
  75. width: 80rpx;
  76. height: 80rpx;
  77. }
  78. }
  79. .right {
  80. width: calc(100% - 110rpx);
  81. display: grid;
  82. align-content: space-between;
  83. .top {
  84. display: flex;
  85. justify-content: space-between;
  86. .title {
  87. color: #000;
  88. font-size: 30rpx;
  89. }
  90. .time {
  91. color: #999999;
  92. font-size: 25rpx;
  93. }
  94. }
  95. .bottom {
  96. display: flex;
  97. justify-content: space-between;
  98. .concent {
  99. width: calc(100% - 30rpx);
  100. color: #999999;
  101. font-size: 26rpx;
  102. }
  103. .icon {
  104. margin: auto 0;
  105. width: 10rpx;
  106. height: 10rpx;
  107. background-color: #FB555C;
  108. border-radius: 50%;
  109. }
  110. }
  111. }
  112. }
  113. }
  114. </style>