Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

address.vue 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. <template>
  2. <view class="content-wrap">
  3. <!-- 收货地址 -->
  4. <view v-if="!state.data.address" class="address-lane">
  5. <view class="title">请选择或新增收货地址</view>
  6. <view style="margin-top: 30rpx" class="action">
  7. <button type="default" class="button" @click="state.show = true">
  8. 添加收货地址
  9. </button>
  10. </view>
  11. </view>
  12. <view v-if="state.data.address" class="address-lane">
  13. <view class="title">收货地址</view>
  14. <view @click="state.show = true" class="address-content" style="margin-top: 30rpx">
  15. <view class="flex">
  16. <image :showLoading="true" :src="`${$imgUrl}applyCard/location.png`"
  17. style="width: 48rpx; height: 48rpx">
  18. </image>
  19. <view style="margin-left: 18rpx" class="">
  20. <view class="address">
  21. {{ state.data.region + state.data.address }}
  22. </view>
  23. <view style="margin-top: 15rpx" class="flex">
  24. <view class="name">
  25. {{ state.data.consignee }}
  26. </view>
  27. <view class="phone">
  28. {{ state.data.consigneeTel }}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="arror">
  34. <image :src="`${$imgUrl}common/arror-right.png`" class="icon"></image>
  35. </view>
  36. </view>
  37. <view style="margin-top: 30rpx" class="action">
  38. <button type="default" class="button" @click="nextAction()">
  39. 下一步
  40. </button>
  41. </view>
  42. </view>
  43. </view>
  44. <u-popup mode="bottom" v-model="state.show">
  45. <view class="address-line">
  46. <view v-if="state.addressArray" v-for="(item, index) in state.addressArray" :key="index"
  47. @click="addressSelected(item)" style="margin-bottom: 60rpx" class="flex-bettwen">
  48. <view class="flex">
  49. <view class="xing">
  50. {{ item.consignee.charAt(0) }}
  51. </view>
  52. <view class="content">
  53. <view class="flex">
  54. <view class="name">
  55. {{ item.consignee }}
  56. </view>
  57. <view class="phone">
  58. {{ item.consigneeTel }}
  59. </view>
  60. </view>
  61. <view class="address">
  62. {{ item.region + item.address }}
  63. </view>
  64. </view>
  65. </view>
  66. <view @click.stop="editAddress(item)" style="margin-left: 80rpx" class="picture">
  67. <image :showLoading="true" :src="`${$imgUrl}applyCard/edit.png`"
  68. style="width: 48rpx; height: 48rpx"></image>
  69. </view>
  70. </view>
  71. <view :style="state.addressArray ? 'margin-top: 60rpx;' : ''" class="action-bottom">
  72. <button type="default" class="button" @click="goToAddAddress()">
  73. 添加收货地址
  74. </button>
  75. </view>
  76. </view>
  77. </u-popup>
  78. </template>
  79. <script setup lang="ts">
  80. import {
  81. reactive
  82. } from "vue";
  83. import {
  84. getItem,
  85. StorageKeys
  86. } from "@/utils/storage";
  87. import {
  88. stringToJson
  89. } from "@/utils/network/encryption";
  90. import {
  91. addressQuery,
  92. gongWuSupplementObu
  93. } from "@/utils/network/api.js";
  94. import {
  95. request
  96. } from "@/utils/network/request.js";
  97. import {
  98. onLoad,
  99. onShow
  100. } from "@dcloudio/uni-app";
  101. import {
  102. navTo,
  103. confirm,
  104. msg
  105. } from "@/utils/utils";
  106. onLoad((option) => {
  107. state.data.openId = getItem(StorageKeys.OpenId);
  108. state.data.vehicleId = option.vehicleId;
  109. state.data.deptId = option.deptId;
  110. });
  111. onShow(() => {
  112. var data = {
  113. openId: getItem(StorageKeys.OpenId),
  114. };
  115. const options = {
  116. type: 2,
  117. data: data,
  118. method: "POST",
  119. showLoading: true,
  120. };
  121. request(addressQuery, options).then((res) => {
  122. console.log(res);
  123. const data = stringToJson(res.bizContent);
  124. state.addressArray = data.data;
  125. });
  126. });
  127. const state = reactive({
  128. data: {
  129. openId: "",
  130. orderSource: "WECHAT",
  131. receiveMethod: 0,
  132. deptId: 0,
  133. vehicleId: "",
  134. consignee: "", //收货人
  135. consigneeTel: "", //收货电话
  136. region: "",
  137. address: "",
  138. postalCode: "",
  139. postCode: "",
  140. area: "",
  141. },
  142. show: false,
  143. addressArray: undefined,
  144. });
  145. const addressSelected = (val: any) => {
  146. console.log(val);
  147. state.data = {
  148. ...state.data,
  149. ...val,
  150. };
  151. state.data.postCode = val.postalCode;
  152. state.data.area = val.region;
  153. state.show = false;
  154. };
  155. const goToAddAddress = () => {
  156. uni.navigateTo({
  157. url: "/subpackage/applyCard/addAddress",
  158. });
  159. };
  160. const editAddress = (val) => {
  161. uni.navigateTo({
  162. url: `/subpackage/applyCard/editAddress?content=` + JSON.stringify(val),
  163. });
  164. };
  165. const nextAction = () => {
  166. console.log("下一步");
  167. console.log(state.data);
  168. const options = {
  169. type: 2,
  170. data: state.data,
  171. method: "POST",
  172. showLoading: true,
  173. };
  174. request(gongWuSupplementObu, options).then((res) => {
  175. console.log(res);
  176. const result = stringToJson(res.bizContent);
  177. if (result?.orderId) {
  178. // console.log(888888888);
  179. navTo("/subpackage/orders/order-details-obu?id=" + result.orderId)
  180. } else if (res.statusCode == 600) {
  181. msg(res.errorMsg)
  182. setTimeout(()=>{
  183. uni.switchTab({
  184. url: "/pages/order/order"
  185. })
  186. },2000)
  187. } else {
  188. msg("信息提交错误")
  189. }
  190. });
  191. }
  192. </script>
  193. <style lang="scss">
  194. page {
  195. background: #EEF7F7;
  196. }
  197. .flex {
  198. display: flex;
  199. align-items: center;
  200. }
  201. .content-wrap {
  202. position: relative;
  203. padding: 50rpx 30rpx;
  204. .title {
  205. font-size: 30rpx;
  206. font-family: Noto Sans S Chinese;
  207. font-weight: bold;
  208. color: #000000;
  209. line-height: 30rpx;
  210. margin-bottom: 30rpx;
  211. }
  212. .car-input {}
  213. .chepai-lane {
  214. margin-top: 60rpx;
  215. margin-bottom: 20rpx;
  216. }
  217. .address-lane {
  218. margin-bottom: 30rpx;
  219. .title {
  220. font-size: 30rpx;
  221. font-weight: bold;
  222. color: #000000;
  223. line-height: 30rpx;
  224. }
  225. }
  226. }
  227. .address-content {
  228. display: flex;
  229. align-items: center;
  230. justify-content: space-between;
  231. padding-bottom: 30rpx;
  232. border-bottom: 1rpx solid #dcdcdc;
  233. .name {
  234. font-size: 26rpx;
  235. font-family: Microsoft YaHei;
  236. font-weight: 400;
  237. color: #999999;
  238. font-size: 26rpx;
  239. }
  240. .phone {
  241. font-size: 26rpx;
  242. font-family: Microsoft YaHei;
  243. font-weight: 400;
  244. color: #999999;
  245. line-height: 26rpx;
  246. margin-left: 20rpx;
  247. }
  248. .arror .icon {
  249. width: 36rpx;
  250. height: 36rpx;
  251. }
  252. .address {
  253. font-size: 32rpx;
  254. font-family: Microsoft YaHei;
  255. font-weight: 400;
  256. color: #333333;
  257. line-height: 32rpx;
  258. }
  259. }
  260. .address-line {
  261. padding: 20px;
  262. .flex-bettwen {
  263. display: flex;
  264. align-items: center;
  265. justify-content: space-between;
  266. }
  267. .xing {
  268. width: 68rpx;
  269. height: 68rpx;
  270. background: rgba(0, 179, 139, 0.2);
  271. border-radius: 50%;
  272. font-size: 26rpx;
  273. font-weight: 400;
  274. color: #00b38b;
  275. line-height: 68rpx;
  276. text-align: center;
  277. }
  278. .content {
  279. margin-left: 20px;
  280. .name {
  281. font-size: 30rpx;
  282. font-family: Microsoft YaHei;
  283. font-weight: 500;
  284. color: #333333;
  285. }
  286. .phone {
  287. margin-left: 10rpx;
  288. font-size: 24rpx;
  289. font-family: Microsoft YaHei;
  290. font-weight: 400;
  291. color: #999999;
  292. line-height: 36rpx;
  293. }
  294. .address {
  295. margin-top: 10rpx;
  296. font-size: 26rpx;
  297. font-family: Microsoft YaHei;
  298. font-weight: 400;
  299. color: #333333;
  300. line-height: 36rpx;
  301. }
  302. .picture {
  303. width: 48rpx;
  304. height: 48rpx;
  305. }
  306. .editIcon {
  307. width: 48rpx;
  308. height: 48rpx;
  309. }
  310. }
  311. }
  312. .action {
  313. padding-bottom: 100rpx;
  314. .button {
  315. height: 80rpx;
  316. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  317. border-radius: 40rpx;
  318. font-size: 32rpx;
  319. font-weight: 400;
  320. color: #ffffff;
  321. line-height: 80rpx;
  322. }
  323. }
  324. .action-bottom {
  325. padding-bottom: 30rpx;
  326. .button {
  327. height: 80rpx;
  328. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  329. border-radius: 40rpx;
  330. font-size: 32rpx;
  331. font-weight: 400;
  332. color: #ffffff;
  333. line-height: 80rpx;
  334. }
  335. }
  336. </style>