change.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <view class="container">
  3. <view class="body">
  4. <!-- 每一个小孩区域 -->
  5. <view class="body_box" v-for="item in list" :key="item.id" @click="change(item)">
  6. <radio class="box_radio" :checked="item.isCheck" color="#1E7DFB" />
  7. <view class="box_info">
  8. <view class="">{{ item.name }}</view>
  9. <view class="">{{ item.cardNo }}</view>
  10. </view>
  11. </view>
  12. <!-- 确认按钮区域 -->
  13. <view class="body_btn" @click="handleConfirm">确认</view>
  14. </view>
  15. </view>
  16. </template>
  17. <script setup>
  18. import { ref } from 'vue'
  19. import { onLoad } from '@dcloudio/uni-app'
  20. onLoad((options) => {
  21. list.value = JSON.parse(options.list) || []
  22. currentId.value = options.id
  23. list.value.forEach((ele) => {
  24. if (ele.id == currentId.value) {
  25. ele.isCheck = true
  26. }
  27. })
  28. })
  29. const currentId = ref()
  30. // 小孩列表数据
  31. const list = ref([])
  32. const change = (item) => {
  33. list.value.forEach((ele) => {
  34. ele.isCheck = false
  35. })
  36. item.isCheck = !item.isCheck
  37. }
  38. // 确认按钮回调
  39. const handleConfirm = () => {
  40. const temObj = list.value.find((ele) => ele.isCheck)
  41. uni.$emit('updateObj', temObj)
  42. uni.navigateBack(1)
  43. }
  44. </script>
  45. <style lang="scss" scoped>
  46. .container {
  47. display: flex;
  48. flex-direction: column;
  49. min-height: 100vh;
  50. background-color: #f1f6fe;
  51. .body {
  52. padding-left: 20rpx;
  53. margin-top: 20rpx;
  54. height: calc(100vh - 20rpx);
  55. background-color: #fff;
  56. .body_box {
  57. display: flex;
  58. align-items: center;
  59. height: 170rpx;
  60. border-bottom: 1rpx solid #e6e6e6;
  61. .box_radio {
  62. margin-left: 20rpx;
  63. }
  64. .box_info {
  65. display: flex;
  66. flex-direction: column;
  67. justify-content: space-between;
  68. margin-left: 40rpx;
  69. height: 95rpx;
  70. }
  71. }
  72. .body_btn {
  73. margin: auto;
  74. margin-top: 400rpx;
  75. display: flex;
  76. justify-content: center;
  77. align-items: center;
  78. width: 297rpx;
  79. height: 100rpx;
  80. color: #fff;
  81. font-size: 32rpx;
  82. border-radius: 8rpx;
  83. background-color: #1e7dfb;
  84. }
  85. }
  86. }
  87. </style>