list.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <template>
  2. <div class="addresslist">
  3. <uni-swipe-action class="swipeAction" v-if="addressList.length">
  4. <uni-swipe-action-item
  5. class="swipeAction_item"
  6. v-for="(i, s) in addressList"
  7. :key="s"
  8. >
  9. <view class="addressLi clearfix" @click="onSelect(i, s)">
  10. <view class="addressLi_l">
  11. <div class="a_icon iconfont" v-if="i.status == 1">&#xe62a;</div>
  12. <div class="a_icon" v-else>{{ i.name.slice(0,1) }}</div>
  13. <!-- <text v-if="i.id != presentId" class="iconfont">&#xe623;</text>
  14. <text v-else class="iconfont pitchOn">&#xe624;</text> -->
  15. </view>
  16. <view class="addressLi_r">
  17. <view class="user">
  18. <text class="name">{{ i.name }}</text>
  19. <text>{{ i.mobile }}</text>
  20. <text v-if="i.status == 1" class="defaultAddress">默认</text>
  21. </view>
  22. <view class="address">{{ i.province + ' ' + i.city + ' ' + i.area + ' ' + i.street + ' ' + i.address }}</view>
  23. </view>
  24. </view>
  25. <template v-slot:right>
  26. <view class="btns clearfix">
  27. <view class="btn edit" @click="onedit(i)"
  28. ><text class="iconfont">&#xe600;</text></view
  29. >
  30. <view class="btn del" @click="delAddress(i.id)"
  31. ><text class="iconfont">&#xe601;</text></view
  32. >
  33. </view>
  34. </template>
  35. </uni-swipe-action-item>
  36. </uni-swipe-action>
  37. <div class="zanwu" v-else>
  38. <img src="@/static/img/zanwu.png" alt="" class="zanwuimg">
  39. <view class="zanwutxt">暂无地址信息</view>
  40. </div>
  41. <div class="footbtn" @click="goto('/pagesB/address/addaddress')">添加地址</div>
  42. </div>
  43. </template>
  44. <script>
  45. import { post } from "@/request/api.js";
  46. let app = getApp();
  47. var appEv = app.$vm.$options;
  48. export default {
  49. name: "addresslist",
  50. props: {},
  51. components: {},
  52. data() {
  53. return {
  54. addressList: [],
  55. };
  56. },
  57. methods: {
  58. // 获取用户地址
  59. loadAddress() {
  60. post("v1/user/addressList").then((res) => {
  61. if (res.code === 0) {
  62. this.addressList = res.data.data;
  63. }
  64. });
  65. },
  66. onedit(da) {
  67. uni.setStorageSync('address_form', da);
  68. this.goto('/pagesB/address/addaddress',{isedit:1})
  69. // let { id, name, mobile, address, province, city, area, street, status } = da;
  70. // this.userAddress = { id, name, mobile, address };
  71. // this.address = { province, city, area, street };
  72. // this.userAddress.region = province + " " + city + " " + area + " " + street;
  73. // this.is_default = status;
  74. },
  75. delAddress(id) {
  76. post("v1/user/delAddress", { id }).then((res) => {
  77. if (res.code === 0) {
  78. appEv.errTips(res.msg);
  79. this.loadAddress();
  80. }
  81. });
  82. },
  83. },
  84. onLoad(da) {},
  85. onShow() {
  86. this.loadAddress();
  87. },
  88. mounted() {},
  89. };
  90. </script>
  91. <style scoped lang='scss'>
  92. .swipeAction {
  93. font-size: 28rpx;
  94. .addressLi {
  95. .addressLi_l {
  96. width: 100rpx;
  97. height: 80rpx;
  98. display: flex;
  99. align-items: center;
  100. .a_icon{
  101. width: 60rpx;
  102. height: 60rpx;
  103. color: #f50;
  104. background: rgba($color: #f50, $alpha: 0.15);
  105. text-align: center;
  106. line-height: 60rpx;
  107. border-radius: 50%;
  108. font-size: 34rpx;
  109. }
  110. .iconfont {
  111. background: rgba($color: #f50, $alpha: 0.2);
  112. color: #fff;
  113. }
  114. }
  115. .addressLi_r {
  116. width: calc(100% - 100rpx);
  117. // padding-right: 20rpx;
  118. }
  119. .addressLi_l,
  120. .addressLi_r {
  121. float: left;
  122. }
  123. .user {
  124. margin-bottom: 10rpx;
  125. }
  126. .name {
  127. // font-size: 32rpx;
  128. margin-right: 10rpx;
  129. }
  130. .address {
  131. font-size: 24rpx;
  132. color: #999;
  133. padding: 0;
  134. }
  135. }
  136. // .swipeAction_item {
  137. // background: #fff;
  138. // margin-bottom: 20rpx;
  139. // }
  140. .btns {
  141. .btn {
  142. float: left;
  143. display: flex;
  144. justify-content: center;
  145. align-items: center;
  146. height: 100%;
  147. padding: 0 30rpx;
  148. color: #fff;
  149. font-size: 36rpx;
  150. }
  151. .edit {
  152. background: rgba(25, 137, 250, 0.5);
  153. }
  154. .del {
  155. background: rgba(238, 10, 36, 0.5);
  156. }
  157. .iconfont {
  158. color: #fff;
  159. }
  160. }
  161. }
  162. ::v-deep .uni-swipe_box {
  163. padding: 20rpx 30rpx;
  164. background: #fff;
  165. margin-bottom: 20rpx;
  166. }
  167. .defaultAddress {
  168. border: 1rpx solid #2db389;
  169. color: #2db389;
  170. border-radius: 6rpx;
  171. font-size: 18rpx;
  172. padding: 0 6rpx;
  173. margin-left: 20rpx;
  174. }
  175. .footbtn{
  176. width: calc(100% - 60rpx);
  177. height: 80rpx;
  178. background: #17bb87;
  179. border-radius: 45rpx;
  180. position: fixed;
  181. bottom: 50rpx;
  182. left: 30rpx;
  183. color: #fff;
  184. font-size: 36rpx;
  185. text-align: center;
  186. line-height: 80rpx;
  187. }
  188. </style>