index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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="`${domain}/static/images/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~2024 https://www.crmeb.com All rights reserved.
  30. // +----------------------------------------------------------------------
  31. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  32. // +----------------------------------------------------------------------
  33. // | Author: CRMEB Team <admin@crmeb.com>
  34. // +----------------------------------------------------------------------
  35. import { getAddressList } from '@/api/user.js';
  36. import { HTTP_REQUEST_URL } from '@/config/app';
  37. import { toLogin } from '@/libs/login.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. domain: HTTP_REQUEST_URL,
  61. active: 0,
  62. //地址列表
  63. addressList: [],
  64. is_loading: true
  65. };
  66. },
  67. methods: {
  68. tapAddress: function(e, addressid) {
  69. this.active = e;
  70. this.$emit('OnChangeAddress', addressid);
  71. },
  72. close: function() {
  73. this.$emit('changeClose');
  74. this.$emit('changeTextareaStatus');
  75. },
  76. goAddressPages: function() {
  77. this.$emit('changeClose');
  78. this.$emit('changeTextareaStatus');
  79. uni.navigateTo({
  80. url: this.pagesUrl
  81. });
  82. },
  83. getAddressList: function() {
  84. let that = this;
  85. getAddressList({
  86. page: 1,
  87. limit: 5
  88. }).then(res => {
  89. let addressList = res.data;
  90. //处理默认选中项
  91. for (let i = 0, leng = addressList.length; i < leng; i++) {
  92. if (addressList[i].id == that.address.addressId) {
  93. that.active = i;
  94. }
  95. }
  96. that.$set(that, 'addressList', addressList);
  97. that.is_loading = false;
  98. })
  99. }
  100. }
  101. }
  102. </script>
  103. <style scoped lang="scss">
  104. .address-window {
  105. background-color: #fff;
  106. position: fixed;
  107. bottom: 0;
  108. left: 0;
  109. width: 100%;
  110. z-index: 101;
  111. transform: translate3d(0, 100%, 0);
  112. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  113. }
  114. .address-window.on {
  115. transform: translate3d(0, 0, 0);
  116. }
  117. .address-window .title {
  118. font-size: 32rpx;
  119. font-weight: bold;
  120. text-align: center;
  121. height: 123rpx;
  122. line-height: 123rpx;
  123. position: relative;
  124. }
  125. .address-window .title .iconfont {
  126. position: absolute;
  127. right: 30rpx;
  128. color: #8a8a8a;
  129. font-size: 35rpx;
  130. }
  131. .address-window .list .item {
  132. margin-left: 30rpx;
  133. padding-right: 30rpx;
  134. border-bottom: 1px solid #eee;
  135. height: 129rpx;
  136. font-size: 25rpx;
  137. color: #333;
  138. }
  139. .address-window .list .item .iconfont {
  140. font-size: 37rpx;
  141. color: #2c2c2c;
  142. }
  143. .address-window .list .item .iconfont.icon-complete {
  144. font-size: 30rpx;
  145. color: #fff;
  146. }
  147. .address-window .list .item .address {
  148. width: 560rpx;
  149. }
  150. .address-window .list .item .address .name {
  151. font-size: 28rpx;
  152. font-weight: bold;
  153. color: #282828;
  154. margin-bottom: 4rpx;
  155. }
  156. .address-window .list .item .address .name .phone {
  157. margin-left: 18rpx;
  158. }
  159. .address-window .addressBnt {
  160. font-size: 30rpx;
  161. font-weight: bold;
  162. color: #fff;
  163. width: 690rpx;
  164. height: 86rpx;
  165. border-radius: 43rpx;
  166. text-align: center;
  167. line-height: 86rpx;
  168. margin: 85rpx auto;
  169. }
  170. .address-window .pictrue {
  171. width: 414rpx;
  172. height: 336rpx;
  173. margin: 0 auto;
  174. }
  175. .address-window .pictrue image {
  176. width: 100%;
  177. height: 100%;
  178. }
  179. </style>