SelAddress.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <template>
  2. <view :class="['qn-page-' + theme]">
  3. <view class="now-address">
  4. <view class="a-title">当前配送至</view>
  5. <view class="a-sel">
  6. <text class="ibonfont ibondizhi2"></text>
  7. <text>{{ now_address.provinceName || '' }}-{{ now_address.cityName || '' }}-{{ now_address.districtName || '' }}</text>
  8. </view>
  9. </view>
  10. <view class="address-view">
  11. <view class="a-title">从我的收货地址选择</view>
  12. <ul class="address-ul">
  13. <li class="address-li" v-for="(item, index) in addressList" :key="index" @click="selAddress(item)">
  14. <view class="user-info clearfix">
  15. <text class="float_left">{{ item.name }}</text>
  16. <text class="float_right">{{ item.mobile }}</text>
  17. </view>
  18. <view class="address-de">
  19. <text v-if="item.defaultStatus === 5" class="default-tag">[默认地址]</text>
  20. {{ item.area.provinceName }} {{ item.area.cityName }} {{ item.area.districtName }} {{ item.address }}
  21. </view>
  22. </li>
  23. </ul>
  24. </view>
  25. <view class="fixed-bottom">
  26. <RegionSel @pickerRegionChange="pickerRegionChange">
  27. <view class="bottom-btn">选择其他地区</view>
  28. </RegionSel>
  29. </view>
  30. </view>
  31. </template>
  32. <script>
  33. import RegionSel from '../components/region/RegionSel.vue';
  34. export default {
  35. components: {
  36. RegionSel
  37. },
  38. data() {
  39. return {
  40. now_address: {},
  41. addressList: [],
  42. pageTotal: 0,
  43. page: 1,
  44. pageSize: 10,
  45. loading_status: 'loadmore'
  46. };
  47. },
  48. onLoad(options) {
  49. this.now_address = JSON.parse(options.address_data);
  50. this.getAllShippingAddress();
  51. },
  52. onPullDownRefresh() {
  53. if (this.pageTotal / this.pageSize > this.page) {
  54. this.page += 1;
  55. this.getAllShippingAddress();
  56. }
  57. },
  58. methods: {
  59. pickerRegionChange(row) {
  60. this.now_address = {
  61. provinceCode: row[0].value,
  62. cityCode: row[1].value || '',
  63. districtCode: row[2].value || '',
  64. provinceName: row[0].label || '',
  65. cityName: row[1].label || '',
  66. districtName: row[2].label || ''
  67. };
  68. this.$api.prePage().now_sel_address = this.now_address;
  69. uni.navigateBack();
  70. },
  71. selAddress(row) {
  72. this.now_address = {
  73. provinceCode: row.provinceCode,
  74. cityCode: row.cityCode,
  75. districtCode: row.districtCode,
  76. provinceName: row.area.provinceName,
  77. cityName: row.area.cityName,
  78. districtName: row.area.districtName
  79. };
  80. this.$api.prePage().now_sel_address = this.now_address;
  81. uni.navigateBack();
  82. },
  83. // 获取客户地址列表 getAllShippingAddress
  84. getAllShippingAddress() {
  85. this.loading_status = 'more';
  86. this.$u.api.getAllShippingAddress({
  87. page: this.page,
  88. pageSize: this.pageSize
  89. }).then(data=>{
  90. this.loading_status = 'noMore';
  91. uni.stopPullDownRefresh();
  92. if (this.page === 1) {
  93. this.addressList = data.data;
  94. } else {
  95. this.addressList = this.addressList.concat(data.data);
  96. }
  97. if (this.addressList.length) {
  98. if(!this.now_address.provinceCode){
  99. const address = this.addressList.find(item => item.defaultStatus === 5) || this.addressList[0];
  100. this.now_address = {
  101. provinceCode: address.provinceCode,
  102. cityCode: address.cityCode,
  103. districtCode: address.districtCode,
  104. provinceName: address.area.provinceName,
  105. cityName: address.area.cityName,
  106. districtName: address.area.districtName
  107. };
  108. }
  109. }
  110. this.pageTotal = data.pageTotal;
  111. });
  112. }
  113. }
  114. };
  115. </script>
  116. <style lang="scss">
  117. body,
  118. pages {
  119. background-color: #f7f7f7;
  120. }
  121. .a-title {
  122. font-size: 24upx;
  123. color: #999999;
  124. line-height: 66upx;
  125. padding: 0 24upx;
  126. }
  127. .now-address {
  128. .a-sel {
  129. background-color: #ffffff;
  130. line-height: 80upx;
  131. padding: 0 24upx;
  132. .ibonfont {
  133. font-size: 28upx;
  134. color: #666666;
  135. margin-right: 20upx;
  136. }
  137. }
  138. }
  139. .address-view {
  140. .address-ul {
  141. .address-li {
  142. background-color: #ffffff;
  143. padding: 20upx 24upx;
  144. border-bottom: 1px solid #f7f7f7;
  145. .user-info {
  146. font-size: 28upx;
  147. padding-bottom: 10upx;
  148. }
  149. .address-de {
  150. font-size: 24upx;
  151. .default-tag {
  152. margin-right: 10upx;
  153. }
  154. }
  155. }
  156. }
  157. }
  158. .fixed-bottom {
  159. position: fixed;
  160. bottom: 30upx;
  161. left: 0;
  162. width: 100%;
  163. }
  164. .bottom-btn {
  165. width: 680upx;
  166. line-height: 78upx;
  167. font-size: 28upx;
  168. border-radius: 8upx;
  169. text-align: center;
  170. color: #ffffff;
  171. margin: 0 auto;
  172. }
  173. </style>