index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="content b-t">
  3. <view class="list b-b" v-for="(item, index) in addressList" :key="index" @click="checkAddress(item)">
  4. <view class="wrapper">
  5. <view class="address-box">
  6. <text v-if="item.is_default" class="tag">默认</text>
  7. <text class="address">{{item.storeaddress}}</text>
  8. </view>
  9. <view class="u-box">
  10. <text class="name">{{item.storename}}</text>
  11. <text class="mobile">{{item.phone}}</text>
  12. </view>
  13. </view>
  14. </view>
  15. </view>
  16. </template>
  17. <script>
  18. export default {
  19. data() {
  20. return {
  21. source: 0,
  22. addressList: []
  23. }
  24. },
  25. onLoad(option) {
  26. this.source = option.source;
  27. },
  28. onShow() {
  29. this.getList();
  30. },
  31. methods: {
  32. //获取我的收货地址
  33. async getList() {
  34. let data = await this.$api.request('/store/index', 'POST', {
  35. page: 1,
  36. pagesize: 9999,
  37. lng: '114.93609',
  38. lat: '25.82162'
  39. });
  40. if (data && data.list) {
  41. this.addressList = data.list;
  42. }
  43. },
  44. //选择地址
  45. checkAddress(item) {
  46. if (this.source == 1) {
  47. //this.$api.prePage()获取上一页实例,在App.vue定义
  48. this.$api.prePage().storeData = item;
  49. uni.navigateBack()
  50. }
  51. },
  52. //添加或修改成功之后回调
  53. refreshList(data, type) {
  54. //添加或修改后事件,这里直接在最前面添加了一条数据,实际应用中直接刷新地址列表即可
  55. this.addressList.unshift(data);
  56. }
  57. }
  58. }
  59. </script>
  60. <style lang='scss'>
  61. page {
  62. padding-bottom: 120upx;
  63. }
  64. .content {
  65. position: relative;
  66. }
  67. .list {
  68. display: flex;
  69. align-items: center;
  70. padding: 20upx 30upx;
  71. ;
  72. background: #fff;
  73. position: relative;
  74. }
  75. .wrapper {
  76. display: flex;
  77. flex-direction: column;
  78. flex: 1;
  79. }
  80. .address-box {
  81. display: flex;
  82. align-items: center;
  83. .tag {
  84. font-size: 24upx;
  85. color: $base-color;
  86. margin-right: 10upx;
  87. background: #fffafb;
  88. border: 1px solid #ffb4c7;
  89. border-radius: 4upx;
  90. padding: 4upx 10upx;
  91. line-height: 1;
  92. }
  93. .address {
  94. font-size: 30upx;
  95. color: $font-color-dark;
  96. }
  97. }
  98. .u-box {
  99. font-size: 28upx;
  100. color: $font-color-light;
  101. margin-top: 16upx;
  102. .name {
  103. margin-right: 30upx;
  104. }
  105. }
  106. .icon-bianji {
  107. display: flex;
  108. align-items: center;
  109. height: 80upx;
  110. font-size: 40upx;
  111. color: $font-color-light;
  112. padding-left: 30upx;
  113. }
  114. .icon-lajitong {
  115. color: $font-color-light;
  116. padding-left: 25rpx;
  117. }
  118. .add-btn {
  119. position: fixed;
  120. left: 30upx;
  121. right: 30upx;
  122. bottom: 16upx;
  123. z-index: 95;
  124. display: flex;
  125. align-items: center;
  126. justify-content: center;
  127. width: 690upx;
  128. height: 80upx;
  129. font-size: 32upx;
  130. color: #fff;
  131. background-color: $base-color;
  132. border-radius: 10upx;
  133. box-shadow: 1px 2px 5px rgba(219, 63, 96, 0.4);
  134. }
  135. </style>