index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view :style="viewColor">
  3. <view class="address-window" :class="address.address==true?'on':''">
  4. <view class='title'>选择地址<text class='iconfont icon-guanbi' @tap='close'></text></view>
  5. <scroll-view scroll-y="true" class='list'>
  6. <view class='item acea-row row-between-wrapper' :class='active==index?"t-color":""' v-for="(item,index) in addressList"
  7. @tap='tapAddress(index,item.address_id)' :key='index'>
  8. <text class='iconfont icon-ditu' :class='active==index?"t-color":""'></text>
  9. <view class='address'>
  10. <view class='name' :class='active==index?"t-color":""'>{{item.real_name}}<text class='phone'>{{item.phone}}</text></view>
  11. <view class='line1'>{{item.province}}{{item.city}}{{item.district}}{{item.street || ''}}{{item.detail}}</view>
  12. </view>
  13. <text class='iconfont icon-complete' :class='active==index?"t-color":""'></text>
  14. </view>
  15. </scroll-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>暂无地址</view>
  20. </view>
  21. <view class='addressBnt' @tap='goAddressPages'>添加新地址</view>
  22. </view>
  23. <view class='mask' catchtouchmove="true" :hidden='address.address==false' @tap='close'></view>
  24. </view>
  25. </template>
  26. <script>
  27. // +----------------------------------------------------------------------
  28. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  29. // +----------------------------------------------------------------------
  30. // | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
  31. // +----------------------------------------------------------------------
  32. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  33. // +----------------------------------------------------------------------
  34. // | Author: CRMEB Team <admin@crmeb.com>
  35. // +----------------------------------------------------------------------
  36. import { getAddressList } from '@/api/user.js';
  37. import { mapGetters } from "vuex";
  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. computed: mapGetters(['viewColor']),
  59. data() {
  60. return {
  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.list;
  90. //处理默认选中项
  91. for (let i = 0; i < res.data.list.length; i++) {
  92. if (addressList[i].address_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{
  132. height: 150rpx;
  133. }
  134. .address-window .list .item {
  135. margin-left: 30rpx;
  136. padding-right: 30rpx;
  137. border-bottom: 1px solid #eee;
  138. height: 129rpx;
  139. font-size: 25rpx;
  140. color: #333;
  141. }
  142. .address-window .list .item .iconfont {
  143. font-size: 37rpx;
  144. color: #2c2c2c;
  145. }
  146. .address-window .list .item .iconfont.icon-complete {
  147. font-size: 30rpx;
  148. color: #fff;
  149. }
  150. .address-window .list .item .address {
  151. width: 560rpx;
  152. }
  153. .address-window .list .item .address .name {
  154. font-size: 28rpx;
  155. font-weight: bold;
  156. color: #282828;
  157. margin-bottom: 4rpx;
  158. }
  159. .address-window .list .item .address .name .phone {
  160. margin-left: 18rpx;
  161. }
  162. .address-window .addressBnt {
  163. font-size: 30rpx;
  164. font-weight: bold;
  165. color: #fff;
  166. width: 690rpx;
  167. height: 86rpx;
  168. border-radius: 43rpx;
  169. text-align: center;
  170. line-height: 86rpx;
  171. margin: 85rpx auto;
  172. background-color: var(--view-theme);
  173. }
  174. .address-window .pictrue {
  175. text-align: center;
  176. }
  177. .address-window .pictrue image,.address-window .pictrue uni-image {
  178. width: 414rpx;
  179. height: 305rpx;
  180. }
  181. .address-window .pictrue view{
  182. color: #999;
  183. }
  184. .t-color {
  185. color: var(--view-theme)!important;
  186. }
  187. </style>