index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template>
  2. <view>
  3. <view class="address-window" :class="address.address==true?'on':''">
  4. <view class='title'>选择地址<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-color":""' v-for="(item,index) in addressList"
  7. @tap='tapAddress(index,item.id)' :key='index'>
  8. <text class='iconfont icon-ditu' :class='active==index?"font-color":""'></text>
  9. <view class='address'>
  10. <view class='name' :class='active==index?"font-color":""'>{{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-color":""'></text>
  14. </view>
  15. </view>
  16. <!-- 无地址 -->
  17. <view class='pictrue' v-if="!is_loading && !addressList.length">
  18. <image src='http://ygs.hqgjsmc.com/baseimg/noAddress.png'></image>
  19. </view>
  20. <view class='addressBnt bg-color' @tap='goAddressPages'>选择其地址</view>
  21. </view>
  22. <view class='mask' catchtouchmove="true" :hidden='address.address==false' @tap='close'></view>
  23. </view>
  24. </template>
  25. <script>
  26. // +----------------------------------------------------------------------
  27. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  28. // +----------------------------------------------------------------------
  29. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  30. // +----------------------------------------------------------------------
  31. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  32. // +----------------------------------------------------------------------
  33. // | Author: CRMEB Team <admin@crmeb.com>
  34. // +----------------------------------------------------------------------
  35. import {
  36. getAddressList
  37. } from '@/api/user.js';
  38. export default {
  39. props: {
  40. pagesUrl: {
  41. type: String,
  42. default: '',
  43. },
  44. address: {
  45. type: Object,
  46. default: function() {
  47. return {
  48. address: true,
  49. addressId: 0,
  50. };
  51. }
  52. },
  53. isLog: {
  54. type: Boolean,
  55. default: false,
  56. },
  57. },
  58. data() {
  59. return {
  60. active: 0,
  61. //地址列表
  62. addressList: [],
  63. is_loading: true
  64. };
  65. },
  66. methods: {
  67. tapAddress: function(e, addressid) {
  68. this.active = e;
  69. this.$emit('OnChangeAddress', addressid);
  70. },
  71. close: function() {
  72. this.$emit('changeClose');
  73. this.$emit('changeTextareaStatus');
  74. },
  75. goAddressPages: function() {
  76. this.$emit('changeClose');
  77. this.$emit('changeTextareaStatus');
  78. uni.navigateTo({
  79. url: this.pagesUrl
  80. });
  81. },
  82. getAddressList: function() {
  83. let that = this;
  84. getAddressList({
  85. page: 1,
  86. limit: 5
  87. }).then(res => {
  88. let addressList = res.data;
  89. //处理默认选中项
  90. for (let i = 0, leng = addressList.length; i < leng; i++) {
  91. if (addressList[i].id == that.address.addressId) {
  92. that.active = i;
  93. }
  94. }
  95. that.$set(that, 'addressList', addressList);
  96. that.is_loading = false;
  97. })
  98. }
  99. }
  100. }
  101. </script>
  102. <style scoped lang="scss">
  103. .address-window {
  104. background-color: #fff;
  105. position: fixed;
  106. bottom: 0;
  107. left: 0;
  108. width: 100%;
  109. z-index: 101;
  110. transform: translate3d(0, 100%, 0);
  111. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  112. }
  113. .address-window.on {
  114. transform: translate3d(0, 0, 0);
  115. }
  116. .address-window .title {
  117. font-size: 32rpx;
  118. font-weight: bold;
  119. text-align: center;
  120. height: 123rpx;
  121. line-height: 123rpx;
  122. position: relative;
  123. }
  124. .address-window .title .iconfont {
  125. position: absolute;
  126. right: 30rpx;
  127. color: #8a8a8a;
  128. font-size: 35rpx;
  129. }
  130. .address-window .list .item {
  131. margin-left: 30rpx;
  132. padding-right: 30rpx;
  133. border-bottom: 1px solid #eee;
  134. height: 129rpx;
  135. font-size: 25rpx;
  136. color: #333;
  137. }
  138. .address-window .list .item .iconfont {
  139. font-size: 37rpx;
  140. color: #2c2c2c;
  141. }
  142. .address-window .list .item .iconfont.icon-complete {
  143. font-size: 30rpx;
  144. color: #fff;
  145. }
  146. .address-window .list .item .address {
  147. width: 560rpx;
  148. }
  149. .address-window .list .item .address .name {
  150. font-size: 28rpx;
  151. font-weight: bold;
  152. color: #282828;
  153. margin-bottom: 4rpx;
  154. }
  155. .address-window .list .item .address .name .phone {
  156. margin-left: 18rpx;
  157. }
  158. .address-window .addressBnt {
  159. font-size: 30rpx;
  160. font-weight: bold;
  161. color: #fff;
  162. width: 690rpx;
  163. height: 86rpx;
  164. border-radius: 43rpx;
  165. text-align: center;
  166. line-height: 86rpx;
  167. margin: 85rpx auto;
  168. }
  169. .address-window .pictrue {
  170. width: 414rpx;
  171. height: 336rpx;
  172. margin: 0 auto;
  173. }
  174. .address-window .pictrue image {
  175. width: 100%;
  176. height: 100%;
  177. }
  178. </style>