index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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="value">
  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"></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 value = ref('')
  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. }
  53. const hadlClickTo = (item) => {
  54. const {
  55. address,
  56. addressId,
  57. age,
  58. cityName,
  59. districtName,
  60. label,
  61. name,
  62. provinceName,
  63. sex,
  64. telephone,
  65. haveContagion
  66. } = item;
  67. // 手动构建查询参数
  68. const params =
  69. `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)}`;
  70. // 使用拼接的查询参数进行页面跳转
  71. uni.navigateTo({
  72. url: `/pages_mine/pages/selectAddress/edit?${params}`
  73. });
  74. };
  75. const handlHeader = ()=>{
  76. uni.navigateTo({
  77. url: `/pages_mine/pages/setupUser/Address`
  78. });
  79. }
  80. onMounted(() => {
  81. getListData()
  82. })
  83. </script>
  84. <style scoped>
  85. .address-list {
  86. padding: 20rpx;
  87. }
  88. .header {
  89. display: flex;
  90. justify-content: flex-end;
  91. align-items: center;
  92. margin-bottom: 20rpx;
  93. }
  94. .add-item {
  95. display: flex;
  96. align-items: center;
  97. }
  98. .add-item image {
  99. width: 40rpx;
  100. height: 40rpx;
  101. margin-right: 8rpx;
  102. }
  103. .add-item text {
  104. font-size: 25rpx;
  105. color: crimson;
  106. }
  107. .address-item {
  108. display: flex;
  109. align-items: flex-start;
  110. padding: 24rpx 0;
  111. border-bottom: 1rpx solid #f0f0f0;
  112. }
  113. .radio-group {
  114. flex-shrink: 0;
  115. /* 禁止压缩 */
  116. margin-right: 20rpx;
  117. }
  118. .content-wrapper {
  119. flex: 1;
  120. min-width: 0;
  121. }
  122. .edit-icon {
  123. flex-shrink: 0;
  124. margin-left: 300rpx;
  125. padding: 8rpx;
  126. }
  127. .address-text {
  128. display: inline-block;
  129. max-width: 100%;
  130. font-size: 32rpx;
  131. font-weight: 500;
  132. white-space: nowrap;
  133. overflow: hidden;
  134. text-overflow: ellipsis;
  135. }
  136. .contact-info {
  137. display: flex;
  138. gap: 20rpx;
  139. margin-top: 8rpx;
  140. }
  141. .name,
  142. .phone {
  143. font-size: 28rpx;
  144. color: #666;
  145. }
  146. </style>