index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <view>
  3. <base-drawer mode="bottom" :visible="address.address" background-color="transparent" mask maskClosable @close="close">
  4. <view class="w-full bg--w111-fff rd-t-40rpx py-32">
  5. <view class="text-center fs-32 text--w111-333 fw-500">选择地址</view>
  6. <view class="mt-64 px-32">
  7. <view class="mb-38 flex-between-center"
  8. v-for="(item,index) in addressList" :key="index"
  9. :class="{'font-num': active==index}"
  10. @tap='tapAddress(index,item.id,item)'>
  11. <text class='iconfont icon-ic_location5 fs-36'></text>
  12. <view class="flex-1 pl-40">
  13. <view class="fs-28 fw-500">{{item.real_name}}<text class='phone'>{{item.phone}}</text></view>
  14. <view class="w-560 line1 mt-4">{{item.province}}{{item.city}}{{item.district}}{{item.street}}{{item.detail}}</view>
  15. </view>
  16. </view>
  17. <view v-if="!is_loading && !addressList.length">
  18. <emptyPage title="暂无地址信息~" src="/statics/images/noAddress.png"></emptyPage>
  19. </view>
  20. </view>
  21. <view class="mx-20 pb-safe">
  22. <view class="mt-52 h-72 flex-center rd-36px bg-color fs-26 text--w111-fff" @tap='goAddressPages'>选择其它地址</view>
  23. </view>
  24. </view>
  25. </base-drawer>
  26. </view>
  27. </template>
  28. <script>
  29. import {getAddressList} from '@/api/user.js';
  30. import {adminUserAddressList} from '@/api/admin.js';
  31. import {HTTP_REQUEST_URL} from '@/config/app';
  32. import baseDrawer from '@/components/tui-drawer/tui-drawer.vue';
  33. import emptyPage from '@/components/emptyPage.vue';
  34. export default {
  35. props: {
  36. fromType: {
  37. type: Number,
  38. default: 0,
  39. },
  40. pagesUrl: {
  41. type: String,
  42. default: '',
  43. },
  44. address: {
  45. type: Object,
  46. default: function() {
  47. return {
  48. address: true,
  49. addressId: 0,
  50. };
  51. }
  52. },
  53. isLog: {
  54. type: Boolean,
  55. default: false,
  56. },
  57. userId: {
  58. type: [String, Number],
  59. default: 0,
  60. },
  61. },
  62. components: {
  63. baseDrawer,
  64. emptyPage
  65. },
  66. data() {
  67. return {
  68. active: 0,
  69. //地址列表
  70. addressList: [],
  71. is_loading: true,
  72. imgHost: HTTP_REQUEST_URL
  73. };
  74. },
  75. methods: {
  76. tapAddress: function(e, addressid, row) {
  77. this.active = e;
  78. this.$emit('OnChangeAddress', addressid, row);
  79. },
  80. close: function() {
  81. this.$emit('changeClose');
  82. this.$emit('changeTextareaStatus');
  83. },
  84. goAddressPages: function() {
  85. this.$emit('changeClose');
  86. this.$emit('changeTextareaStatus');
  87. uni.navigateTo({
  88. url: this.pagesUrl
  89. });
  90. },
  91. getAddressList: function() {
  92. let that = this;
  93. if (that.userId) {
  94. adminUserAddressList(that.userId, {
  95. page: 1,
  96. limit: 5
  97. }).then(res => {
  98. let addressList = res.data;
  99. //处理默认选中项
  100. for (let i = 0, leng = addressList.length; i < leng; i++) {
  101. if (addressList[i].id == that.address.addressId) {
  102. that.active = i;
  103. }
  104. }
  105. that.$set(that, 'addressList', addressList);
  106. this.$emit('addressList', addressList);
  107. that.is_loading = false;
  108. })
  109. return;
  110. }
  111. getAddressList({
  112. page: 1,
  113. limit: 5
  114. }).then(res => {
  115. let addressList = res.data;
  116. //处理默认选中项
  117. for (let i = 0, leng = addressList.length; i < leng; i++) {
  118. if (addressList[i].id == that.address.addressId) {
  119. that.active = i;
  120. }
  121. }
  122. that.$set(that, 'addressList', addressList);
  123. this.$emit('addressList', addressList);
  124. that.is_loading = false;
  125. })
  126. }
  127. }
  128. }
  129. </script>