addressManage.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. }
  57. },
  58. getList() {
  59. addressListApi().then(res => {
  60. console.log(res, 'addressListApi-res')
  61. this.list = res.data.list
  62. })
  63. },
  64. toAdd() {
  65. wx.navigateTo({url: '/pages/addressEdit/addressEdit'})
  66. },
  67. clickEdit(data) {
  68. wx.navigateTo({
  69. url: `/pages/addressEdit/addressEdit?id=${data.id}`
  70. })
  71. },
  72. clickDelete(data) {
  73. let _this = this
  74. wx.showModal({
  75. title: '提示',
  76. content : '删除该收货地址?',
  77. success: () => {
  78. let params = {
  79. id: data.id
  80. }
  81. addressDeleteApi(params).then(res => {
  82. wx.showToast({
  83. title: '操作成功'
  84. })
  85. _this.getList()
  86. })
  87. }
  88. })
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped lang="scss">
  94. .container {
  95. background: #eaeaea;
  96. overflow: scroll;
  97. }
  98. .list {
  99. margin-bottom: 60px;
  100. }
  101. .card {
  102. margin-top: 10px;
  103. margin-left: 10px;
  104. margin-right: 10px;
  105. padding: 10px;
  106. background: white;
  107. border-radius: 5px;
  108. font-size: 14px;
  109. .row {
  110. display: flex;
  111. justify-content: space-between;
  112. align-items: center;
  113. }
  114. }
  115. .bottom {
  116. position: fixed;
  117. bottom: 0;
  118. padding: 20px;
  119. text-align: center;
  120. width: calc(100% - 40px);
  121. .m_button {
  122. height: 36px;
  123. width: 40vw;
  124. line-height: 36px;
  125. border-radius: 18px;
  126. font-size: 13px;
  127. }
  128. }
  129. </style>