addressManage.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="container">
  3. <view class="list">
  4. <view class="card" v-for="(item, index) in list" :key="index" @click="selectAddress(item)">
  5. <view class="row">
  6. <view>
  7. {{ item.name }}
  8. </view>
  9. <view>
  10. {{ item.tel }}
  11. </view>
  12. <uni-icons color="#ff5a5a" type="trash" size="25" @click="clickDelete(item)"></uni-icons>
  13. </view>
  14. <view class="row" style="margin-top: 10rpx">
  15. <view style="font-size: 24rpx">
  16. {{ item.province }}{{ item.city }}{{ item.county }}{{ item.addressDetail }}
  17. </view>
  18. <uni-icons color="#00ce65" type="compose" size="25" @click="clickEdit(item)"></uni-icons>
  19. </view>
  20. </view>
  21. <noData v-if="list.length == 0" />
  22. </view>
  23. <view class="bottom">
  24. <button class="m_button" type="default" @click="toAdd">新建地址</button>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import noData from '@/component/noData.vue'
  30. import { addressListApi, addressDeleteApi } from '@/api/address.js'
  31. export default {
  32. components: {
  33. noData,
  34. },
  35. data() {
  36. return {
  37. list: [],
  38. select: false,
  39. url: '',
  40. ids: '',
  41. }
  42. },
  43. onLoad(query) {
  44. if (getApp().globalData.selectAddrss) {
  45. this.select = true
  46. }
  47. },
  48. onShow() {
  49. this.getList()
  50. },
  51. methods: {
  52. selectAddress(item) {
  53. if (this.select) {
  54. let params = {
  55. addressId: item.id,
  56. }
  57. this.$redirectTo('/pages/orderConfirm/orderConfirm', params)
  58. getApp().globalData.selectAddrss = false
  59. }
  60. },
  61. getList() {
  62. addressListApi().then(res => {
  63. console.log(res, 'addressListApi-res')
  64. this.list = res.data.list
  65. })
  66. },
  67. toAdd() {
  68. wx.navigateTo({ url: '/pages/addressEdit/addressEdit' })
  69. },
  70. clickEdit(data) {
  71. wx.navigateTo({
  72. url: `/pages/addressEdit/addressEdit?id=${data.id}`,
  73. })
  74. },
  75. clickDelete(data) {
  76. let _this = this
  77. wx.showModal({
  78. title: '提示',
  79. content: '删除该收货地址?',
  80. success: () => {
  81. let params = {
  82. id: data.id,
  83. }
  84. addressDeleteApi(params).then(res => {
  85. wx.showToast({
  86. title: '操作成功',
  87. })
  88. _this.getList()
  89. })
  90. },
  91. })
  92. },
  93. },
  94. }
  95. </script>
  96. <style scoped lang="scss">
  97. .container {
  98. background: #eaeaea;
  99. overflow: scroll;
  100. }
  101. .list {
  102. margin-bottom: 120rpx;
  103. }
  104. .card {
  105. margin-top: 20rpx;
  106. margin-left: 20rpx;
  107. margin-right: 20rpx;
  108. padding: 20rpx;
  109. background: white;
  110. border-radius: 10rpx;
  111. font-size: 28rpx;
  112. .row {
  113. display: flex;
  114. justify-content: space-between;
  115. align-items: center;
  116. }
  117. }
  118. .bottom {
  119. position: fixed;
  120. bottom: 0;
  121. padding: 40rpx;
  122. text-align: center;
  123. width: calc(100% - 80rpx);
  124. .m_button {
  125. height: 72rpx;
  126. width: 40vw;
  127. line-height: 72rpx;
  128. border-radius: 36rpx;
  129. font-size: 26rpx;
  130. }
  131. }
  132. </style>