addressManage.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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: 5px;">
  15. <view style="font-size: 12px;">
  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 {
  31. addressListApi,
  32. addressDeleteApi
  33. } from "@/api/address.js"
  34. export default {
  35. components: {
  36. noData
  37. },
  38. data() {
  39. return {
  40. list: [],
  41. select: false,
  42. url: "",
  43. ids: ""
  44. }
  45. },
  46. onLoad(query) {
  47. if(getApp().globalData.selectAddrss) {
  48. this.select = true
  49. }
  50. },
  51. onShow() {
  52. this.getList()
  53. },
  54. methods: {
  55. selectAddress(item) {
  56. if (this.select) {
  57. let params = {
  58. addressId: item.id,
  59. }
  60. this.$redirectTo("/pages/orderConfirm/orderConfirm", params)
  61. getApp().globalData.selectAddrss = false
  62. }
  63. },
  64. getList() {
  65. addressListApi().then(res => {
  66. console.log(res, 'addressListApi-res')
  67. this.list = res.data.list
  68. })
  69. },
  70. toAdd() {
  71. wx.navigateTo({url: '/pages/addressEdit/addressEdit'})
  72. },
  73. clickEdit(data) {
  74. wx.navigateTo({
  75. url: `/pages/addressEdit/addressEdit?id=${data.id}`
  76. })
  77. },
  78. clickDelete(data) {
  79. let _this = this
  80. wx.showModal({
  81. title: '提示',
  82. content : '删除该收货地址?',
  83. success: () => {
  84. let params = {
  85. id: data.id
  86. }
  87. addressDeleteApi(params).then(res => {
  88. wx.showToast({
  89. title: '操作成功'
  90. })
  91. _this.getList()
  92. })
  93. }
  94. })
  95. }
  96. }
  97. }
  98. </script>
  99. <style scoped lang="scss">
  100. .container {
  101. background: #eaeaea;
  102. overflow: scroll;
  103. }
  104. .list {
  105. margin-bottom: 60px;
  106. }
  107. .card {
  108. margin-top: 10px;
  109. margin-left: 10px;
  110. margin-right: 10px;
  111. padding: 10px;
  112. background: white;
  113. border-radius: 5px;
  114. font-size: 14px;
  115. .row {
  116. display: flex;
  117. justify-content: space-between;
  118. align-items: center;
  119. }
  120. }
  121. .bottom {
  122. position: fixed;
  123. bottom: 0;
  124. padding: 20px;
  125. text-align: center;
  126. width: calc(100% - 40px);
  127. .m_button {
  128. height: 36px;
  129. width: 40vw;
  130. line-height: 36px;
  131. border-radius: 18px;
  132. font-size: 13px;
  133. }
  134. }
  135. </style>