index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="address-list">
  3. <view v-for="(item, index) in dataList" :key="index" class="address-item">
  4. <!-- 左侧单选框 -->
  5. <view class="radio-group">
  6. <up-radio-group v-model="value">
  7. <up-radio shape="circle"></up-radio>
  8. </up-radio-group>
  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. </view>
  28. </template>
  29. <script setup>
  30. import {
  31. onMounted,
  32. ref
  33. } from 'vue'
  34. import {
  35. addressList
  36. } from "@/api/userSettings.js"
  37. const value = ref('')
  38. const dataList = ref([])
  39. const total = ref(0)
  40. const addressId = ref('')
  41. const getListData = async () => {
  42. const res = await addressList()
  43. dataList.value = res.rows
  44. total.value = res.total
  45. }
  46. const hadlClickTo = (item) => {
  47. const {
  48. address,
  49. addressId,
  50. age,
  51. cityName,
  52. districtName,
  53. label,
  54. name,
  55. provinceName,
  56. sex,
  57. telephone,
  58. haveContagion
  59. } = item;
  60. // 手动构建查询参数
  61. const params =
  62. `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)}`;
  63. // 使用拼接的查询参数进行页面跳转
  64. uni.navigateTo({
  65. url: `/pages_mine/pages/selectAddress/edit?${params}`
  66. });
  67. };
  68. onMounted(() => {
  69. getListData()
  70. })
  71. </script>
  72. <style scoped>
  73. .address-list {
  74. padding: 20rpx;
  75. }
  76. .address-item {
  77. display: flex;
  78. align-items: flex-start;
  79. padding: 24rpx 0;
  80. border-bottom: 1rpx solid #f0f0f0;
  81. }
  82. .radio-group {
  83. flex-shrink: 0;
  84. /* 禁止压缩 */
  85. margin-right: 20rpx;
  86. }
  87. .content-wrapper {
  88. flex: 1;
  89. min-width: 0;
  90. }
  91. .edit-icon {
  92. flex-shrink: 0;
  93. margin-left: 20rpx;
  94. padding: 8rpx;
  95. }
  96. .address-text {
  97. display: inline-block;
  98. max-width: 100%;
  99. font-size: 32rpx;
  100. font-weight: 500;
  101. white-space: nowrap;
  102. overflow: hidden;
  103. text-overflow: ellipsis;
  104. }
  105. .contact-info {
  106. display: flex;
  107. gap: 20rpx;
  108. margin-top: 8rpx;
  109. }
  110. .name,
  111. .phone {
  112. font-size: 28rpx;
  113. color: #666;
  114. }
  115. </style>