index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 {
  30. getUserAddressPage,
  31. } from "@/api/home.js";
  32. import {HTTP_REQUEST_URL} 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. created() {
  63. this.getAddressList()
  64. },
  65. methods: {
  66. tapAddress: function(e, addressid) {
  67. this.active = e;
  68. this.$emit('OnChangeAddress', addressid);
  69. },
  70. close: function() {
  71. this.$emit('changeClose');
  72. this.$emit('changeTextareaStatus');
  73. },
  74. goAddressPages: function() {
  75. this.$emit('changeClose');
  76. this.$emit('changeTextareaStatus');
  77. uni.navigateTo({
  78. url: this.pagesUrl
  79. });
  80. },
  81. getAddressList: function() {
  82. let that = this;
  83. getUserAddressPage({
  84. userId: this.$store.state.app.uid,
  85. type: 1
  86. }).then(res => {
  87. let addressList = res.data;
  88. //处理默认选中项
  89. for (let i = 0, leng = addressList.length; i < leng; i++) {
  90. if (addressList[i].id == that.address.addressId) {
  91. that.active = i;
  92. }
  93. }
  94. that.$set(that, 'addressList', addressList);
  95. that.is_loading = false;
  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>