address.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <!-- 地址列表 -->
  2. <template>
  3. <view class="address-wrap" :style="vuex_skin">
  4. <!-- #ifdef MP-WEIXIN -->
  5. <u-navbar title-color="#000000" :is-back="true" title="用户地址"></u-navbar>
  6. <!-- #endif -->
  7. <view v-if="addressList" class="address-list" v-for="address in addressList" :key="address.id"
  8. @tap="useAddress(address)">
  9. <view class="top u-flex">
  10. <text class="name">{{ address.consignee }}</text>
  11. <text class="phone ">{{ address.phone }}</text>
  12. <text class="tag" v-if="address.isDefault">默认</text>
  13. </view>
  14. <view class="detail">
  15. {{ address.provinceName }}{{ address.cityName }}{{ address.areaName }}{{ address.address }}
  16. </view>
  17. <button class="u-reset-button set-btn" @tap.stop="edit(address.id)">编辑</button>
  18. </view>
  19. <view class="empty" v-else>
  20. <image src="@/static/icon/empty.png" mode="widthFix"></image>
  21. <text>暂无地址</text>
  22. </view>
  23. <view class="foot_box-wrap safe-area-inset-bottom">
  24. <view class="foot_box u-flex u-row-between safe-area-inset-bottom">
  25. <!-- #ifdef MP-WEIXIN -->
  26. <!-- 微信小程序 -->
  27. <button class="u-reset-button sync-wxaddress u-m-20 u-flex u-row-center u-col-center"
  28. @tap="getWXaddress">
  29. <text class="u-iconfont uicon-weixin-fill u-p-r-10" style="color:#09bb07;font-size: 40rpx;"></text>
  30. 导入微信地址
  31. </button>
  32. <!-- #endif -->
  33. <button class="u-reset-button add-btn u-m-20" @tap="$jump('/pages/address/add')">添加新的收货地址</button>
  34. </view>
  35. </view>
  36. </view>
  37. </template>
  38. <script>
  39. let _this;
  40. export default {
  41. components: {},
  42. data() {
  43. return {
  44. addressList: [],
  45. };
  46. },
  47. computed: {},
  48. onLoad() {
  49. _this = this
  50. },
  51. onShow() {
  52. this.getAddressList();
  53. },
  54. methods: {
  55. // 选中
  56. useAddress(addressData) {
  57. let params = {
  58. addressData
  59. }
  60. uni.$emit('ADDRESS', addressData)
  61. this.$back()
  62. },
  63. //编辑
  64. edit(id) {
  65. uni.navigateTo({
  66. url: "./add?addressId=" + id
  67. })
  68. },
  69. // 微信导入
  70. getWXaddress() {
  71. uni.chooseAddress({
  72. success: res => {
  73. _this.$jump('/pages/address/add?wxAddress=' + JSON.stringify(res))
  74. },
  75. fail: err => {
  76. console.log('%cuni.chooseAddress,调用失败', 'color:green;background:yellow');
  77. }
  78. });
  79. },
  80. getAddressList() {
  81. let params = {
  82. userId: this.vuex_userId
  83. }
  84. this.$api.address.list(params).then(res => {
  85. this.addressList = res.data.data.records
  86. })
  87. }
  88. }
  89. };
  90. </script>
  91. <style lang="scss">
  92. .empty {
  93. display: flex;
  94. justify-content: center;
  95. align-items: center;
  96. margin-top: 360rpx;
  97. flex-direction: column;
  98. image {
  99. width: 220rpx;
  100. height: 170rpx;
  101. }
  102. text {
  103. margin-top: 20rpx;
  104. font-size: 28rpx;
  105. color: #c1c1c1;
  106. }
  107. }
  108. .address-list {
  109. padding: 40rpx;
  110. position: relative;
  111. background: #fff;
  112. margin-bottom: 20rpx;
  113. .name {
  114. font-size: 30rpx;
  115. font-weight: 600;
  116. margin-bottom: 10rpx;
  117. }
  118. .phone {
  119. font-size: 30rpx;
  120. margin: 0 20rpx;
  121. }
  122. .tag {
  123. background: rgba(233, 191, 113, 0.2);
  124. border-radius: 6rpx;
  125. padding: 0 16rpx;
  126. line-height: 38rpx;
  127. color: var(--bgColor);
  128. font-size: 22rpx;
  129. }
  130. .detail {
  131. margin-top: 25rpx;
  132. width: 543rpx;
  133. font-size: 26rpx;
  134. font-weight: 400;
  135. color: rgba(153, 153, 153, 1);
  136. line-height: 40rpx;
  137. }
  138. .set-btn {
  139. background: none;
  140. position: absolute;
  141. font-size: 26rpx;
  142. color: var(--bgColor);
  143. top: 40rpx;
  144. right: 40rpx;
  145. }
  146. }
  147. // 底部按钮
  148. .foot_box-wrap {
  149. height: 140rpx;
  150. width: 100%;
  151. }
  152. .foot_box {
  153. padding: 10rpx 20rpx;
  154. position: fixed;
  155. bottom: 0;
  156. left: 0;
  157. width: 100%;
  158. background-color: #fff;
  159. border-top: 1rpx solid rgba(#ccc, 0.2);
  160. .sync-wxaddress {
  161. flex: 1;
  162. line-height: 80rpx;
  163. background: rgba(255, 255, 255, 1);
  164. border-radius: 40rpx;
  165. box-shadow: 0 0 1rpx 6rpx rgba(#ccc, 0.2);
  166. }
  167. .add-btn {
  168. line-height: 80rpx;
  169. flex: 1;
  170. background: var(--bgColor);
  171. color: rgba(255, 255, 255, 1);
  172. border-radius: 40rpx;
  173. }
  174. }
  175. </style>