You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

addressManager.vue 5.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  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 navBgCar from "./components/nav-bg-car1";
  38. import carNumberInput from "@/components/car-number-input/car-number-input.vue";
  39. import numberplateColor from "./components/layout-numberplate-color";
  40. import {
  41. getItem,
  42. StorageKeys
  43. } from "@/utils/storage";
  44. import {
  45. stringToJson
  46. } from "@/utils/network/encryption";
  47. import navBar from "@/components/nav-bar/nav-bar2.vue";
  48. import {
  49. onLoad,
  50. onShow
  51. } from "@dcloudio/uni-app";
  52. import {
  53. addressQuery,
  54. etcCreatOrder,
  55. etcVehiclePlateVer,
  56. } from "@/utils/network/api.js";
  57. import {
  58. request
  59. } from "@/utils/network/request.js";
  60. import {
  61. reactive,
  62. } from "vue";
  63. const state = reactive({
  64. addressArray: [],
  65. fromOrder: false, //是否来自订单
  66. });
  67. const goToAddAddress = () => {
  68. uni.navigateTo({
  69. url: "/subpackage/orders/addAddress",
  70. });
  71. };
  72. const editAddress = (val) => {
  73. uni.navigateTo({
  74. url: `/subpackage/orders/editAddress?content=` + JSON.stringify(val),
  75. });
  76. };
  77. const addressSelected = (val : any) => {
  78. if (state.fromOrder) {
  79. //来自订单-直接返回选中数据
  80. uni.$emit("selectAddressSuccess", val);
  81. uni.navigateBack({
  82. delta: 1
  83. });
  84. }
  85. // state.data = {
  86. // ...state.data,
  87. // ...val
  88. // }
  89. // state.show = false;
  90. };
  91. onShow(() => {
  92. var data = {
  93. openId: getItem(StorageKeys.OpenId),
  94. };
  95. const options = {
  96. type: 2,
  97. data: data,
  98. method: "POST",
  99. showLoading: true,
  100. };
  101. request(addressQuery, options).then((res) => {
  102. state.addressArray = []
  103. const data = stringToJson(res.bizContent);
  104. if (data.data == null) {
  105. console.log("这是空");
  106. state.addressArray = []
  107. } else {
  108. state.addressArray = data.data;
  109. console.log(state.addressArray, "列表数组");
  110. }
  111. });
  112. });
  113. onLoad((option : any) => {
  114. state.fromOrder = option.fromOrder;
  115. });
  116. </script>
  117. <style lang="scss" scoped>
  118. .flex {
  119. display: flex;
  120. align-items: center;
  121. }
  122. .content-wrap {
  123. position: relative;
  124. margin-top: -50rpx;
  125. padding: 0rpx 30rpx;
  126. .title {
  127. font-size: 30rpx;
  128. font-family: Noto Sans S Chinese;
  129. font-weight: 400;
  130. color: #000000;
  131. line-height: 30rpx;
  132. margin-bottom: 30rpx;
  133. }
  134. .car-input {}
  135. .chepai-lane {
  136. margin-top: 60rpx;
  137. margin-bottom: 20rpx;
  138. }
  139. .address-lane {
  140. margin-bottom: 30rpx;
  141. .title {
  142. font-size: 30rpx;
  143. font-weight: 400;
  144. color: #000000;
  145. line-height: 30rpx;
  146. }
  147. }
  148. }
  149. .address-content {
  150. display: flex;
  151. align-items: center;
  152. justify-content: space-between;
  153. padding-bottom: 30rpx;
  154. border-bottom: 1rpx solid #dcdcdc;
  155. .name {
  156. font-size: 26rpx;
  157. font-family: Microsoft YaHei;
  158. font-weight: 400;
  159. color: #999999;
  160. font-size: 26rpx;
  161. }
  162. .phone {
  163. font-size: 26rpx;
  164. font-family: Microsoft YaHei;
  165. font-weight: 400;
  166. color: #999999;
  167. line-height: 26rpx;
  168. margin-left: 20rpx;
  169. }
  170. .arror {
  171. width: 16rpx;
  172. height: 30rpx;
  173. color: rgba(153, 153, 153, 1);
  174. }
  175. .address {
  176. font-size: 32rpx;
  177. font-family: Microsoft YaHei;
  178. font-weight: 400;
  179. color: #333333;
  180. line-height: 32rpx;
  181. }
  182. }
  183. .address-line {
  184. padding: 20px;
  185. .flex-bettwen {
  186. display: flex;
  187. align-items: center;
  188. justify-content: space-between;
  189. }
  190. .xing {
  191. width: 68rpx;
  192. height: 68rpx;
  193. background: rgba(0, 179, 139, 0.2);
  194. border-radius: 50%;
  195. font-size: 26rpx;
  196. font-weight: 400;
  197. color: #00b38b;
  198. line-height: 68rpx;
  199. text-align: center;
  200. }
  201. .content {
  202. margin-left: 20px;
  203. .name {
  204. font-size: 30rpx;
  205. font-family: Microsoft YaHei;
  206. font-weight: 500;
  207. color: #333333;
  208. }
  209. .phone {
  210. margin-left: 10rpx;
  211. font-size: 24rpx;
  212. font-family: Microsoft YaHei;
  213. font-weight: 400;
  214. color: #999999;
  215. line-height: 36rpx;
  216. }
  217. .address {
  218. margin-top: 10rpx;
  219. font-size: 26rpx;
  220. font-family: Microsoft YaHei;
  221. font-weight: 400;
  222. color: #333333;
  223. line-height: 36rpx;
  224. }
  225. .picture {
  226. width: 48rpx;
  227. height: 48rpx;
  228. }
  229. .editIcon {
  230. width: 48rpx;
  231. height: 48rpx;
  232. }
  233. }
  234. }
  235. .action {
  236. padding-bottom: 100rpx;
  237. .button {
  238. height: 80rpx;
  239. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  240. border-radius: 40rpx;
  241. font-size: 32rpx;
  242. font-weight: 400;
  243. color: #ffffff;
  244. line-height: 80rpx;
  245. }
  246. }
  247. .action-bottom {
  248. padding-bottom: 30rpx;
  249. .button {
  250. height: 80rpx;
  251. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  252. border-radius: 40rpx;
  253. font-size: 32rpx;
  254. font-weight: 400;
  255. color: #ffffff;
  256. line-height: 80rpx;
  257. }
  258. }
  259. .default {
  260. border: 1rpx solid #00b38b;
  261. border-radius: 5rpx;
  262. padding: 2rpx 4rpx;
  263. color: #00b38b;
  264. margin-left: 4rpx;
  265. }
  266. </style>