index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <template>
  2. <view>
  3. <view class="u-page">
  4. <u-swipe-action :show="item.show" :index="index" v-for="(item, index) in msgList" :key="item.id" @click="click" @content-click="inSystem" @open="open"
  5. :options="options">
  6. <view class="item u-border-bottom">
  7. <image mode="aspectFill" :src="item.images" />
  8. <!-- 此层wrap在此为必写的,否则可能会出现标题定位错误 -->
  9. <view class="title-wrap">
  10. <text class="title u-line-2">{{ item.title }}</text>
  11. <view class="title-wrap-one">
  12. 【{{ item.text }} 】
  13. </view>
  14. </view>
  15. <view class="title-wrap-two">
  16. <view>
  17. {{ item.time }}
  18. </view>
  19. <view>
  20. {{ item.ip }}
  21. </view>
  22. </view>
  23. </view>
  24. </u-swipe-action>
  25. </view>
  26. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  27. </view>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. msgList: [{
  34. id: 1,
  35. ip: 1,
  36. time: '14.23',
  37. title: '青岛市市北区赛轮轮胎经销部',
  38. text: '订单信息',
  39. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  40. show: false
  41. },
  42. {
  43. id: 2,
  44. ip: 2,
  45. time: '17.23',
  46. title: '青岛市市北区赛轮轮胎经销部',
  47. text: '订单信息',
  48. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  49. show: false
  50. },
  51. {
  52. id: 3,
  53. ip: 3,
  54. time: '19.23',
  55. title: '青岛市市北区赛轮轮胎经销部',
  56. text: '订单信息',
  57. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  58. show: false,
  59. }
  60. ],
  61. disabled: false,
  62. btnWidth: 180,
  63. show: false,
  64. options: [{
  65. text: '收藏',
  66. style: {
  67. backgroundColor: '#007aff'
  68. }
  69. },
  70. {
  71. text: '删除',
  72. style: {
  73. backgroundColor: '#dd524d'
  74. }
  75. }
  76. ]
  77. };
  78. },
  79. methods: {
  80. click(index, index1) {
  81. if (index1 == 1) {
  82. this.list.splice(index, 1);
  83. this.$u.toast(`删除了第${index}个cell`);
  84. } else {
  85. this.list[index].show = false;
  86. this.$u.toast(`收藏成功`);
  87. }
  88. },
  89. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  90. open(index) {
  91. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  92. // 原本为'false',再次设置为'false'会无效
  93. this.list[index].show = true;
  94. this.list.map((val, idx) => {
  95. if (index != idx) this.list[idx].show = false;
  96. })
  97. },
  98. inSystem(){
  99. this.$u.route({
  100. url: 'pages/msg/System-message/index',
  101. })
  102. }
  103. }
  104. };
  105. </script>
  106. <style lang="scss" scoped>
  107. .item {
  108. display: flex;
  109. padding: 20rpx;
  110. }
  111. image {
  112. width: 120rpx;
  113. flex: 0 0 120rpx;
  114. height: 120rpx;
  115. margin-right: 20rpx;
  116. border-radius: 12rpx;
  117. }
  118. .title {
  119. text-align: left;
  120. font-size: 29rpx;
  121. color: #333333;
  122. font-weight: bold;
  123. margin-top: 20rpx;
  124. }
  125. .title-wrap-one {
  126. margin-top: 10rpx;
  127. font-size: 23rpx;
  128. color: #999999;
  129. }
  130. .title-wrap-two {
  131. margin-left: 120rpx;
  132. margin-top: 10rpx;
  133. }
  134. .title-wrap-two>view:nth-child(1) {
  135. font-size: 19rpx;
  136. color: #999999;
  137. }
  138. .title-wrap-two>view:nth-child(2) {
  139. width: 35rpx;
  140. height: 35rpx;
  141. background: #FC3228;
  142. border-radius: 50%;
  143. color: #fff;
  144. text-align: center;
  145. font-size: 19rpx;
  146. margin: 0 auto;
  147. margin-top: 5rpx;
  148. }
  149. </style>