index.vue 4.2 KB

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