選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

address.vue 7.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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/orders/addAddress",
  158. });
  159. };
  160. const editAddress = (val) => {
  161. uni.navigateTo({
  162. url: `/subpackage/orders/editAddress?content=` + JSON.stringify(val),
  163. });
  164. };
  165. const nextAction = () => {
  166. const options = {
  167. type: 2,
  168. data: state.data,
  169. method: "POST",
  170. showLoading: true,
  171. };
  172. request(gongWuSupplementObu, options).then((res) => {
  173. console.log(res);
  174. const result = stringToJson(res.bizContent);
  175. if (result?.orderId) {
  176. navTo("/subpackage/orders/order-details-obu?id=" + result.orderId)
  177. } else if (res.statusCode == 600) {
  178. msg(res.errorMsg)
  179. setTimeout(() => {
  180. uni.switchTab({
  181. url: "/pages/order/order"
  182. })
  183. }, 2000)
  184. } else {
  185. msg("信息提交错误")
  186. }
  187. });
  188. }
  189. </script>
  190. <style lang="scss">
  191. page {
  192. background: #EEF7F7;
  193. }
  194. .flex {
  195. display: flex;
  196. align-items: center;
  197. }
  198. .content-wrap {
  199. position: relative;
  200. padding: 50rpx 30rpx;
  201. .title {
  202. font-size: 30rpx;
  203. font-family: Noto Sans S Chinese;
  204. font-weight: bold;
  205. color: #000000;
  206. line-height: 30rpx;
  207. margin-bottom: 30rpx;
  208. }
  209. .chepai-lane {
  210. margin-top: 60rpx;
  211. margin-bottom: 20rpx;
  212. }
  213. .address-lane {
  214. margin-bottom: 30rpx;
  215. .title {
  216. font-size: 30rpx;
  217. font-weight: bold;
  218. color: #000000;
  219. line-height: 30rpx;
  220. }
  221. }
  222. }
  223. .address-content {
  224. display: flex;
  225. align-items: center;
  226. justify-content: space-between;
  227. padding-bottom: 30rpx;
  228. border-bottom: 1rpx solid #dcdcdc;
  229. .name {
  230. font-size: 26rpx;
  231. font-family: Microsoft YaHei;
  232. font-weight: 400;
  233. color: #999999;
  234. font-size: 26rpx;
  235. }
  236. .phone {
  237. font-size: 26rpx;
  238. font-family: Microsoft YaHei;
  239. font-weight: 400;
  240. color: #999999;
  241. line-height: 26rpx;
  242. margin-left: 20rpx;
  243. }
  244. .arror .icon {
  245. width: 36rpx;
  246. height: 36rpx;
  247. }
  248. .address {
  249. font-size: 32rpx;
  250. font-family: Microsoft YaHei;
  251. font-weight: 400;
  252. color: #333333;
  253. line-height: 32rpx;
  254. }
  255. }
  256. .address-line {
  257. padding: 20px;
  258. .flex-bettwen {
  259. display: flex;
  260. align-items: center;
  261. justify-content: space-between;
  262. }
  263. .xing {
  264. width: 68rpx;
  265. height: 68rpx;
  266. background: rgba(0, 179, 139, 0.2);
  267. border-radius: 50%;
  268. font-size: 26rpx;
  269. font-weight: 400;
  270. color: #00b38b;
  271. line-height: 68rpx;
  272. text-align: center;
  273. }
  274. .content {
  275. margin-left: 20px;
  276. .name {
  277. font-size: 30rpx;
  278. font-family: Microsoft YaHei;
  279. font-weight: 500;
  280. color: #333333;
  281. }
  282. .phone {
  283. margin-left: 10rpx;
  284. font-size: 24rpx;
  285. font-family: Microsoft YaHei;
  286. font-weight: 400;
  287. color: #999999;
  288. line-height: 36rpx;
  289. }
  290. .address {
  291. margin-top: 10rpx;
  292. font-size: 26rpx;
  293. font-family: Microsoft YaHei;
  294. font-weight: 400;
  295. color: #333333;
  296. line-height: 36rpx;
  297. }
  298. .picture {
  299. width: 48rpx;
  300. height: 48rpx;
  301. }
  302. .editIcon {
  303. width: 48rpx;
  304. height: 48rpx;
  305. }
  306. }
  307. }
  308. .action {
  309. padding-bottom: 100rpx;
  310. .button {
  311. height: 80rpx;
  312. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  313. border-radius: 40rpx;
  314. font-size: 32rpx;
  315. font-weight: 400;
  316. color: #ffffff;
  317. line-height: 80rpx;
  318. }
  319. }
  320. .action-bottom {
  321. padding-bottom: 30rpx;
  322. .button {
  323. height: 80rpx;
  324. background: linear-gradient(-90deg, #43a1e0 0%, #13e7c1 100%);
  325. border-radius: 40rpx;
  326. font-size: 32rpx;
  327. font-weight: 400;
  328. color: #ffffff;
  329. line-height: 80rpx;
  330. }
  331. }
  332. </style>