index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. inSystem(index) {
  81. console.log(index)
  82. this.$u.route({
  83. url: 'pages/msg/System-message/index',
  84. })
  85. },
  86. click(index, index1) {
  87. if(index1 == 1) {
  88. this.msgList.splice(index, 1);
  89. this.$u.toast(`删除了第${index}个cell`);
  90. } else {
  91. this.msgList[index].show = false;
  92. this.$u.toast(`收藏成功`);
  93. }
  94. },
  95. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  96. open(index) {
  97. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  98. // 原本为'false',再次设置为'false'会无效
  99. this.msgList[index].show = true;
  100. this.msgList.map((val, idx) => {
  101. if(index != idx) this.msgList[idx].show = false;
  102. })
  103. }
  104. },
  105. };
  106. </script>
  107. <style lang="scss" scoped>
  108. .item {
  109. display: flex;
  110. padding: 20rpx;
  111. }
  112. image {
  113. width: 120rpx;
  114. flex: 0 0 120rpx;
  115. height: 120rpx;
  116. margin-right: 20rpx;
  117. border-radius: 12rpx;
  118. }
  119. .title {
  120. text-align: left;
  121. font-size: 29rpx;
  122. color: #333333;
  123. font-weight: bold;
  124. margin-top: 20rpx;
  125. }
  126. .title-wrap-one {
  127. margin-top: 10rpx;
  128. font-size: 23rpx;
  129. color: #999999;
  130. }
  131. .title-wrap-two {
  132. margin-left: 120rpx;
  133. margin-top: 10rpx;
  134. }
  135. .title-wrap-two>view:nth-child(1) {
  136. font-size: 19rpx;
  137. color: #999999;
  138. }
  139. .title-wrap-two>view:nth-child(2) {
  140. width: 35rpx;
  141. height: 35rpx;
  142. background: #FC3228;
  143. border-radius: 50%;
  144. color: #fff;
  145. text-align: center;
  146. font-size: 19rpx;
  147. margin: 0 auto;
  148. margin-top: 15rpx;
  149. }
  150. </style>