information.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view>
  3. <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in list" :key="item.id"
  4. @click="click(index,item.id)" @open="open" :options="options">
  5. <view class="item u-border-bottom" style="justify:center;align-items:center;display:-webkit-flex">
  6. <image mode="aspectFill" :src="item.images" />
  7. <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
  8. <view class="title-wrap">
  9. <text>{{item.text}}</text>
  10. <text class="title u-line-2">{{ item.title }}</text>
  11. </view>
  12. <view style="color: #9a9a9f;margin-right: -5rpx;">
  13. 11:20
  14. </view>
  15. </view>
  16. </u-swipe-action>
  17. <view style="
  18. width: 50%;
  19. margin: 0 auto;
  20. height: 220rpx;
  21. align-items: center;
  22. position: absolute;
  23. top: 45%;
  24. left: 50%;
  25. transform:translate(-50%,-50%)">
  26. <u-image src="../../static/noNews.png" width="100%" height="200rpx"></u-image>
  27. <view style="text-align: center;">
  28. <text style="color: #C0C4CC;">暂无消息</text>
  29. </view>
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. list: [
  38. // {
  39. // id: 1,
  40. // text:'系统消息',
  41. // title: '长安回望绣成堆,山顶千门次第开,一骑红尘妃子笑,无人知是荔枝来',
  42. // images: 'https://cdn.uviewui.com/uview/common/logo.png',
  43. // show: false
  44. // },
  45. // {
  46. // id: 2,
  47. // text:'客服消息',
  48. // title: '新丰绿树起黄埃,数骑渔阳探使回,霓裳一曲千峰上,舞破中原始下来',
  49. // images: 'https://cdn.uviewui.com/uview/common/logo.png',
  50. // show: false
  51. // },
  52. // {
  53. // id: 3,
  54. // text:'广告消息',
  55. // title: '登临送目,正故国晚秋,天气初肃。千里澄江似练,翠峰如簇',
  56. // images: 'https://cdn.uviewui.com/uview/common/logo.png',
  57. // show: false,
  58. // }
  59. ],
  60. disabled: false,
  61. btnWidth: 180,
  62. show: false,
  63. options: [{
  64. text: '删除',
  65. style: {
  66. backgroundColor: '#f30000'
  67. }
  68. }]
  69. };
  70. },
  71. methods: {
  72. click(index, index1) {
  73. this.list.splice(index, 1);
  74. },
  75. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  76. open(index) {
  77. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  78. // 原本为'false',再次设置为'false'会无效
  79. this.list[index].show = true;
  80. this.list.map((val, idx) => {
  81. if (index != idx) this.list[idx].show = false;
  82. })
  83. }
  84. }
  85. };
  86. </script>
  87. <style lang="scss" scoped>
  88. .item {
  89. display: flex;
  90. padding: 20rpx;
  91. }
  92. image {
  93. width: 120rpx;
  94. flex: 0 0 120rpx;
  95. height: 120rpx;
  96. margin-right: 20rpx;
  97. border-radius: 12rpx;
  98. }
  99. .title {
  100. text-align: left;
  101. font-size: 28rpx;
  102. width: 90%;
  103. color: $u-content-color;
  104. margin-top: 20rpx;
  105. overflow: hidden;
  106. text-overflow: ellipsis;
  107. display: -webkit-box;
  108. -webkit-line-clamp: 1;
  109. -webkit-box-orient: vertical;
  110. }
  111. .u-border-bottom:active {
  112. background-color: #f0f0f0;
  113. }
  114. </style>