index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. current: 1,
  34. list: [{
  35. iconPath: "home",
  36. selectedIconPath: "home-fill",
  37. text: '首页',
  38. customIcon: false,
  39. pagePath: '/pages/home/index'
  40. },
  41. {
  42. iconPath: "chat",
  43. selectedIconPath: "chat-fill",
  44. text: '消息',
  45. count: 2,
  46. isDot: false,
  47. customIcon: false,
  48. pagePath: '/pages/msg/index'
  49. },
  50. {
  51. iconPath: "account",
  52. selectedIconPath: "account-fill",
  53. text: '我的',
  54. customIcon: false,
  55. pagePath: '/pages/me/index'
  56. },
  57. ],
  58. msgList: [{
  59. id: 1,
  60. ip: 1,
  61. time: '14.23',
  62. title: '青岛市市北区赛轮轮胎经销部',
  63. text: '订单信息',
  64. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  65. show: false
  66. },
  67. {
  68. id: 2,
  69. ip: 2,
  70. time: '17.23',
  71. title: '青岛市市北区赛轮轮胎经销部',
  72. text: '订单信息',
  73. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  74. show: false
  75. },
  76. {
  77. id: 3,
  78. ip: 3,
  79. time: '19.23',
  80. title: '青岛市市北区赛轮轮胎经销部',
  81. text: '订单信息',
  82. images: 'https://cdn.uviewui.com/uview/common/logo.png',
  83. show: false,
  84. }
  85. ],
  86. disabled: false,
  87. btnWidth: 180,
  88. show: false,
  89. options: [{
  90. text: '收藏',
  91. style: {
  92. backgroundColor: '#007aff'
  93. }
  94. },
  95. {
  96. text: '删除',
  97. style: {
  98. backgroundColor: '#dd524d'
  99. }
  100. }
  101. ]
  102. };
  103. },
  104. methods: {
  105. click(index, index1) {
  106. if (index1 == 1) {
  107. this.list.splice(index, 1);
  108. this.$u.toast(`删除了第${index}个cell`);
  109. } else {
  110. this.list[index].show = false;
  111. this.$u.toast(`收藏成功`);
  112. }
  113. },
  114. // 如果打开一个的时候,不需要关闭其他,则无需实现本方法
  115. open(index) {
  116. // 先将正在被操作的swipeAction标记为打开状态,否则由于props的特性限制,
  117. // 原本为'false',再次设置为'false'会无效
  118. this.list[index].show = true;
  119. this.list.map((val, idx) => {
  120. if (index != idx) this.list[idx].show = false;
  121. })
  122. },
  123. inSystem(){
  124. this.$u.route({
  125. url: 'pages/msg/System-message/index',
  126. })
  127. }
  128. }
  129. };
  130. </script>
  131. <style lang="scss" scoped>
  132. .item {
  133. display: flex;
  134. padding: 20rpx;
  135. }
  136. image {
  137. width: 120rpx;
  138. flex: 0 0 120rpx;
  139. height: 120rpx;
  140. margin-right: 20rpx;
  141. border-radius: 12rpx;
  142. }
  143. .title {
  144. text-align: left;
  145. font-size: 29rpx;
  146. color: #333333;
  147. font-weight: bold;
  148. margin-top: 20rpx;
  149. }
  150. .title-wrap-one {
  151. margin-top: 10rpx;
  152. font-size: 23rpx;
  153. color: #999999;
  154. }
  155. .title-wrap-two {
  156. margin-left: 120rpx;
  157. margin-top: 10rpx;
  158. }
  159. .title-wrap-two>view:nth-child(1) {
  160. font-size: 19rpx;
  161. color: #999999;
  162. }
  163. .title-wrap-two>view:nth-child(2) {
  164. width: 35rpx;
  165. height: 35rpx;
  166. background: #FC3228;
  167. border-radius: 50%;
  168. color: #fff;
  169. text-align: center;
  170. font-size: 19rpx;
  171. margin: 0 auto;
  172. margin-top: 5rpx;
  173. }
  174. </style>