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