adresss.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view class="box">
  3. <!-- <view class="" @click="handleChane">
  4. 改变
  5. </view> -->
  6. <up-radio-group v-model="radioValue" @change="handleChane">
  7. <view v-for="(item, index) in dataList" :key="index" class="address-item">
  8. <!-- 左侧单选框 -->
  9. <view class="radio-group">
  10. <up-radio shape="circle" activeColor="red" :name="item.addressId"></up-radio>
  11. </view>
  12. <!-- 中间内容区(自动伸缩) -->
  13. <view class="content-wrapper">
  14. <view class="address-line">
  15. <text class="address-text">
  16. {{ item.provinceName }}{{ item.cityName }}{{ item.districtName }}
  17. </text>
  18. </view>
  19. <view class="contact-info">
  20. <text class="name">{{ item.name }}</text>
  21. <text class="phone">{{ item.telephone }}</text>
  22. </view>
  23. </view>
  24. <!-- 右侧编辑图标(固定宽度) -->
  25. <view class="edit-icon" @click="hadlClickTo(item)">
  26. <up-icon name="edit-pen" size="16"></up-icon>
  27. </view>
  28. </view>
  29. </up-radio-group>
  30. </view>
  31. </template>
  32. <script setup>
  33. import {
  34. onMounted,
  35. ref
  36. } from 'vue'
  37. import {
  38. addressList
  39. } from "@/api/userSettings.js"
  40. const radioValue = ref(null)
  41. const dataList = ref([])
  42. const total = ref(0)
  43. const addressId = ref('')
  44. const onLoadOptions = ref({})
  45. const getListData = async () => {
  46. const res = await addressList()
  47. dataList.value = res.rows
  48. total.value = res.total
  49. }
  50. const props = defineProps({
  51. modelValue: {
  52. type: Boolean,
  53. default: false
  54. },
  55. addressInfo: {
  56. type: Object,
  57. default: () => {}
  58. },
  59. })
  60. const emits = defineEmits([
  61. 'update:modelValue',
  62. 'update:addressInfo'
  63. ])
  64. function handleChane(addressId, item) {
  65. const selectedItem = dataList.value.find(item => item.addressId === addressId);
  66. emits('update:modelValue', false)
  67. emits('update:addressInfo',selectedItem)
  68. }
  69. onMounted(() => {
  70. getListData()
  71. })
  72. </script>
  73. <style lang="scss">
  74. .box {
  75. height: 100vh;
  76. width: 100vw;
  77. position: fixed;
  78. top: 0;
  79. left: 0;
  80. z-index: 999999;
  81. background: #f0f0f0;
  82. }
  83. .address-list {
  84. padding: 20rpx;
  85. }
  86. .header {
  87. display: flex;
  88. justify-content: flex-end;
  89. align-items: center;
  90. margin-bottom: 20rpx;
  91. }
  92. .add-item {
  93. display: flex;
  94. align-items: center;
  95. }
  96. .add-item image {
  97. width: 40rpx;
  98. height: 40rpx;
  99. margin-right: 8rpx;
  100. }
  101. .add-item text {
  102. font-size: 25rpx;
  103. color: crimson;
  104. }
  105. .address-item {
  106. display: flex;
  107. align-items: flex-start;
  108. padding: 24rpx 0;
  109. border-bottom: 1rpx solid #f0f0f0;
  110. }
  111. .radio-group {
  112. flex-shrink: 0;
  113. /* 禁止压缩 */
  114. margin-right: 20rpx;
  115. }
  116. .content-wrapper {
  117. flex: 1;
  118. min-width: 0;
  119. }
  120. .edit-icon {
  121. flex-shrink: 0;
  122. margin-left: 330rpx;
  123. padding: 8rpx;
  124. }
  125. .address-text {
  126. display: inline-block;
  127. max-width: 100%;
  128. font-size: 32rpx;
  129. font-weight: 500;
  130. white-space: nowrap;
  131. overflow: hidden;
  132. text-overflow: ellipsis;
  133. }
  134. .contact-info {
  135. display: flex;
  136. gap: 20rpx;
  137. margin-top: 8rpx;
  138. }
  139. .name,
  140. .phone {
  141. font-size: 28rpx;
  142. color: #666;
  143. }
  144. </style>