commonPeople.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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. mobile: uni.getStorageSync('carUserInfo').mobile
  59. }
  60. const res = await myRequest({
  61. url: '/ctUserlist.action',
  62. data
  63. })
  64. console.log(res)
  65. dataList.value = [...dataList.value, ...res.rows]
  66. total.value = res.total
  67. }
  68. // 点击添加旅客回调
  69. const handleAdd = () => {
  70. uni.navigateTo({
  71. url: '/pages/handlePeople/handlePeople'
  72. })
  73. }
  74. // 编辑旅客回调
  75. const handleEdit = (item) => {
  76. let info = encodeURIComponent(JSON.stringify(item))
  77. uni.navigateTo({
  78. url: `/pages/handlePeople/handlePeople?info=${info}`
  79. })
  80. }
  81. // 删除图标回调
  82. const handleDelete = (item) => {
  83. // console.log(item)
  84. uni.showModal({
  85. title: '提示',
  86. content: `确定删除${item.username}吗?`,
  87. success: (res) => {
  88. if (res.confirm) {
  89. deleteReq(item.id)
  90. }
  91. }
  92. })
  93. }
  94. // 删除请求
  95. const deleteReq = async (id) => {
  96. let data = {
  97. id
  98. }
  99. const res = await myRequest({
  100. url: '/ctUserdel.action',
  101. data
  102. })
  103. // console.log(res)
  104. if (res.code == 200) {
  105. uni.showToast({
  106. title: res.message,
  107. icon: 'success'
  108. })
  109. setTimeout(() => {
  110. currentPage.value = 1
  111. dataList.value = []
  112. total.value = 0
  113. getCommonData()
  114. }, 1500)
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .container {
  120. box-sizing: border-box;
  121. padding: 30rpx;
  122. min-height: 100vh;
  123. color: #001713;
  124. background-color: #fffdfb;
  125. overflow-y: auto;
  126. .add {
  127. display: flex;
  128. align-items: center;
  129. justify-content: center;
  130. margin-bottom: 20rpx;
  131. width: 100%;
  132. height: 104rpx;
  133. font-size: 32rpx;
  134. color: #ff8205;
  135. border-radius: 10rpx;
  136. background-color: #fff2e5;
  137. }
  138. .box {
  139. display: flex;
  140. align-items: center;
  141. justify-content: space-between;
  142. box-sizing: border-box;
  143. padding: 30rpx 40rpx;
  144. margin-bottom: 20rpx;
  145. width: 100%;
  146. height: 200rpx;
  147. border-radius: 16rpx;
  148. background-color: #fff;
  149. box-shadow: 0 3rpx 6rpx #ccc;
  150. .box_msg {
  151. display: flex;
  152. flex-direction: column;
  153. justify-content: space-between;
  154. height: 100%;
  155. font-size: 24rpx;
  156. color: #aba6a6;
  157. .msg_name {
  158. font-size: 36rpx;
  159. color: #001713;
  160. }
  161. }
  162. .box_btn {
  163. display: flex;
  164. align-items: center;
  165. justify-content: space-between;
  166. width: 200rpx;
  167. }
  168. }
  169. }
  170. </style>