update-address.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <template>
  2. <view>
  3. <CustomToast ref="customToast" />
  4. <view class="region mar-t-10 pad-24">
  5. <view class="font36 font-bold mar-b-20">
  6. 原地址
  7. </view>
  8. <view>
  9. <view class="font-bold">
  10. {{order.province}}{{order.city}}{{order.area}}{{order.address}}
  11. </view>
  12. <view class="mar-t-10 ">
  13. {{order.name}} {{order.mobile}}
  14. </view>
  15. </view>
  16. </view>
  17. <view class="region mar-t-10 pad-24 height-vh">
  18. <view class="font36 font-bold mar-b-20">
  19. 选择新的收货地址
  20. </view>
  21. <view>
  22. <view class="mar-t-30">
  23. <view v-if="list.length>0">
  24. <view v-for="(item,index) in list" :key="index" class=" mar-b-50 ">
  25. <view class="flex-items flex-sp-between" @tap="customRadioChange(item)">
  26. <view class="width90 flex-items flex-sp-between">
  27. <view>
  28. <view>
  29. <text class="font28">
  30. {{item.province}}{{item.city}}{{item.area}}{{item.address}}</text>
  31. </view>
  32. <view>
  33. <text class="font28">{{item.name}} {{item.mobile}}</text>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="width10">
  38. <radio-group>
  39. <radio :value="item.id" :checked="templateSelect === item.id" />
  40. </radio-group>
  41. </view>
  42. </view>
  43. <view class="line"></view>
  44. </view>
  45. </view>
  46. <view v-else>
  47. <view class="flex-items-plus">
  48. <image src="../../static/images/empty.png" class="empty "></image>
  49. </view>
  50. <view class="font28 font-gray flex-items-plus">
  51. 暂无数据
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 提交按钮 -->
  58. <button class="submit-button" @click="submit()">确认修改</button>
  59. </view>
  60. </template>
  61. <script>
  62. import {
  63. addressList,
  64. orderDetail,
  65. updateAddress
  66. } from '../../config/api.js';
  67. import CustomToast from '../../components/CustomToast.vue';
  68. export default {
  69. components: {
  70. CustomToast,
  71. },
  72. data() {
  73. return {
  74. templateSelect: "",
  75. orderId: "",
  76. order: {},
  77. list: []
  78. }
  79. },
  80. methods: {
  81. submit() {
  82. updateAddress(this.order).then((res) => {
  83. if (res.code == 200) {
  84. this.$refs.customToast.showToast('操作成功');
  85. setTimeout(() => {
  86. uni.navigateBack({
  87. delta: 1
  88. })
  89. }, 1000)
  90. }
  91. })
  92. },
  93. getOrderDetail() {
  94. orderDetail({
  95. id: this.orderId
  96. }).then((res) => {
  97. this.order = res.data;
  98. });
  99. },
  100. getAddressList() {
  101. addressList().then((res) => {
  102. this.list = res.data
  103. })
  104. },
  105. customRadioChange(item) {
  106. this.templateSelect = item.id;
  107. this.order.province = item.province
  108. this.order.city = item.city
  109. this.order.area = item.area
  110. this.order.address = item.address
  111. this.order.name = item.name
  112. this.order.mobile = item.mobile
  113. },
  114. },
  115. onLoad(op) {
  116. this.orderId = op.orderId;
  117. this.getOrderDetail();
  118. this.getAddressList()
  119. },
  120. }
  121. </script>
  122. <style>
  123. .navigation {
  124. border: solid 2rpx #f2f2f2;
  125. background-color: #ffffff;
  126. padding: 16rpx 0;
  127. }
  128. .submit-button {
  129. position: fixed;
  130. bottom: 0;
  131. width: 100%;
  132. background-color: #F95B5B;
  133. color: #fff;
  134. font-size: 32rpx;
  135. padding: 5rpx;
  136. border-radius: 10rpx;
  137. margin-right: 30rpx;
  138. text-align: center;
  139. margin-top: 30rpx;
  140. }
  141. </style>