address.vue 3.8 KB

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