commonPeople.vue 3.8 KB

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