address.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. <template>
  2. <view class="container">
  3. <view class="address-list" v-if="addressList.length > 0">
  4. <view class="item" v-for="(item, index) in addressList" :key="item.id" @tap="selectAddress" :data-address-id="item.id">
  5. <view class="l">
  6. <view class="name">{{item.userName||''}}</view>
  7. <view class="default" v-if="item.is_default">默认</view>
  8. </view>
  9. <view class="c">
  10. <view class="mobile">{{item.telNumber}}</view>
  11. <view class="address">{{item.full_region+item.detailInfo}}</view>
  12. </view>
  13. <view class="r">
  14. <image @click.stop.prevent="addressAddOrUpdate" :data-address-id="item.id" class="del" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-edit-7fee7b0d63.png"></image>
  15. </view>
  16. </view>
  17. </view>
  18. <view class="empty-view" v-if="addressList.length <= 0">
  19. <image class="icon" src="http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/noAddress-26d570cefa.png"></image>
  20. <text class="text">收货地址在哪里</text>
  21. </view>
  22. <view class="add-address" @tap="addressAddOrUpdate" :data-address-id="0">新建</view>
  23. </view>
  24. </template>
  25. <script>
  26. const util = require("@/utils/util.js");
  27. const api = require('@/utils/api.js');
  28. export default {
  29. data() {
  30. return {
  31. addressList: []
  32. }
  33. },
  34. methods: {
  35. getAddressList() {
  36. let that = this;
  37. util.request(api.AddressList).then(function(res) {
  38. if (res.errno === 0) {
  39. that.addressList = res.data
  40. }
  41. });
  42. },
  43. addressAddOrUpdate(event) {
  44. uni.navigateTo({
  45. url: '/pages/shopping/addressAdd/addressAdd?id=' + event.currentTarget.dataset.addressId
  46. });
  47. },
  48. selectAddress(event) {
  49. try {
  50. uni.setStorageSync('addressId', event.currentTarget.dataset.addressId);
  51. } catch (e) {
  52. }
  53. //选择该收货地址
  54. uni.navigateBack({
  55. url: '/pages/shopping/checkout/checkout'
  56. });
  57. }
  58. },
  59. onShow: function() {
  60. this.getAddressList();
  61. }
  62. }
  63. </script>
  64. <style lang="scss">
  65. page {
  66. height: 100%;
  67. width: 100%;
  68. background: #f4f4f4;
  69. }
  70. .container {
  71. height: 100%;
  72. width: 100%;
  73. }
  74. .address-list {
  75. padding-left: 31.25rpx;
  76. background: #fff url(http://yanxuan.nosdn.127.net/hxm/yanxuan-wap/p/20161201/style/img/icon-normal/address-bg-bd30f2bfeb.png) 0 0 repeat-x;
  77. background-size: auto 10.5rpx;
  78. margin-bottom: 90rpx;
  79. }
  80. .address-list .item {
  81. height: 156.55rpx;
  82. align-items: center;
  83. display: flex;
  84. border-bottom: 1rpx solid #DCD9D9;
  85. }
  86. .address-list .item:last-child {
  87. border-bottom: none;
  88. }
  89. .address-list .l {
  90. width: 155rpx;
  91. height: 80rpx;
  92. overflow: hidden;
  93. }
  94. .address-list .name {
  95. width: 155rpx;
  96. height: 43rpx;
  97. font-size: 29rpx;
  98. color: #333;
  99. margin-bottom: 5.2rpx;
  100. text-overflow: ellipsis;
  101. white-space: nowrap;
  102. overflow: hidden;
  103. }
  104. .address-list .default {
  105. width: 62.5rpx;
  106. height: 33rpx;
  107. line-height: 28rpx;
  108. text-align: center;
  109. font-size: 20rpx;
  110. color: #b4282d;
  111. border: 1rpx solid #b4282d;
  112. visibility: visible;
  113. }
  114. .address-list .c {
  115. flex: 1;
  116. height: auto;
  117. overflow: hidden;
  118. }
  119. .address-list .mobile {
  120. height: 29rpx;
  121. font-size: 29rpx;
  122. line-height: 29rpx;
  123. overflow: hidden;
  124. color: #333;
  125. margin-bottom: 6.25rpx;
  126. }
  127. .address-list .address {
  128. height: 37rpx;
  129. font-size: 25rpx;
  130. line-height: 37rpx;
  131. overflow: hidden;
  132. color: #666;
  133. }
  134. .address-list .r {
  135. width: 52rpx;
  136. height: auto;
  137. overflow: hidden;
  138. margin-right: 16.5rpx;
  139. }
  140. .address-list .del {
  141. display: block;
  142. width: 52rpx;
  143. height: 52rpx;
  144. }
  145. .add-address {
  146. background: #b4282d;
  147. text-align: center;
  148. width: 100%;
  149. height: 99rpx;
  150. line-height: 99rpx;
  151. position: fixed;
  152. border-radius: 0;
  153. border: none;
  154. color: #fff;
  155. font-size: 29rpx;
  156. bottom: 0;
  157. left: 0;
  158. }
  159. .empty-view {
  160. height: 100%;
  161. width: 100%;
  162. display: flex;
  163. flex-direction: column;
  164. align-items: center;
  165. justify-content: center;
  166. }
  167. .empty-view .icon {
  168. height: 248rpx;
  169. width: 258rpx;
  170. margin-bottom: 10rpx;
  171. }
  172. .empty-view .text {
  173. width: auto;
  174. font-size: 28rpx;
  175. line-height: 35rpx;
  176. color: #999;
  177. }
  178. </style>