common.vue 4.6 KB

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