adresss.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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 handleAddAddress = () => {
  52. uni.navigateTo({
  53. url: '/pages_home/components/volunteerSide/addAddress'
  54. })
  55. }
  56. const handlHeader = () => {
  57. uni.navigateTo({
  58. url: `/pages_mine/pages/setupUser/Address`
  59. });
  60. }
  61. const props = defineProps({
  62. modelValue: {
  63. type: Boolean,
  64. default: false
  65. },
  66. addressInfo: {
  67. type: Object,
  68. default: () => {}
  69. },
  70. })
  71. const emits = defineEmits([
  72. 'update:modelValue',
  73. 'update:addressInfo'
  74. ])
  75. function handleChane(addressId, item) {
  76. const selectedItem = dataList.value.find(item => item.addressId === addressId);
  77. emits('update:modelValue', false)
  78. emits('update:addressInfo',selectedItem)
  79. }
  80. onMounted(() => {
  81. getListData()
  82. })
  83. const getListData = async () => {
  84. const res = await addressList()
  85. dataList.value = res.rows
  86. total.value = res.total
  87. }
  88. </script>
  89. <style lang="scss">
  90. .box {
  91. height: 100vh;
  92. width: 100vw;
  93. position: fixed;
  94. top: 0;
  95. left: 0;
  96. z-index: 999999;
  97. background: #f0f0f0;
  98. display: flex;
  99. flex-direction: column;
  100. }
  101. .address-list {
  102. flex: 1;
  103. overflow-y: auto;
  104. padding: 0 0 120rpx 0;
  105. }
  106. .footer {
  107. position: fixed;
  108. left: 0;
  109. right: 0;
  110. bottom: 0;
  111. background: transparent;
  112. display: flex;
  113. justify-content: center;
  114. align-items: center;
  115. padding-bottom: env(safe-area-inset-bottom);
  116. z-index: 1000;
  117. }
  118. .add-item {
  119. display: flex;
  120. align-items: center;
  121. justify-content: center;
  122. gap: 10rpx;
  123. background: #fff;
  124. border-radius: 40rpx;
  125. box-shadow: 0 2rpx 10rpx rgba(0,0,0,0.06);
  126. padding: 0 40rpx;
  127. height: 80rpx;
  128. margin: 20rpx 0 30rpx 0;
  129. font-size: 30rpx;
  130. color: #222;
  131. font-weight: 500;
  132. }
  133. .add-item text {
  134. font-size: 30rpx;
  135. color: #222;
  136. }
  137. .address-item {
  138. display: flex;
  139. align-items: flex-start;
  140. padding: 24rpx 0;
  141. border-bottom: 1rpx solid #f0f0f0;
  142. background: transparent;
  143. }
  144. .radio-group {
  145. flex-shrink: 0;
  146. /* 禁止压缩 */
  147. margin-right: 20rpx;
  148. }
  149. .content-wrapper {
  150. flex: 1;
  151. min-width: 0;
  152. }
  153. .edit-icon {
  154. flex-shrink: 0;
  155. margin-left: 330rpx;
  156. padding: 8rpx;
  157. }
  158. .address-text {
  159. display: inline-block;
  160. max-width: 100%;
  161. font-size: 32rpx;
  162. font-weight: 500;
  163. white-space: nowrap;
  164. overflow: hidden;
  165. text-overflow: ellipsis;
  166. }
  167. .contact-info {
  168. display: flex;
  169. gap: 20rpx;
  170. margin-top: 8rpx;
  171. }
  172. .name,
  173. .phone {
  174. font-size: 28rpx;
  175. color: #666;
  176. }
  177. .add-bottom-btn {
  178. position: fixed;
  179. left: 0;
  180. bottom: 0;
  181. width: 100vw;
  182. background: #fff;
  183. display: flex;
  184. justify-content: center;
  185. align-items: center;
  186. padding: 24rpx 0 32rpx 0;
  187. z-index: 10;
  188. box-shadow: 0 -2rpx 8rpx rgba(0,0,0,0.03);
  189. }
  190. .add-bottom-btn-inner {
  191. display: flex;
  192. align-items: center;
  193. font-size: 30rpx;
  194. color: #222;
  195. font-weight: 500;
  196. background: #fff;
  197. border-radius: 40rpx;
  198. padding: 8rpx 32rpx;
  199. box-shadow: 0 2rpx 8rpx rgba(0,0,0,0.04);
  200. }
  201. .add-bottom-btn-inner .plus {
  202. font-size: 38rpx;
  203. color: #f5b400;
  204. margin-right: 12rpx;
  205. }
  206. </style>