index.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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="`${domain}/static/images/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~2024 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. import { HTTP_REQUEST_URL } from '@/config/app';
  39. export default {
  40. props: {
  41. pagesUrl: {
  42. type: String,
  43. default: '',
  44. },
  45. address: {
  46. type: Object,
  47. default: function() {
  48. return {
  49. address: true,
  50. addressId: 0,
  51. };
  52. }
  53. },
  54. isLog: {
  55. type: Boolean,
  56. default: false,
  57. },
  58. },
  59. computed: mapGetters(['viewColor']),
  60. data() {
  61. return {
  62. domain: HTTP_REQUEST_URL,
  63. active: 0,
  64. //地址列表
  65. addressList: [],
  66. is_loading: true
  67. };
  68. },
  69. methods: {
  70. tapAddress: function(e, addressid) {
  71. this.active = e;
  72. this.$emit('OnChangeAddress', addressid);
  73. },
  74. close: function() {
  75. this.$emit('changeClose');
  76. this.$emit('changeTextareaStatus');
  77. },
  78. goAddressPages: function() {
  79. this.$emit('changeClose');
  80. this.$emit('changeTextareaStatus');
  81. uni.navigateTo({
  82. url: this.pagesUrl
  83. });
  84. },
  85. getAddressList: function() {
  86. let that = this;
  87. getAddressList({
  88. page: 1,
  89. limit: 5
  90. }).then(res => {
  91. let addressList = res.data.list;
  92. //处理默认选中项
  93. for (let i = 0; i < res.data.list.length; i++) {
  94. if (addressList[i].address_id == that.address.addressId) {
  95. that.active = i;
  96. }
  97. }
  98. that.$set(that, 'addressList', addressList);
  99. that.is_loading = false;
  100. })
  101. }
  102. }
  103. }
  104. </script>
  105. <style scoped lang="scss">
  106. .address-window {
  107. background-color: #fff;
  108. position: fixed;
  109. bottom: 0;
  110. left: 0;
  111. width: 100%;
  112. z-index: 101;
  113. transform: translate3d(0, 100%, 0);
  114. transition: all .3s cubic-bezier(.25, .5, .5, .9);
  115. }
  116. .address-window.on {
  117. transform: translate3d(0, 0, 0);
  118. }
  119. .address-window .title {
  120. font-size: 32rpx;
  121. font-weight: bold;
  122. text-align: center;
  123. height: 123rpx;
  124. line-height: 123rpx;
  125. position: relative;
  126. }
  127. .address-window .title .iconfont {
  128. position: absolute;
  129. right: 30rpx;
  130. color: #8a8a8a;
  131. font-size: 35rpx;
  132. }
  133. .address-window .list{
  134. max-height: 650rpx;
  135. }
  136. .address-window .list .item {
  137. margin-left: 30rpx;
  138. padding-right: 30rpx;
  139. border-bottom: 1px solid #eee;
  140. height: 129rpx;
  141. font-size: 25rpx;
  142. color: #333;
  143. }
  144. .address-window .list .item .iconfont {
  145. font-size: 37rpx;
  146. color: #2c2c2c;
  147. }
  148. .address-window .list .item .iconfont.icon-complete {
  149. font-size: 30rpx;
  150. color: #fff;
  151. }
  152. .address-window .list .item .address {
  153. width: 560rpx;
  154. }
  155. .address-window .list .item .address .name {
  156. font-size: 28rpx;
  157. font-weight: bold;
  158. color: #282828;
  159. margin-bottom: 4rpx;
  160. }
  161. .address-window .list .item .address .name .phone {
  162. margin-left: 18rpx;
  163. }
  164. .address-window .addressBnt {
  165. font-size: 30rpx;
  166. font-weight: bold;
  167. color: #fff;
  168. width: 690rpx;
  169. height: 86rpx;
  170. border-radius: 43rpx;
  171. text-align: center;
  172. line-height: 86rpx;
  173. margin: 85rpx auto;
  174. background-color: var(--view-theme);
  175. }
  176. .address-window .pictrue {
  177. text-align: center;
  178. }
  179. .address-window .pictrue image,.address-window .pictrue uni-image {
  180. width: 414rpx;
  181. height: 305rpx;
  182. }
  183. .address-window .pictrue view{
  184. color: #999;
  185. }
  186. .t-color {
  187. color: var(--view-theme)!important;
  188. }
  189. </style>