index.vue 4.5 KB

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