index.vue 4.6 KB

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