Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

addressManager.vue 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view class="address-line">
  3. <view v-for="(item, index) in state.addressArray" :key="index" @click="addressSelected(item)"
  4. style="margin-bottom: 60rpx" class="flex-bettwen">
  5. <view class="flex">
  6. <view class="xing">
  7. {{ item.consignee.charAt(0) }}
  8. </view>
  9. <view class="content">
  10. <view class="flex">
  11. <view class="name">
  12. {{ item.consignee }}
  13. </view>
  14. <view class="phone">
  15. {{ item.consigneeTel }}
  16. <text class="default" v-if="item.defaultAddress==1">默认</text>
  17. </view>
  18. </view>
  19. <view class="address">
  20. {{ item.region + item.address }}
  21. </view>
  22. </view>
  23. </view>
  24. <view @click.stop="editAddress(item)" style="margin-left: 80rpx" class="picture">
  25. <image :showLoading="true" :src="`${$imgUrl}applyCard/edit.png`" style="width: 48rpx; height: 48rpx">
  26. </image>
  27. </view>
  28. </view>
  29. <view :style="state.addressArray.length > 0 ? 'margin-top: 60rpx;' : ''" class="action-bottom">
  30. <button type="default" class="ui-btn" @click="goToAddAddress()">
  31. 添加收货地址
  32. </button>
  33. </view>
  34. </view>
  35. </template>
  36. <script setup lang="ts">
  37. import {
  38. getItem,
  39. StorageKeys
  40. } from "@/utils/storage";
  41. import {
  42. onLoad,
  43. onShow
  44. } from "@dcloudio/uni-app";
  45. import {
  46. addressQueryNew,
  47. } from "@/utils/network/api.js";
  48. import { requestNew} from "@/utils/network/request.js";
  49. import {
  50. reactive,
  51. } from "vue";
  52. const state = reactive({
  53. addressArray: [],
  54. fromOrder: false, //是否来自订单
  55. });
  56. const goToAddAddress = () => {
  57. uni.navigateTo({
  58. url: "/subpackage/orders/addAddress",
  59. });
  60. };
  61. const editAddress = (val) => {
  62. uni.navigateTo({
  63. url: `/subpackage/orders/editAddress?content=` + JSON.stringify(val),
  64. });
  65. };
  66. const addressSelected = (val : any) => {
  67. if (state.fromOrder) {
  68. //来自订单-直接返回选中数据
  69. uni.$emit("selectAddressSuccess", val);
  70. uni.navigateBack({
  71. delta: 1
  72. });
  73. }
  74. };
  75. onShow(() => {
  76. const options = {
  77. type: 2,
  78. data: {},
  79. method: "POST",
  80. showLoading: true,
  81. };
  82. requestNew(addressQueryNew, options).then((res) => {
  83. console.log("/iaw/api/address/query",res)
  84. state.addressArray = []
  85. const data = res;
  86. if (data.result.length==0) {
  87. console.log("这是空");
  88. state.addressArray = []
  89. } else {
  90. state.addressArray = data.result;
  91. console.log(state.addressArray, "列表数组");
  92. }
  93. });
  94. });
  95. onLoad((option : any) => {
  96. state.fromOrder = option.fromOrder;
  97. });
  98. </script>
  99. <style lang="scss" scoped>
  100. .flex {
  101. display: flex;
  102. align-items: center;
  103. }
  104. .content-wrap {
  105. position: relative;
  106. margin-top: -50rpx;
  107. padding: 0rpx 30rpx;
  108. .title {
  109. font-size: 30rpx;
  110. font-family: Noto Sans S Chinese;
  111. font-weight: 400;
  112. color: #000000;
  113. line-height: 30rpx;
  114. margin-bottom: 30rpx;
  115. }
  116. .car-input {}
  117. .chepai-lane {
  118. margin-top: 60rpx;
  119. margin-bottom: 20rpx;
  120. }
  121. .address-lane {
  122. margin-bottom: 30rpx;
  123. .title {
  124. font-size: 30rpx;
  125. font-weight: 400;
  126. color: #000000;
  127. line-height: 30rpx;
  128. }
  129. }
  130. }
  131. .address-content {
  132. display: flex;
  133. align-items: center;
  134. justify-content: space-between;
  135. padding-bottom: 30rpx;
  136. border-bottom: 1rpx solid #dcdcdc;
  137. .name {
  138. font-size: 26rpx;
  139. font-family: Microsoft YaHei;
  140. font-weight: 400;
  141. color: #999999;
  142. font-size: 26rpx;
  143. }
  144. .phone {
  145. font-size: 26rpx;
  146. font-family: Microsoft YaHei;
  147. font-weight: 400;
  148. color: #999999;
  149. line-height: 26rpx;
  150. margin-left: 20rpx;
  151. }
  152. .arror {
  153. width: 16rpx;
  154. height: 30rpx;
  155. color: rgba(153, 153, 153, 1);
  156. }
  157. .address {
  158. font-size: 32rpx;
  159. font-family: Microsoft YaHei;
  160. font-weight: 400;
  161. color: #333333;
  162. line-height: 32rpx;
  163. }
  164. }
  165. .address-line {
  166. padding: 20px;
  167. .flex-bettwen {
  168. display: flex;
  169. align-items: center;
  170. justify-content: space-between;
  171. }
  172. .xing {
  173. width: 68rpx;
  174. height: 68rpx;
  175. background: rgba(0, 69, 118, 0.2);
  176. border-radius: 50%;
  177. font-size: 26rpx;
  178. font-weight: 400;
  179. color:white;
  180. line-height: 68rpx;
  181. text-align: center;
  182. }
  183. .content {
  184. margin-left: 20px;
  185. .name {
  186. font-size: 30rpx;
  187. font-family: Microsoft YaHei;
  188. font-weight: 500;
  189. color: #333333;
  190. }
  191. .phone {
  192. margin-left: 10rpx;
  193. font-size: 24rpx;
  194. font-family: Microsoft YaHei;
  195. font-weight: 400;
  196. color: #999999;
  197. line-height: 36rpx;
  198. }
  199. .address {
  200. margin-top: 10rpx;
  201. font-size: 26rpx;
  202. font-family: Microsoft YaHei;
  203. font-weight: 400;
  204. color: #333333;
  205. line-height: 36rpx;
  206. }
  207. .picture {
  208. width: 48rpx;
  209. height: 48rpx;
  210. }
  211. .editIcon {
  212. width: 48rpx;
  213. height: 48rpx;
  214. }
  215. }
  216. }
  217. .action-bottom {
  218. padding-bottom: 30rpx;
  219. }
  220. .default {
  221. border: 1rpx solid #004576;
  222. border-radius: 5rpx;
  223. padding: 2rpx 4rpx;
  224. color: #004576;
  225. margin-left: 4rpx;
  226. }
  227. </style>