commonPeople.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. <template>
  2. <view class="container">
  3. <!-- 添加按钮区域 -->
  4. <view class="add" @click="handleAdd">+ 添加常用旅客</view>
  5. <!-- 每一个旅客信息区域 -->
  6. <view v-for="item in dataList" :key="item.id" class="box">
  7. <view class="box_msg">
  8. <view class="msg_name">{{ item.username }}</view>
  9. <view class="msg_identity">身份证 {{ item.sfzh }}</view>
  10. <view class="msg_phone">手机号 {{ item.mobile }}</view>
  11. </view>
  12. <view class="box_btn">
  13. <wd-icon name="delete" color="#DC2626" size="20" @click="handleDelete(item)"></wd-icon>
  14. <wd-icon name="edit-1" color="#ABA6A6" size="20" @click="handleEdit(item)" />
  15. </view>
  16. </view>
  17. <view v-if="!dataList.length">
  18. <wd-status-tip image="content" tip="暂无数据" />
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import { ref } from 'vue'
  24. import { onLoad, onReachBottom } from '@dcloudio/uni-app'
  25. import { myRequest } from '@/utils/api.ts'
  26. // 用户信息
  27. const userInfo = ref()
  28. // 每页多少条
  29. const pageSize = ref(8)
  30. // 当前页
  31. const currentPage = ref(1)
  32. // 总条数
  33. const total = ref(0)
  34. // 常用旅客数组数据
  35. const dataList = ref([])
  36. onLoad(() => {
  37. userInfo.value = uni.getStorageSync('carUserInfo')
  38. console.log(userInfo.value)
  39. getCommonData()
  40. })
  41. // 页面触底触发的回调
  42. onReachBottom(() => {
  43. if (dataList.value.length < total.value) {
  44. currentPage.value++
  45. getCommonData()
  46. } else {
  47. uni.showToast({
  48. title: '没有更多数据了',
  49. icon: 'none'
  50. })
  51. }
  52. })
  53. // 获取常用旅客列表数据
  54. const getCommonData = async () => {
  55. let data = {
  56. page: currentPage.value,
  57. rows: pageSize.value,
  58. username: userInfo.value.username || '',
  59. mobile: userInfo.value.mobile || ''
  60. }
  61. const res = await myRequest({
  62. url: '/ctUserlist.action',
  63. data
  64. })
  65. // console.log(res)
  66. dataList.value = [...dataList.value, ...res.rows]
  67. total.value = res.total
  68. }
  69. // 点击添加旅客回调
  70. const handleAdd = () => {
  71. uni.navigateTo({
  72. url: '/pages/handlePeople/handlePeople'
  73. })
  74. }
  75. // 编辑旅客回调
  76. const handleEdit = (item) => {
  77. let info = encodeURIComponent(JSON.stringify(item))
  78. uni.navigateTo({
  79. url: `/pages/handlePeople/handlePeople?info=${info}`
  80. })
  81. }
  82. // 删除图标回调
  83. const handleDelete = (item) => {
  84. // console.log(item)
  85. uni.showModal({
  86. title: '提示',
  87. content: `确定删除${item.username}吗?`,
  88. success: (res) => {
  89. if (res.confirm) {
  90. deleteReq(item.id)
  91. }
  92. }
  93. })
  94. }
  95. // 删除请求
  96. const deleteReq = async (id) => {
  97. let data = {
  98. id
  99. }
  100. const res = await myRequest({
  101. url: '/ctUserdel.action',
  102. data
  103. })
  104. // console.log(res)
  105. if (res.code == 200) {
  106. uni.showToast({
  107. title: res.message,
  108. icon: 'success'
  109. })
  110. setTimeout(() => {
  111. currentPage.value = 1
  112. dataList.value = []
  113. total.value = 0
  114. getCommonData()
  115. }, 1500)
  116. }
  117. }
  118. </script>
  119. <style lang="scss" scoped>
  120. .container {
  121. box-sizing: border-box;
  122. padding: 30rpx;
  123. min-height: 100vh;
  124. color: #001713;
  125. background-color: #fffdfb;
  126. overflow-y: auto;
  127. .add {
  128. display: flex;
  129. align-items: center;
  130. justify-content: center;
  131. margin-bottom: 20rpx;
  132. width: 100%;
  133. height: 104rpx;
  134. font-size: 32rpx;
  135. color: #ff8205;
  136. border-radius: 10rpx;
  137. background-color: #fff2e5;
  138. }
  139. .box {
  140. display: flex;
  141. align-items: center;
  142. justify-content: space-between;
  143. box-sizing: border-box;
  144. padding: 30rpx 40rpx;
  145. margin-bottom: 20rpx;
  146. width: 100%;
  147. height: 200rpx;
  148. border-radius: 16rpx;
  149. background-color: #fff;
  150. box-shadow: 0 3rpx 6rpx #ccc;
  151. .box_msg {
  152. display: flex;
  153. flex-direction: column;
  154. justify-content: space-between;
  155. height: 100%;
  156. font-size: 24rpx;
  157. color: #aba6a6;
  158. .msg_name {
  159. font-size: 36rpx;
  160. color: #001713;
  161. }
  162. }
  163. .box_btn {
  164. display: flex;
  165. align-items: center;
  166. justify-content: space-between;
  167. width: 200rpx;
  168. }
  169. }
  170. }
  171. </style>