index.vue 4.1 KB

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