index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view>
  3. <!-- 下拉选择地址 -->
  4. <view class="address-window" :class="{ on: address.address, ons: !isFooter }">
  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. isFooter: {
  61. type: Boolean,
  62. default: false
  63. }
  64. },
  65. data() {
  66. return {
  67. active: 0,
  68. //地址列表
  69. addressList: [],
  70. is_loading: true,
  71. imgHost:HTTP_REQUEST_URL
  72. };
  73. },
  74. methods: {
  75. tapAddress: function(e, addressid,row) {
  76. this.active = e;
  77. this.$emit('OnChangeAddress', addressid,row);
  78. },
  79. close: function() {
  80. this.$emit('changeClose');
  81. this.$emit('changeTextareaStatus');
  82. },
  83. goAddressPages: function() {
  84. this.$emit('changeClose');
  85. this.$emit('changeTextareaStatus');
  86. if (!this.addressList.length && this.pagesUrl.indexOf('isCollage') != -1) {
  87. let index = this.pagesUrl.indexOf('?')
  88. return uni.navigateTo({
  89. url: '/pages/users/user_address/index'+this.pagesUrl.slice(index)
  90. });
  91. }
  92. uni.navigateTo({
  93. url: this.pagesUrl
  94. });
  95. },
  96. getAddressList: function() {
  97. let that = this;
  98. getAddressList({
  99. page: 1,
  100. limit: 5
  101. }).then(res => {
  102. let addressList = res.data;
  103. //处理默认选中项
  104. for (let i = 0, leng = addressList.length; i < leng; i++) {
  105. if (addressList[i].id == that.address.addressId) {
  106. that.active = i;
  107. }
  108. }
  109. that.$set(that, 'addressList', addressList);
  110. that.is_loading = false;
  111. })
  112. }
  113. }
  114. }
  115. </script>
  116. <style scoped lang="scss">
  117. .mask{
  118. z-index: 100 !important;
  119. }
  120. .address-window {
  121. background-color: #fff;
  122. position: fixed;
  123. bottom: 0;
  124. left: 0;
  125. width: 100%;
  126. z-index: 101;
  127. transform: translate3d(0, 100%, 0);
  128. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  129. }
  130. .address-window.on {
  131. transform: translate3d(0, 0, 0);
  132. }
  133. .address-window .title {
  134. font-size: 32rpx;
  135. font-weight: bold;
  136. text-align: center;
  137. height: 123rpx;
  138. line-height: 123rpx;
  139. position: relative;
  140. }
  141. .address-window .title .iconfont {
  142. position: absolute;
  143. right: 30rpx;
  144. color: #8a8a8a;
  145. font-size: 35rpx;
  146. }
  147. .address-window .list .item {
  148. margin-left: 30rpx;
  149. padding-right: 30rpx;
  150. border-bottom: 1px solid #eee;
  151. height: 129rpx;
  152. font-size: 25rpx;
  153. color: #333;
  154. }
  155. .address-window .list .item .iconfont {
  156. font-size: 37rpx;
  157. color: #2c2c2c;
  158. }
  159. .address-window .list .item .iconfont.icon-complete {
  160. font-size: 30rpx;
  161. color: #fff;
  162. }
  163. .address-window .list .item .address {
  164. width: 560rpx;
  165. }
  166. .address-window .list .item .address .name {
  167. font-size: 28rpx;
  168. font-weight: bold;
  169. color: #282828;
  170. margin-bottom: 4rpx;
  171. }
  172. .address-window .list .item .address .name .phone {
  173. margin-left: 18rpx;
  174. }
  175. .address-window .addressBnt {
  176. font-size: 30rpx;
  177. font-weight: bold;
  178. color: #fff;
  179. width: 690rpx;
  180. height: 86rpx;
  181. border-radius: 43rpx;
  182. text-align: center;
  183. line-height: 86rpx;
  184. margin: 85rpx auto;
  185. &.on{
  186. margin-bottom: 150rpx;
  187. margin-bottom: calc(150rpx + constant(safe-area-inset-bottom)); ///兼容 IOS<11.2/
  188. margin-bottom: calc(150rpx + env(safe-area-inset-bottom)); ///兼容 IOS>11.2/
  189. }
  190. }
  191. .address-window .pictrue {
  192. width: 414rpx;
  193. height: 336rpx;
  194. margin: 0 auto;
  195. }
  196. .address-window .pictrue image {
  197. width: 100%;
  198. height: 100%;
  199. }
  200. </style>