list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <template>
  2. <view class="list">
  3. <view @click="add" class="adBbtn">
  4. <view class="label">+添加出游人</view>
  5. </view>
  6. <view v-for="item in userList" @click="check(item)" class="user-card">
  7. <view class="user-info">
  8. <view class="user-name">
  9. <view class="icon">
  10. <image class="img" src="/static/user-edit.png" mode="aspectFit" />
  11. </view>
  12. <view class="name">
  13. {{ item.userName }}
  14. </view>
  15. </view>
  16. <view class="id-number">
  17. <text class="label">身份证</text>{{ item.idCard }}
  18. </view>
  19. </view>
  20. <view class="check">
  21. <image v-if="!item.check" class="check-img" src="/static/check.png"></image>
  22. <image v-else class="check-img" src="/static/eglass-check.png"></image>
  23. </view>
  24. </view>
  25. <view class="btn-box">
  26. <view class="total-price">
  27. <view class="label">
  28. 已选择:{{ userList.filter(e => e.check).length }}人
  29. </view>
  30. </view>
  31. <button class="btn" type="default" :loading="loading" @click="submit">确认</button>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. import { getAllTravelers } from "@/api/study";
  37. export default {
  38. data() {
  39. return {
  40. userList: [],
  41. };
  42. },
  43. methods: {
  44. add() {
  45. uni.navigateTo({
  46. url: '/study/tourList/add'
  47. });
  48. },
  49. check(user) {
  50. if (user.check) {
  51. user.check = false
  52. } else {
  53. user.check = true
  54. }
  55. this.userList.filter(e => e.id !== user.id).forEach(e => {
  56. e.check = false
  57. })
  58. },
  59. submit() {
  60. const selected = this.userList.filter(e => e.check)
  61. if (selected.length === 0) {
  62. uni.showToast({
  63. title: '请选择出游人',
  64. icon: 'none'
  65. })
  66. return
  67. }
  68. uni.$emit('updateData', selected)
  69. uni.navigateBack()
  70. }
  71. },
  72. onShow() {
  73. getAllTravelers().then(({ content }) => {
  74. this.userList = content.map(e => {
  75. return {
  76. ...e,
  77. check: false
  78. }
  79. })
  80. })
  81. },
  82. };
  83. </script>
  84. <style lang="scss" scoped>
  85. .list {
  86. background: #F9F9F9;
  87. min-height: 100vh;
  88. padding: 20rpx;
  89. .adBbtn {
  90. display: flex;
  91. justify-content: center;
  92. align-items: center;
  93. background-color: #FFFFFF;
  94. .label {
  95. color: #3B83FF;
  96. font-size: 28rpx;
  97. font-weight: Bold;
  98. padding: 24rpx 0;
  99. }
  100. margin: 0 0 20rpx 0;
  101. }
  102. .user-card {
  103. padding: 24rpx;
  104. background-color: #FFFFFF;
  105. border-radius: 16rpx;
  106. display: flex;
  107. justify-content: space-between;
  108. align-items: center;
  109. margin-bottom: 20rpx;
  110. .user-info {
  111. .user-name {
  112. display: flex;
  113. align-items: center;
  114. margin-bottom: 20rpx;
  115. .icon {
  116. width: 36rpx;
  117. height: 36rpx;
  118. margin-right: 8rpx;
  119. .img {
  120. width: 100%;
  121. height: 100%;
  122. }
  123. }
  124. .name {
  125. font-size: 28rpx;
  126. color: #222222;
  127. font-weight: bold;
  128. }
  129. }
  130. .id-number {
  131. padding-left: 44rpx;
  132. font-size: 24rpx;
  133. color: #222222;
  134. .label {
  135. margin-right: 20rpx;
  136. }
  137. }
  138. }
  139. .check {
  140. width: 40rpx;
  141. height: 40rpx;
  142. .check-img {
  143. width: 100%;
  144. height: 100%;
  145. }
  146. }
  147. }
  148. .btn-box {
  149. position: fixed;
  150. bottom: 0%;
  151. left: 0%;
  152. width: 100%;
  153. display: flex;
  154. align-items: center;
  155. justify-content: space-between;
  156. box-sizing: border-box;
  157. padding: 10rpx 30rpx env(safe-area-inset-bottom);
  158. border-top: 1rpx solid #EEEEEE;
  159. .total-price {
  160. .label {
  161. color: #AAAAAA;
  162. font-size: 28rpx;
  163. }
  164. }
  165. .btn {
  166. width: 280rpx;
  167. height: 80rpx;
  168. line-height: 80rpx;
  169. text-align: center;
  170. background: #3B83FF;
  171. box-shadow: inset 0rpx 6rpx 12rpx 2rpx rgba(255, 255, 255, 0.16);
  172. border-radius: 46rpx 46rpx 46rpx 46rpx;
  173. font-weight: 800;
  174. color: #FFFFFF;
  175. font-size: 28rpx;
  176. margin: 0;
  177. }
  178. }
  179. }
  180. </style>