Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

addressManager.vue 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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="button" @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. var data = {
  77. openId: getItem(StorageKeys.OpenId),
  78. };
  79. const options = {
  80. type: 2,
  81. data: data,
  82. method: "POST",
  83. showLoading: true,
  84. };
  85. requestNew(addressQueryNew, options).then((res) => {
  86. console.log("/iaw/api/address/query",res)
  87. state.addressArray = []
  88. const data = res;
  89. if (data.result.length==0) {
  90. console.log("这是空");
  91. state.addressArray = []
  92. } else {
  93. state.addressArray = data.result;
  94. console.log(state.addressArray, "列表数组");
  95. }
  96. });
  97. });
  98. onLoad((option : any) => {
  99. state.fromOrder = option.fromOrder;
  100. });
  101. </script>
  102. <style lang="scss" scoped>
  103. .flex {
  104. display: flex;
  105. align-items: center;
  106. }
  107. .content-wrap {
  108. position: relative;
  109. margin-top: -50rpx;
  110. padding: 0rpx 30rpx;
  111. .title {
  112. font-size: 30rpx;
  113. font-family: Noto Sans S Chinese;
  114. font-weight: 400;
  115. color: #000000;
  116. line-height: 30rpx;
  117. margin-bottom: 30rpx;
  118. }
  119. .car-input {}
  120. .chepai-lane {
  121. margin-top: 60rpx;
  122. margin-bottom: 20rpx;
  123. }
  124. .address-lane {
  125. margin-bottom: 30rpx;
  126. .title {
  127. font-size: 30rpx;
  128. font-weight: 400;
  129. color: #000000;
  130. line-height: 30rpx;
  131. }
  132. }
  133. }
  134. .address-content {
  135. display: flex;
  136. align-items: center;
  137. justify-content: space-between;
  138. padding-bottom: 30rpx;
  139. border-bottom: 1rpx solid #dcdcdc;
  140. .name {
  141. font-size: 26rpx;
  142. font-family: Microsoft YaHei;
  143. font-weight: 400;
  144. color: #999999;
  145. font-size: 26rpx;
  146. }
  147. .phone {
  148. font-size: 26rpx;
  149. font-family: Microsoft YaHei;
  150. font-weight: 400;
  151. color: #999999;
  152. line-height: 26rpx;
  153. margin-left: 20rpx;
  154. }
  155. .arror {
  156. width: 16rpx;
  157. height: 30rpx;
  158. color: rgba(153, 153, 153, 1);
  159. }
  160. .address {
  161. font-size: 32rpx;
  162. font-family: Microsoft YaHei;
  163. font-weight: 400;
  164. color: #333333;
  165. line-height: 32rpx;
  166. }
  167. }
  168. .address-line {
  169. padding: 20px;
  170. .flex-bettwen {
  171. display: flex;
  172. align-items: center;
  173. justify-content: space-between;
  174. }
  175. .xing {
  176. width: 68rpx;
  177. height: 68rpx;
  178. background: rgba(0, 179, 139, 0.2);
  179. border-radius: 50%;
  180. font-size: 26rpx;
  181. font-weight: 400;
  182. color: #00b38b;
  183. line-height: 68rpx;
  184. text-align: center;
  185. }
  186. .content {
  187. margin-left: 20px;
  188. .name {
  189. font-size: 30rpx;
  190. font-family: Microsoft YaHei;
  191. font-weight: 500;
  192. color: #333333;
  193. }
  194. .phone {
  195. margin-left: 10rpx;
  196. font-size: 24rpx;
  197. font-family: Microsoft YaHei;
  198. font-weight: 400;
  199. color: #999999;
  200. line-height: 36rpx;
  201. }
  202. .address {
  203. margin-top: 10rpx;
  204. font-size: 26rpx;
  205. font-family: Microsoft YaHei;
  206. font-weight: 400;
  207. color: #333333;
  208. line-height: 36rpx;
  209. }
  210. .picture {
  211. width: 48rpx;
  212. height: 48rpx;
  213. }
  214. .editIcon {
  215. width: 48rpx;
  216. height: 48rpx;
  217. }
  218. }
  219. }
  220. .action {
  221. padding-bottom: 100rpx;
  222. .button {
  223. height: 80rpx;
  224. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  225. border-radius: 40rpx;
  226. font-size: 32rpx;
  227. font-weight: 400;
  228. color: #ffffff;
  229. line-height: 80rpx;
  230. }
  231. }
  232. .action-bottom {
  233. padding-bottom: 30rpx;
  234. .button {
  235. height: 80rpx;
  236. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  237. border-radius: 40rpx;
  238. font-size: 32rpx;
  239. font-weight: 400;
  240. color: #ffffff;
  241. line-height: 80rpx;
  242. }
  243. }
  244. .default {
  245. border: 1rpx solid #00b38b;
  246. border-radius: 5rpx;
  247. padding: 2rpx 4rpx;
  248. color: #00b38b;
  249. margin-left: 4rpx;
  250. }
  251. </style>