adresss.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <template>
  2. <view class="box">
  3. <view class="address-list">
  4. <up-radio-group v-model="radioValue" @change="handleChane">
  5. <view v-for="(item, index) in dataList" :key="index" class="address-item">
  6. <!-- 左侧单选框 -->
  7. <view class="radio-group">
  8. <up-radio shape="circle" activeColor="red" :name="item.addressId"></up-radio>
  9. </view>
  10. <!-- 中间内容区(自动伸缩) -->
  11. <view class="content-wrapper">
  12. <view class="address-line">
  13. <text class="address-text">
  14. {{ item.provinceName }}{{ item.cityName }}{{ item.districtName }}
  15. </text>
  16. </view>
  17. <view class="contact-info">
  18. <text class="name">{{ item.name }}</text>
  19. <text class="phone">{{ item.telephone }}</text>
  20. </view>
  21. </view>
  22. <!-- 右侧编辑图标(固定宽度) -->
  23. <view class="edit-icon" @click="hadlClickTo(item)">
  24. <up-icon name="edit-pen" size="16"></up-icon>
  25. </view>
  26. </view>
  27. </up-radio-group>
  28. </view>
  29. <!-- 底部新增按钮 -->
  30. <view class="add-bottom-btn" @click="handlHeader">
  31. <view class="add-bottom-btn-inner">
  32. <text class="plus">+</text>
  33. <text>新增收货地址</text>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script setup>
  39. import {
  40. onMounted,
  41. ref
  42. } from 'vue'
  43. import {
  44. addressList
  45. } from "@/api/userSettings.js"
  46. const radioValue = ref(null)
  47. const dataList = ref([])
  48. const total = ref(0)
  49. const addressId = ref('')
  50. const onLoadOptions = ref({})
  51. const handlHeader = () => {
  52. uni.navigateTo({
  53. url: `/pages_home/pages/setupUser/Address`
  54. });
  55. }
  56. const props = defineProps({
  57. modelValue: {
  58. type: Boolean,
  59. default: false
  60. },
  61. addressInfo: {
  62. type: Object,
  63. default: () => {}
  64. },
  65. })
  66. const emits = defineEmits([
  67. 'update:modelValue',
  68. 'update:addressInfo'
  69. ])
  70. function handleChane(addressId, item) {
  71. const selectedItem = dataList.value.find(item => item.addressId === addressId);
  72. emits('update:modelValue', false)
  73. emits('update:addressInfo',selectedItem)
  74. }
  75. onMounted(() => {
  76. getListData()
  77. })
  78. const getListData = async () => {
  79. const res = await addressList()
  80. dataList.value = res.rows
  81. total.value = res.total
  82. }
  83. </script>
  84. <style lang="scss">
  85. .box {
  86. height: 100vh;
  87. width: 100vw;
  88. position: fixed;
  89. top: 0;
  90. left: 0;
  91. z-index: 999999;
  92. background: #f0f0f0;
  93. display: flex;
  94. flex-direction: column;
  95. }
  96. .address-list {
  97. flex: 1;
  98. overflow-y: auto;
  99. padding: 0 0 120rpx 0;
  100. }
  101. .footer {
  102. position: fixed;
  103. left: 0;
  104. right: 0;
  105. bottom: 0;
  106. background: transparent;
  107. display: flex;
  108. justify-content: center;
  109. align-items: center;
  110. padding-bottom: env(safe-area-inset-bottom);
  111. z-index: 1000;
  112. }
  113. .add-item {
  114. display: flex;
  115. align-items: center;
  116. justify-content: center;
  117. gap: 10rpx;
  118. background: #fff;
  119. border-radius: 40rpx;
  120. box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.06);
  121. padding: 0 40rpx;
  122. height: 80rpx;
  123. margin: 20rpx 0 30rpx 0;
  124. font-size: 30rpx;
  125. color: #222;
  126. font-weight: 500;
  127. }
  128. .add-item text {
  129. font-size: 30rpx;
  130. color: #222;
  131. }
  132. .address-item {
  133. display: flex;
  134. align-items: flex-start;
  135. padding: 24rpx 0;
  136. border-bottom: 1rpx solid #f0f0f0;
  137. background: transparent;
  138. }
  139. .radio-group {
  140. flex-shrink: 0;
  141. /* 禁止压缩 */
  142. margin-right: 20rpx;
  143. }
  144. .content-wrapper {
  145. flex: 1;
  146. min-width: 0;
  147. }
  148. .edit-icon {
  149. flex-shrink: 0;
  150. margin-left: 330rpx;
  151. padding: 8rpx;
  152. }
  153. .address-text {
  154. display: inline-block;
  155. max-width: 100%;
  156. font-size: 32rpx;
  157. font-weight: 500;
  158. white-space: nowrap;
  159. overflow: hidden;
  160. text-overflow: ellipsis;
  161. }
  162. .contact-info {
  163. display: flex;
  164. gap: 20rpx;
  165. margin-top: 8rpx;
  166. }
  167. .name,
  168. .phone {
  169. font-size: 28rpx;
  170. color: #666;
  171. }
  172. .add-bottom-btn {
  173. position: fixed;
  174. left: 0;
  175. bottom: 0;
  176. width: 100vw;
  177. background: #fff;
  178. display: flex;
  179. justify-content: center;
  180. align-items: center;
  181. padding: 24rpx 0 32rpx 0;
  182. z-index: 10;
  183. box-shadow: 0 -2rpx 8rpx rgba(0,0,0,0.03);
  184. }
  185. .add-bottom-btn-inner {
  186. display: flex;
  187. align-items: center;
  188. font-size: 30rpx;
  189. color: #222;
  190. font-weight: 500;
  191. background: #fff;
  192. border-radius: 40rpx;
  193. padding: 8rpx 32rpx;
  194. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  195. }
  196. .add-bottom-btn-inner .plus {
  197. font-size: 38rpx;
  198. color: #f5b400;
  199. margin-right: 12rpx;
  200. }
  201. </style>