index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view>
  3. <view class="address-window" :class="address.address==true?'on':''">
  4. <view class='title'>选择地址<text class='iconfont icon-guanbi' @tap='close'></text></view>
  5. <view class='list'>
  6. <view class='item acea-row row-between-wrapper' :class='active==index?"font-color":""' v-for="(item,index) in addressList"
  7. @tap='tapAddress(index,item.address_id)' :key='index'>
  8. <text class='iconfont icon-ditu' :class='active==index?"font-color":""'></text>
  9. <view class='address'>
  10. <view class='name' :class='active==index?"font-color":""'>{{item.real_name}}<text class='phone'>{{item.phone}}</text></view>
  11. <view class='line1'>{{item.province}}{{item.city}}{{item.district}}{{item.detail}}</view>
  12. </view>
  13. <text class='iconfont icon-complete' :class='active==index?"font-color":""'></text>
  14. </view>
  15. </view>
  16. <!-- 无地址 -->
  17. <view class='pictrue' v-if="!is_loading && !addressList.length">
  18. <image src='../../static/images/noAddress.png'></image>
  19. </view>
  20. <view class='addressBnt bg-color' @tap='goAddressPages'>选择其它地址</view>
  21. </view>
  22. <view class='mask' catchtouchmove="true" :hidden='address.address==false' @tap='close'></view>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. getAddressList
  28. } from '@/api/user.js';
  29. export default {
  30. props: {
  31. pagesUrl: {
  32. type: String,
  33. default: '',
  34. },
  35. address: {
  36. type: Object,
  37. default: function() {
  38. return {
  39. address: true,
  40. addressId: 0,
  41. };
  42. }
  43. },
  44. isLog: {
  45. type: Boolean,
  46. default: false,
  47. },
  48. },
  49. data() {
  50. return {
  51. active: 0,
  52. //地址列表
  53. addressList: [],
  54. is_loading: true
  55. };
  56. },
  57. mounted(){
  58. console.log('dd')
  59. this.getAddressList()
  60. },
  61. methods: {
  62. tapAddress: function(e, addressid) {
  63. this.active = e;
  64. this.$emit('OnChangeAddress', addressid);
  65. },
  66. close: function() {
  67. this.$emit('changeClose');
  68. this.$emit('changeTextareaStatus');
  69. },
  70. goAddressPages: function() {
  71. this.$emit('changeClose');
  72. this.$emit('changeTextareaStatus');
  73. uni.navigateTo({
  74. url: this.pagesUrl
  75. });
  76. },
  77. getAddressList: function() {
  78. let that = this;
  79. getAddressList({
  80. page: 1,
  81. limit: 5
  82. }).then(res => {
  83. let addressList = res.data.list;
  84. //处理默认选中项
  85. for (let i = 0; i < res.data.list.length; i++) {
  86. if (addressList[i].address_id == that.address.addressId) {
  87. that.active = i;
  88. }
  89. }
  90. that.$set(that, 'addressList', addressList);
  91. that.is_loading = false;
  92. })
  93. }
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. .address-window {
  99. background-color: #fff;
  100. position: fixed;
  101. bottom: 0;
  102. left: 0;
  103. width: 100%;
  104. z-index: 101;
  105. transform: translate3d(0, 100%, 0);
  106. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  107. }
  108. .address-window.on {
  109. transform: translate3d(0, 0, 0);
  110. }
  111. .address-window .title {
  112. font-size: 32rpx;
  113. font-weight: bold;
  114. text-align: center;
  115. height: 123rpx;
  116. line-height: 123rpx;
  117. position: relative;
  118. }
  119. .address-window .title .iconfont {
  120. position: absolute;
  121. right: 30rpx;
  122. color: #8a8a8a;
  123. font-size: 35rpx;
  124. }
  125. .address-window .list .item {
  126. margin-left: 30rpx;
  127. padding-right: 30rpx;
  128. border-bottom: 1px solid #eee;
  129. height: 129rpx;
  130. font-size: 25rpx;
  131. color: #333;
  132. }
  133. .address-window .list .item .iconfont {
  134. font-size: 37rpx;
  135. color: #2c2c2c;
  136. }
  137. .address-window .list .item .iconfont.icon-complete {
  138. font-size: 30rpx;
  139. color: #fff;
  140. }
  141. .address-window .list .item .address {
  142. width: 560rpx;
  143. }
  144. .address-window .list .item .address .name {
  145. font-size: 28rpx;
  146. font-weight: bold;
  147. color: #282828;
  148. margin-bottom: 4rpx;
  149. }
  150. .address-window .list .item .address .name .phone {
  151. margin-left: 18rpx;
  152. }
  153. .address-window .addressBnt {
  154. font-size: 30rpx;
  155. font-weight: bold;
  156. color: #fff;
  157. width: 690rpx;
  158. height: 86rpx;
  159. border-radius: 43rpx;
  160. text-align: center;
  161. line-height: 86rpx;
  162. margin: 85rpx auto;
  163. }
  164. .address-window .pictrue {
  165. width: 414rpx;
  166. height: 336rpx;
  167. margin: 0 auto;
  168. }
  169. .address-window .pictrue image {
  170. width: 100%;
  171. height: 100%;
  172. }
  173. </style>