address.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <view class="address">
  3. <view class="noaddress" v-if="addressList.length == 0">
  4. <view class="noaddress-bg center">
  5. <image src="/static/image/publice/zanwushouhuo@2x.png" mode=""></image>
  6. <text>暂无收货地址</text>
  7. </view>
  8. <button class="btn-no" hover-class="hover-view" @click="navTo(0)">添加收货地址</button>
  9. </view>
  10. <view class="address-list" v-else>
  11. <view class="address-list-main">
  12. <view class="address-list-item flex" v-for="(item, index) in addressList" :key="index" @click="selectAddress(item)">
  13. <view class="address-list-item-info">
  14. <view class="address-list-scq">{{ item.province }} {{ item.city }} {{ item.area }}</view>
  15. <view class="address-list-detail">{{ item.detail }}</view>
  16. <view class="address-list-userInfo flexs">
  17. <text>{{ item.username }}</text>
  18. <text>{{ item.mobile }}</text>
  19. </view>
  20. </view>
  21. <view class="edit" @click.stop="editAddress(item)"><image src="/static/image/me/bianji@2x.png" mode=""></image></view>
  22. </view>
  23. </view>
  24. <button class="btn btn-no" @click="navTo(0)">新增收货地址</button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. export default {
  30. data() {
  31. return {
  32. type: 1, //1回收选择地址
  33. addressList: []
  34. };
  35. },
  36. methods: {
  37. //编辑地址
  38. editAddress(item) {
  39. uni.setStorageSync('editAddress', JSON.stringify(item));
  40. uni.navigateTo({ url: '/pages/me/addSite?type=1' });
  41. },
  42. //选择地址
  43. selectAddress(item) {
  44. if (this.type == 1 || this.type == 2) {
  45. uni.setStorageSync(this.type == 1 ? 'applyAddress' : '', JSON.stringify(item));
  46. uni.navigateBack();
  47. }
  48. },
  49. navTo(type) {
  50. uni.navigateTo({ url: '/pages/me/addSite?type=' + type });
  51. },
  52. //获取收货地址
  53. loadData() {
  54. this.$api.myAddress().then(res => {
  55. if (res.code === 1) {
  56. this.addressList = res.data;
  57. if (res.data.length == 0) {
  58. uni.removeStorageSync('applyAddress');
  59. }
  60. }
  61. });
  62. }
  63. },
  64. loadData({ type }) {
  65. this.type = type;
  66. },
  67. onShow() {
  68. this.loadData();
  69. }
  70. };
  71. </script>
  72. <style lang="scss">
  73. .noaddress {
  74. display: flex;
  75. padding: 165rpx 30rpx 35rpx 30rpx;
  76. flex-direction: column;
  77. justify-content: space-between;
  78. height: calc(100vh - 44px);
  79. .noaddress-bg {
  80. flex-direction: column;
  81. image {
  82. width: 354rpx;
  83. height: 310rpx;
  84. margin-bottom: 50rpx;
  85. }
  86. text {
  87. font-size: 28rpx;
  88. font-weight: bold;
  89. }
  90. }
  91. }
  92. .btn-no {
  93. height: 98rpx;
  94. color: #333333;
  95. font-size: 30rpx;
  96. font-weight: bold;
  97. background: #ffffff;
  98. box-shadow: 0rpx 0rpx 121rpx 0rpx rgba(63, 52, 2, 0.12);
  99. border-radius: 10rpx;
  100. }
  101. .address-list-main {
  102. padding: 30rpx 30rpx 130rpx 30rpx;
  103. .address-list-item {
  104. padding: 30rpx;
  105. margin-bottom: 30rpx;
  106. background: #ffffff;
  107. .address-list-scq {
  108. color: #666666;
  109. font-size: 28rpx;
  110. }
  111. .address-list-detail {
  112. font-size: 26rpx;
  113. margin: 20rpx 0;
  114. }
  115. .address-list-userInfo {
  116. text {
  117. color: #999999;
  118. font-size: 30rpx;
  119. &:last-child {
  120. font-size: 28rpx;
  121. margin-left: 20rpx;
  122. }
  123. }
  124. }
  125. .edit {
  126. width: 44rpx;
  127. height: 44rpx;
  128. }
  129. }
  130. }
  131. .btn {
  132. width: 690rpx;
  133. left: 50%;
  134. bottom: 34rpx;
  135. transform: translateX(-50%);
  136. position: fixed;
  137. }
  138. </style>