index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <view class="address-list">
  3. <!-- 上方区域:图片和"新增"文字在右边 -->
  4. <view class="header">
  5. <view class="add-item" @click="handlHeader">
  6. <image src="../../../static/img/新增.png" mode=""></image>
  7. <text>新增</text>
  8. </view>
  9. </view>
  10. <up-radio-group v-model="radioValue">
  11. <view v-for="(item, index) in dataList" :key="index" class="address-item">
  12. <!-- 左侧单选框 -->
  13. <view class="radio-group">
  14. <up-radio shape="circle" activeColor="red" :name="item.addressId"></up-radio>
  15. </view>
  16. <!-- 中间内容区(自动伸缩) -->
  17. <view class="content-wrapper">
  18. <view class="address-line">
  19. <text class="address-text">
  20. {{ item.provinceName }}{{ item.cityName }}{{ item.districtName }}
  21. </text>
  22. </view>
  23. <view class="contact-info">
  24. <text class="name">{{ item.name }}</text>
  25. <text class="phone">{{ item.telephone }}</text>
  26. </view>
  27. </view>
  28. <!-- 右侧编辑图标(固定宽度) -->
  29. <view class="edit-icon" @click="hadlClickTo(item)">
  30. <up-icon name="edit-pen" size="16"></up-icon>
  31. </view>
  32. </view>
  33. </up-radio-group>
  34. </view>
  35. </template>
  36. <script setup>
  37. import {
  38. onMounted,
  39. ref
  40. } from 'vue'
  41. import {
  42. addressList
  43. } from "@/api/userSettings.js"
  44. const radioValue = ref(null)
  45. const dataList = ref([])
  46. const total = ref(0)
  47. const addressId = ref('')
  48. const getListData = async () => {
  49. const res = await addressList()
  50. dataList.value = res.rows
  51. total.value = res.total
  52. console.log(dataList.value, '>>>>>dataList.value');
  53. }
  54. const hadlClickTo = (item) => {
  55. const {
  56. address,
  57. addressId,
  58. age,
  59. cityName,
  60. districtName,
  61. label,
  62. name,
  63. provinceName,
  64. sex,
  65. telephone,
  66. haveContagion
  67. } = item;
  68. // 手动构建查询参数
  69. const params =
  70. `address=${encodeURIComponent(address)}&addressId=${encodeURIComponent(addressId)}&age=${encodeURIComponent(age)}&cityName=${encodeURIComponent(cityName)}&districtName=${encodeURIComponent(districtName)}&label=${encodeURIComponent(label)}&name=${encodeURIComponent(name)}&provinceName=${encodeURIComponent(provinceName)}&sex=${encodeURIComponent(sex)}&telephone=${encodeURIComponent(telephone)}&haveContagion=${encodeURIComponent(haveContagion)}`;
  71. // 使用拼接的查询参数进行页面跳转
  72. uni.navigateTo({
  73. url: `/pages_mine/pages/selectAddress/edit?${params}`
  74. });
  75. };
  76. const handlHeader = ()=>{
  77. uni.navigateTo({
  78. url: `/pages_mine/pages/setupUser/Address`
  79. });
  80. }
  81. onMounted(() => {
  82. getListData()
  83. })
  84. </script>
  85. <style scoped>
  86. .address-list {
  87. padding: 20rpx;
  88. }
  89. .header {
  90. display: flex;
  91. justify-content: flex-end;
  92. align-items: center;
  93. margin-bottom: 20rpx;
  94. }
  95. .add-item {
  96. display: flex;
  97. align-items: center;
  98. }
  99. .add-item image {
  100. width: 40rpx;
  101. height: 40rpx;
  102. margin-right: 8rpx;
  103. }
  104. .add-item text {
  105. font-size: 25rpx;
  106. color: crimson;
  107. }
  108. .address-item {
  109. display: flex;
  110. align-items: flex-start;
  111. padding: 24rpx 0;
  112. border-bottom: 1rpx solid #f0f0f0;
  113. }
  114. .radio-group {
  115. flex-shrink: 0;
  116. /* 禁止压缩 */
  117. margin-right: 20rpx;
  118. }
  119. .content-wrapper {
  120. flex: 1;
  121. min-width: 0;
  122. }
  123. .edit-icon {
  124. flex-shrink: 0;
  125. margin-left: 300rpx;
  126. padding: 8rpx;
  127. }
  128. .address-text {
  129. display: inline-block;
  130. max-width: 100%;
  131. font-size: 32rpx;
  132. font-weight: 500;
  133. white-space: nowrap;
  134. overflow: hidden;
  135. text-overflow: ellipsis;
  136. }
  137. .contact-info {
  138. display: flex;
  139. gap: 20rpx;
  140. margin-top: 8rpx;
  141. }
  142. .name,
  143. .phone {
  144. font-size: 28rpx;
  145. color: #666;
  146. }
  147. </style>