address.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <view id="addressList">
  3. <view class="addresBox" v-for="item in newsInfo" :key="item.id">
  4. <!-- <image src="../../../static/img/common/addresList.svg" mode=""></image> -->
  5. <view @click="getItem(item)" class="adresInfo bb">
  6. <view class="adresName">
  7. {{ item.name }}
  8. <text class="textgrey">{{ item.phone }}</text>
  9. </view>
  10. <view class="adresDet">
  11. <text v-if="item.is_check == 1" class="promain">默认</text>
  12. {{ item.mergename }}{{ item.detail }}
  13. </view>
  14. </view>
  15. <!-- "is_default": 1, //是否默认 1=默认 0=不默认 -->
  16. <view class="adresDo dfsb">
  17. <view @click="showDefault(1, item)" class="flex1 dffs">
  18. <image class="icon" v-if="item.is_default == 1" src="/static/img/pro/chenggong.png" mode=""></image>
  19. <image class="icon" v-if="item.is_default == 0" src="/static/img/pro/wxz.png" mode=""></image>
  20. 设为默认
  21. </view>
  22. <text @click="showDefault(2, item)" class="textgrey fontsm">删除</text>
  23. <text @click="showDefault(3, item)" class="textgrey fontsm">修改</text>
  24. </view>
  25. </view>
  26. <u-empty v-if="newsInfo.length < 1" icon-size="200" text="还没有收货地址哦,快去添加吧!" mode="list"></u-empty>
  27. <!-- #ifdef MP -->
  28. <!-- #endif -->
  29. <view @tap="doAddres('add')" class="fixBox"><view class="clickbtn">添加新地址</view></view>
  30. </view>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'addressList',
  35. data() {
  36. return {
  37. newsInfo: [],
  38. page: 1,
  39. limit: 10,
  40. status: 'more'
  41. };
  42. },
  43. onNavigationBarButtonTap(e) {
  44. uni.navigateTo({
  45. url: './editAddres?type=add'
  46. });
  47. },
  48. onReachBottom() {
  49. if (this.status == 'nomore') return;
  50. this.page = ++this.page;
  51. this.getAddList();
  52. },
  53. onLoad(opt) {
  54. // this.selType = opt.type || '';
  55. },
  56. onShow() {
  57. // this.selType = opt.type || '';
  58. this.status = 'loadmore';
  59. this.page = 1;
  60. this.getAddList();
  61. },
  62. methods: {
  63. doAddres(type, val) {
  64. console.log(2);
  65. uni.navigateTo({
  66. url: './editAddres?type=' + type
  67. });
  68. },
  69. getItem(item) {
  70. let address = { shou_name: item.name, shou_phone: item.phone, address_id: item.id, shou_address: item.mergename + item.detail };
  71. // console.log(this.$api.prePage().$data.addressInfo);
  72. this.$api.prePage().addressInfo = address;
  73. uni.navigateBack({
  74. delta: 1
  75. });
  76. },
  77. getAddList() {
  78. this.$api
  79. .request('user_address/addressList', {
  80. page: this.page,
  81. limit: this.limit
  82. })
  83. .then(data => {
  84. if (data.code == 200) {
  85. this.newsInfo = data.data.list;
  86. if (data.data.list.length < this.limit) {
  87. this.status = 'nomore';
  88. }
  89. } else {
  90. this.$api.toast(data.msg);
  91. }
  92. });
  93. },
  94. // 设为默认
  95. showDefault(val, item) {
  96. if (val == 3) {
  97. uni.navigateTo({
  98. url: '/pages/user/address/editAddres?type=edit' + '&id=' + item.id
  99. });
  100. return;
  101. }
  102. let url = val == 1 ? 'user_address/setDefault' : 'user_address/addressDel';
  103. this.$api
  104. .request(url, {
  105. id: item.id
  106. })
  107. .then(data => {
  108. this.$api.toast(data.msg);
  109. if (data.code == 200) {
  110. setTimeout(res => {
  111. this.getAddList();
  112. }, 800);
  113. }
  114. });
  115. }
  116. }
  117. };
  118. </script>
  119. <style lang="scss" scoped>
  120. #addressList {
  121. padding: 30rpx 30rpx 120rpx;
  122. .addresBox {
  123. background: rgba(255, 255, 255, 1);
  124. border-radius: 16rpx;
  125. padding: 0 30rpx;
  126. margin-bottom: 30rpx;
  127. image {
  128. width: 72rpx;
  129. height: 72rpx;
  130. }
  131. .adresInfo {
  132. flex: 1;
  133. padding: 20rpx 0;
  134. .adresName {
  135. font-size: 30rpx;
  136. line-height: 44rpx;
  137. text {
  138. font-size: 30rpx;
  139. margin-left: 8rpx;
  140. }
  141. }
  142. .adresDet {
  143. line-height: 40rpx;
  144. font-size: 30rpx;
  145. .promain {
  146. font-size: 24rpx;
  147. min-width: 80rpx;
  148. padding: 0 16rpx;
  149. height: 40rpx;
  150. line-height: 40rpx;
  151. background: rgba(224, 40, 40, 0.1);
  152. border-radius: 4rpx;
  153. margin-right: 8rpx;
  154. }
  155. }
  156. }
  157. .adresDo {
  158. padding: 17rpx 0 29rpx;
  159. color: #999;
  160. .icon {
  161. width: 30rpx;
  162. height: 30rpx;
  163. margin-right: 12rpx;
  164. }
  165. .flex1 {
  166. font-size: 26rpx;
  167. }
  168. .textgrey {
  169. margin-left: 65rpx;
  170. }
  171. }
  172. }
  173. .clickbtn {
  174. margin: 0 auto;
  175. border-radius: 11rpx;
  176. }
  177. }
  178. </style>