address-list.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view>
  3. <view class="address-action" :class="{'address-show': value==true}" style="background-color: #f8f8f8">
  4. <view class="address-title">请选择地址</view>
  5. <view class="address-body" :style="{'max-height':maxHeight+'px'}">
  6. <view v-if="array.length <= 0" class="address-empty">
  7. {{tips}}
  8. </view>
  9. <view class="address-list" v-if="array.length">
  10. <view class="address-box"
  11. v-for="(item,index) in array" :key="index"
  12. @click="onSelect(item)"
  13. >
  14. <view class="address-r-box">
  15. <view class="address-name">{{ item.name }} {{ item.tel }}</view>
  16. <view class="address-valid">{{ item.address }}</view>
  17. </view>
  18. <view class="address-corner-checkbox">
  19. <text class="iconfont" :class="{ active: active == item.id }">&#xe641;</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view style="width: 100%;height: 60px; float: left"></view>
  24. </view>
  25. <text class="iconfont close" @click.stop="onClose">&#xe600;</text>
  26. <view v-if="add" class="address-button" @click="onAddAddress"><text>新增地址</text></view>
  27. </view>
  28. <popup v-model="value"></popup>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. props: {
  34. value: {
  35. type: Boolean,
  36. default: false
  37. },
  38. add: {
  39. type: Boolean,
  40. default: true
  41. },
  42. tips: {
  43. type: String,
  44. default: "您还没有添加地址哦"
  45. },
  46. array: {
  47. type: Array,
  48. default: function() {
  49. return []
  50. }
  51. }
  52. },
  53. data(){
  54. return {
  55. maxHeight:0,
  56. active: 0
  57. };
  58. },
  59. mounted() {
  60. let info = this.$utils.getSystemInfo();
  61. this.maxHeight = info.h - this.$utils.px2rpx(200);
  62. },
  63. methods: {
  64. onClose(){
  65. this.$emit("input",!this.value)
  66. },
  67. onSelect(value){
  68. this.active = value.id;
  69. this.$emit("address-event",value);
  70. },
  71. onAddAddress(){
  72. this.$emit("onAdd",{});
  73. }
  74. }
  75. }
  76. </script>
  77. <style lang="scss">
  78. .address-action{
  79. position: fixed;
  80. left: 0;
  81. bottom: 0;
  82. background-color: #fff;
  83. width: 100%;
  84. border-radius: 20rpx 20rpx 0 0;
  85. display: flex;
  86. flex-direction: column;
  87. align-items: stretch;
  88. min-height: 50%;
  89. max-height: 80%;
  90. font-size: 28rpx;
  91. z-index: 19999;
  92. overflow: hidden;
  93. transition:all .3s cubic-bezier(.65,.7,.7,.9);
  94. transform:translate3d(0,100%,0);
  95. .address-title { font-size: 32rpx; text-align: center; width: 100%; height: 100rpx; background-color: #fff; line-height: 100rpx; }
  96. .address-button {
  97. width: 100%; height: 90rpx; line-height: 90rpx; position: absolute; left: 0; bottom: 0; background-color: #fff;
  98. text {
  99. text-align: center; background-color: #1b43c4;
  100. width: 90%; height: 70rpx; line-height: 70rpx;
  101. margin: 10rpx auto; display: block;
  102. font-size: 30rpx; color: #fff; border-radius: 40rpx;
  103. }
  104. }
  105. .address-body {
  106. flex: 1 1 auto;
  107. min-height: 88rpx;
  108. overflow-y: scroll;
  109. -webkit-overflow-scrolling: touch;
  110. .address-empty { width: 100%; text-align: center; font-size: 36rpx; height: 100rpx; line-height: 100rpx; position: absolute; top: 50%; transform: translateY(-50%) }
  111. .address-list {
  112. width: 95%;
  113. margin-left: 2.5%;
  114. float: left;
  115. margin-top: 20rpx;
  116. .address-box {
  117. float: left;
  118. margin-bottom: 20rpx;
  119. width: 100%;
  120. height: 170rpx;
  121. background-color: #fff;
  122. border-radius: 20rpx;
  123. position: relative;
  124. .address-r-box {
  125. float: left;
  126. margin-left: 60rpx;
  127. height: 170rpx;
  128. position: relative;
  129. .address-name {
  130. font-size: 30rpx;
  131. padding-top: 36rpx;
  132. }
  133. .address-valid{
  134. padding-top: 24rpx;
  135. font-size: 28rpx;
  136. }
  137. }
  138. .address-corner-checkbox{
  139. position: absolute;
  140. color: #999;
  141. right: 30rpx;
  142. height: 40rpx;
  143. top: 50%;
  144. transform: translateY(-50%);
  145. text { font-size: 40rpx; }
  146. .active { color: #c21313; }
  147. }
  148. }
  149. }
  150. }
  151. .close { position: absolute; top: 30rpx; right: 30rpx; z-index: 1; color: #c8c9cc; font-size: 44rpx; cursor: pointer; }
  152. }
  153. .address-show{
  154. transform:translate3d(0,0,0);
  155. }
  156. </style>