addressManage.vue 2.6 KB

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