addressPink.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="content b-t">
  3. <view class="list" v-if="addressList.real_name">
  4. <view class="wrapper">
  5. <view class="address-box">
  6. <text class="name">{{ addressList.real_name }}</text>
  7. <text class="mobile">{{ addressList.phone }}</text>
  8. </view>
  9. <view class="u-box">
  10. <text class="address">{{ addressList.province + addressList.city + addressList.district }} {{ addressList.detail }}</text>
  11. </view>
  12. </view>
  13. <view class="buttom">
  14. <!-- <view class="default-buttom" @click.stop="defaultUp(item,index)">
  15. <view class="iconfont iconroundcheckfill checkbox" :class="{ checked: item.is_default == 1 }"></view>
  16. <text class="text">设为默认地址</text>
  17. </view> -->
  18. <view class="operation">
  19. <view @click.stop="addAddress('edit', addressList)">
  20. <text class="iconfont iconedit"></text>
  21. <text class="text">编辑</text>
  22. </view>
  23. <view class="blank"></view>
  24. <!-- <view @click.stop="delAddress(item)">
  25. <text class="iconfont icondelete"></text>
  26. <text class="text">删除</text>
  27. </view> -->
  28. </view>
  29. </view>
  30. </view>
  31. <button v-if="!addressList.real_name" class="add-btn" @click="addAddress('add')">新增拼团地址</button>
  32. </view>
  33. </template>
  34. <script>
  35. import { pinkAddress } from '@/api/address.js';
  36. export default {
  37. data() {
  38. return {
  39. source: 0,
  40. addressList: {}
  41. };
  42. },
  43. onLoad(option) {
  44. this.source = option.source||0
  45. this.loadAddress();
  46. },
  47. methods: {
  48. // 加载地址
  49. loadAddress() {
  50. pinkAddress({
  51. page: 1,
  52. limit: 100
  53. }).then(({ data }) => {
  54. console.log(data,9654)
  55. this.addressList = data;
  56. });
  57. },
  58. // 设为默认地址
  59. defaultUp(data,ind) {
  60. this.addressList=this.addressList.map((e) => {
  61. e.is_default=0
  62. return e
  63. })
  64. this.addressList[ind].is_default=1
  65. setAddressDefault({
  66. id: data.id
  67. }).then(({ data }) => {
  68. this.loadAddress();
  69. }).catch((e) => {
  70. console.log(e);
  71. });
  72. },
  73. //删除地址
  74. // delAddress(item) {
  75. // addressDel({
  76. // id:item.id
  77. // }).then(({data})=>{
  78. // this.$api.msg('删除成功')
  79. // })
  80. // let s = this.addressList.indexOf(item);
  81. // this.addressList.splice(s, 1);
  82. // },
  83. //选择地址
  84. checkAddress(item) {
  85. if (this.source == 1) {
  86. //this.$api.prePage()获取上一页实例,在App.vue定义
  87. this.$api.prePage().addressData = item;
  88. uni.navigateBack();
  89. }
  90. },
  91. // 添加地址
  92. addAddress(type, item) {
  93. uni.navigateTo({
  94. url: `/pages/address/addPinkManage?type=${type}&data=${JSON.stringify(item)}`
  95. });
  96. },
  97. //添加或修改成功之后回调
  98. refreshList() {
  99. // 重新加载地址
  100. this.loadAddress()
  101. }
  102. }
  103. };
  104. </script>
  105. <style lang="scss">
  106. page {
  107. padding-bottom: 120rpx;
  108. padding-top: 20rpx;
  109. background-color: $page-color-base;
  110. }
  111. .content {
  112. position: relative;
  113. }
  114. .list {
  115. align-items: center;
  116. padding: 20rpx 30rpx;
  117. background: #fff;
  118. margin: 20rpx;
  119. margin-top: 0;
  120. .buttom {
  121. display: flex;
  122. align-items: center;
  123. justify-content: space-between;
  124. padding-top: 10rpx;
  125. .checkbox {
  126. font-size: 44rpx;
  127. line-height: 1;
  128. padding: 4rpx;
  129. color: $font-color-disabled;
  130. background: #fff;
  131. border-radius: 50px;
  132. }
  133. .checkbox.checked {
  134. color: $base-color;
  135. }
  136. .default-buttom {
  137. display: flex;
  138. align-items: center;
  139. }
  140. .operation {
  141. display: flex;
  142. align-items: center;
  143. .blank {
  144. width: 30rpx;
  145. }
  146. }
  147. .text {
  148. padding-left: 10rpx;
  149. font-size: 24rpx;
  150. color: #666666;
  151. }
  152. }
  153. }
  154. .wrapper {
  155. display: flex;
  156. flex-direction: column;
  157. flex: 1;
  158. border-bottom: 1px solid #f0f0f0;
  159. padding-bottom: 20rpx;
  160. }
  161. .address-box {
  162. display: flex;
  163. align-items: center;
  164. justify-content: space-between;
  165. .address {
  166. font-size: $font-base + 2rpx;
  167. color: $font-color-dark;
  168. }
  169. .mobile {
  170. font-size: $font-base;
  171. color: rgba(51, 51, 51, 1);
  172. }
  173. }
  174. .u-box {
  175. font-size: $font-base;
  176. color: $font-color-light;
  177. margin-top: 16rpx;
  178. .name {
  179. margin-right: 30rpx;
  180. }
  181. }
  182. .icon-bianji {
  183. display: flex;
  184. align-items: center;
  185. height: 80rpx;
  186. font-size: 40rpx;
  187. color: $font-color-light;
  188. padding-left: 30rpx;
  189. }
  190. .add-btn {
  191. position: fixed;
  192. left: 30rpx;
  193. right: 30rpx;
  194. bottom: 16rpx;
  195. z-index: 95;
  196. display: flex;
  197. align-items: center;
  198. justify-content: center;
  199. width: 690rpx;
  200. height: 80rpx;
  201. font-size: $font-lg;
  202. color: #fff;
  203. background-color: $base-color;
  204. border-radius: 10rpx;
  205. }
  206. </style>