common.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.user_name }}</view>
  25. </view>
  26. <view class="item_box">
  27. <view class="box_key">身份证号</view>
  28. <view class="box_value">{{ item.card_number }}</view>
  29. </view>
  30. <view class="item_box">
  31. <view class="box_key">联系电话</view>
  32. <view class="box_value">{{ item.user_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. // 旅客列表
  47. list: [],
  48. type: ''
  49. }
  50. },
  51. onLoad(options) {
  52. if (options.type) {
  53. this.type = options.type
  54. }
  55. },
  56. onShow() {
  57. this.getDataList()
  58. },
  59. methods: {
  60. // 获取旅客列表
  61. async getDataList() {
  62. const res = await this.$myRequest({
  63. url: '/mhotel/ampgetUserContactList.action',
  64. data: {
  65. userId: uni.getStorageSync('userInfo').id
  66. }
  67. })
  68. // console.log(res)
  69. if (res.code === 200) {
  70. this.list = res.data.pageList
  71. }
  72. },
  73. handleClick(item) {
  74. if (this.type) {
  75. uni.$emit('change', {
  76. name: item.user_name,
  77. phone: item.user_phone
  78. })
  79. uni.navigateBack(1)
  80. }
  81. },
  82. // 右侧选项内容编辑按钮回调
  83. handleClickEdit(item) {
  84. // console.log(item)
  85. const info = JSON.stringify(item)
  86. uni.navigateTo({
  87. url: `/pages/addOrEdit/addOrEdit?type=2&info=${info}`
  88. })
  89. },
  90. // 右侧选项内容删除按钮回调
  91. handleClickDelete(item) {
  92. console.log(item)
  93. uni.showModal({
  94. title: '提示',
  95. content: `确定删除${item.user_name}吗?`,
  96. success: async (res) => {
  97. if (res.confirm) {
  98. const res = await this.$myRequest({
  99. url: '/mhotel/ampdelContact.action',
  100. data: {
  101. contactId: item.id
  102. }
  103. })
  104. // console.log(res)
  105. if (res.code === 200) {
  106. uni.showToast({
  107. title: '删除成功',
  108. icon: 'success'
  109. })
  110. setTimeout(() => {
  111. this.getDataList()
  112. }, 1500)
  113. }
  114. }
  115. }
  116. })
  117. },
  118. // 添加按钮回调
  119. handleClickAdd() {
  120. uni.navigateTo({
  121. url: '/pages/addOrEdit/addOrEdit?type=1'
  122. })
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss" scoped>
  128. .container {
  129. box-sizing: border-box;
  130. padding: 0 20rpx;
  131. height: 100vh;
  132. background-color: #ebeced;
  133. .list {
  134. height: calc(100vh - 186rpx);
  135. overflow-y: auto;
  136. .list_item_right {
  137. display: flex;
  138. margin-top: 20rpx;
  139. width: 252rpx;
  140. height: 236rpx;
  141. .list_item_right_box {
  142. flex: 1;
  143. display: flex;
  144. justify-content: center;
  145. align-items: center;
  146. .img {
  147. width: 50rpx;
  148. height: 50rpx;
  149. }
  150. }
  151. .edit {
  152. background-color: #096562;
  153. }
  154. .delete {
  155. background-color: #d43030;
  156. }
  157. }
  158. .list_item {
  159. display: flex;
  160. flex-direction: column;
  161. box-sizing: border-box;
  162. margin-top: 20rpx;
  163. padding-left: 27rpx;
  164. width: 710rpx;
  165. height: 236rpx;
  166. opacity: 0.9;
  167. border-radius: 15rpx;
  168. background-color: #fff;
  169. .item_box {
  170. flex: 1;
  171. display: flex;
  172. align-items: center;
  173. font-size: 28rpx;
  174. .box_key {
  175. width: 120rpx;
  176. color: #808080;
  177. }
  178. .box_value {
  179. margin-left: 30rpx;
  180. }
  181. }
  182. }
  183. }
  184. .btn {
  185. display: flex;
  186. justify-content: center;
  187. align-items: center;
  188. margin: 45rpx 0;
  189. width: 710rpx;
  190. height: 96rpx;
  191. font-size: 32rpx;
  192. border-radius: 64rpx;
  193. color: #fff;
  194. background-color: #096562;
  195. }
  196. }
  197. </style>