common.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="container">
  3. <!-- 旅客列表区域 -->
  4. <view class="list">
  5. <!-- 每一个旅客区域 -->
  6. <uni-swipe-action>
  7. <uni-swipe-action-item v-for="item in list" :key="item.id">
  8. <!-- 右侧选项内容区域 -->
  9. <template v-slot:right>
  10. <view class="list_item_right">
  11. <!-- 编辑按钮区域 -->
  12. <view class="list_item_right_box edit" @click="handleClickEdit(item)">
  13. <img class="img" src="../../static/my/edit.png" />
  14. </view>
  15. <!-- 删除按钮区域 -->
  16. <view class="list_item_right_box delete" @click="handleClickDelete(item)">
  17. <img class="img" src="../../static/my/delete.png" />
  18. </view>
  19. </view>
  20. </template>
  21. <view class="list_item" @click="handleClick(item)">
  22. <view class="item_box">
  23. <view class="box_key">姓名</view>
  24. <view class="box_value">{{ item.name }}</view>
  25. </view>
  26. <view class="item_box">
  27. <view class="box_key">身份证号</view>
  28. <view class="box_value">{{ item.identity }}</view>
  29. </view>
  30. <view class="item_box">
  31. <view class="box_key">联系电话</view>
  32. <view class="box_value">{{ item.phone }}</view>
  33. </view>
  34. </view>
  35. </uni-swipe-action-item>
  36. </uni-swipe-action>
  37. </view>
  38. <!-- 添加按钮区域 -->
  39. <view class="btn" @click="handleClickAdd">添加</view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. list: [
  47. {
  48. id: 1,
  49. name: '张三',
  50. identity: '360730199603164895',
  51. phone: '13677985689'
  52. },
  53. {
  54. id: 2,
  55. name: '李四',
  56. identity: '360730199603164895',
  57. phone: '13677985689'
  58. },
  59. {
  60. id: 3,
  61. name: '王五',
  62. identity: '360730199603164895',
  63. phone: '13677985689'
  64. },
  65. {
  66. id: 4,
  67. name: '老六',
  68. identity: '360730199603164895',
  69. phone: '13677985689'
  70. },
  71. {
  72. id: 5,
  73. name: '剑八',
  74. identity: '360730199603164895',
  75. phone: '13677985689'
  76. }
  77. ],
  78. type: ''
  79. }
  80. },
  81. onLoad(options) {
  82. if (options.type) {
  83. this.type = options.type
  84. }
  85. },
  86. methods: {
  87. handleClick(item) {
  88. if (this.type) {
  89. uni.$emit('change', {
  90. name: item.name
  91. })
  92. uni.navigateBack(1)
  93. }
  94. },
  95. // 右侧选项内容编辑按钮回调
  96. handleClickEdit(item) {
  97. // console.log(item)
  98. const info = JSON.stringify(item)
  99. uni.navigateTo({
  100. url: `/pages/addOrEdit/addOrEdit?type=2&info=${info}`
  101. })
  102. },
  103. // 右侧选项内容删除按钮回调
  104. handleClickDelete(item) {
  105. console.log(item)
  106. uni.showModal({
  107. title: '提示',
  108. content: `确定删除${item.name}吗?`,
  109. success: (res) => {
  110. if (res.confirm) {
  111. uni.showToast({
  112. title: '删除成功',
  113. icon: 'success'
  114. })
  115. }
  116. }
  117. })
  118. },
  119. // 添加按钮回调
  120. handleClickAdd() {
  121. uni.navigateTo({
  122. url: '/pages/addOrEdit/addOrEdit?type=1'
  123. })
  124. }
  125. }
  126. }
  127. </script>
  128. <style lang="scss" scoped>
  129. .container {
  130. box-sizing: border-box;
  131. padding: 0 20rpx;
  132. height: 100vh;
  133. background-color: #ebeced;
  134. .list {
  135. height: calc(100vh - 186rpx);
  136. overflow-y: auto;
  137. .list_item_right {
  138. display: flex;
  139. margin-top: 20rpx;
  140. width: 252rpx;
  141. height: 236rpx;
  142. .list_item_right_box {
  143. flex: 1;
  144. display: flex;
  145. justify-content: center;
  146. align-items: center;
  147. .img {
  148. width: 50rpx;
  149. height: 50rpx;
  150. }
  151. }
  152. .edit {
  153. background-color: #096562;
  154. }
  155. .delete {
  156. background-color: #d43030;
  157. }
  158. }
  159. .list_item {
  160. display: flex;
  161. flex-direction: column;
  162. box-sizing: border-box;
  163. margin-top: 20rpx;
  164. padding-left: 27rpx;
  165. width: 710rpx;
  166. height: 236rpx;
  167. opacity: 0.9;
  168. border-radius: 15rpx;
  169. background-color: #fff;
  170. .item_box {
  171. flex: 1;
  172. display: flex;
  173. align-items: center;
  174. font-size: 28rpx;
  175. .box_key {
  176. width: 120rpx;
  177. color: #808080;
  178. }
  179. .box_value {
  180. margin-left: 30rpx;
  181. }
  182. }
  183. }
  184. }
  185. .btn {
  186. display: flex;
  187. justify-content: center;
  188. align-items: center;
  189. margin: 45rpx 0;
  190. width: 710rpx;
  191. height: 96rpx;
  192. font-size: 32rpx;
  193. border-radius: 64rpx;
  194. color: #fff;
  195. background-color: #096562;
  196. }
  197. }
  198. </style>