Address.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="body">
  3. <view class="content">
  4. <view class="model" v-for="(item,index) in addressList" :key="index" >
  5. <view style="font-size: 1rem; font-weight: 550;">{{item.full_addr}}</view>
  6. <view style="margin-top: 2vw;"> <span>{{item.name}}</span> <span style="margin-left: 2vw;">{{item.tel}}</span> </view>
  7. <view style=" height: 20vw; display: flex; justify-content: space-around; align-items: center; border-top: 1px solid #f8f8f8; margin-top: 4vw;">
  8. <view style="display: flex;">
  9. <u-checkbox-group>
  10. <u-checkbox @change="checkboxChange(item)" v-model="item.default" label-disabled="true" shape="circle"
  11. active-color="red"></u-checkbox>
  12. </u-checkbox-group>
  13. <p style="color: red; margin-left: -4vw; margin-top: -1vw; font-size: 1rem;">已设为默认地址</p>
  14. </view>
  15. <view style="display: flex;">
  16. <p> <image style="width: 5vw; height: 5vw; " src="../../static/bianji.png"></image> </p>
  17. <p style="margin-left: 2vw;" @click="Edmit(item)">编辑</p>
  18. </view>
  19. <view style="display: flex;">
  20. <p> <image style="width: 5vw; height: 5vw; " src="../../static/shanchu.png"></image> </p>
  21. <p style="margin-left: 2vw;" @click="deleteAddress(item)" >删除</p>
  22. </view>
  23. </view>
  24. </view>
  25. <!-- <p>暂无收获地址哦~</p> -->
  26. </view>
  27. <view class="foot">
  28. <u-toast ref="uToast" />
  29. <view class="button" @click="saveAddress">添加新地址</view>
  30. </view>
  31. </view>
  32. </template>
  33. <script >
  34. export default{
  35. data(){
  36. return{
  37. checked: false,
  38. addressList:[]
  39. }
  40. },
  41. onLoad() {
  42. },
  43. onShow(){
  44. this.getAddressList()
  45. },
  46. methods:{
  47. checkboxChange(item) {
  48. console.log(item.default)
  49. this.$nextTick(()=>{
  50. this.$api.getRadio(item.id,item.default,res=>{
  51. if(res.code==0){
  52. this.getAddressList()
  53. }
  54. })
  55. })
  56. },
  57. Edmit(item){
  58. uni.navigateTo({
  59. url:'/pages/shopStore/saveAddress?addressInfo='+encodeURIComponent(JSON.stringify(item))
  60. })
  61. },
  62. getAddressList(){
  63. this.$api.getAddress(res=>{
  64. if(res.code==0){
  65. this.addressList=res.data
  66. }
  67. })
  68. },
  69. saveAddress(){
  70. uni.navigateTo({
  71. url:'/pages/shopStore/saveAddress'
  72. })
  73. },
  74. deleteAddress(item){
  75. this.$api.getdeleteAddress(item.id,res=>{
  76. if(res.code==0){
  77. this.getAddressList()
  78. }else{
  79. this.errorToast(res.msg)
  80. }
  81. })
  82. },
  83. successToast(msg) {
  84. this.$refs.uToast.show({
  85. title: msg,
  86. type: 'success',
  87. duration: 1000
  88. })
  89. },
  90. errorToast(msg) {
  91. this.$refs.uToast.show({
  92. title: msg,
  93. type: 'error',
  94. duration: 1000
  95. })
  96. },
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .body{
  102. width: 100vw;
  103. height: 100vh;
  104. .content{
  105. width: 100vw;
  106. height: 98vh;
  107. background-color: #f8f8f8;
  108. box-sizing: border-box;
  109. padding:0 5vw;
  110. overflow-y: auto;
  111. .model{
  112. width: 90vw;
  113. height: 20vh;
  114. border-radius: 5px;
  115. background-color: white;
  116. box-sizing: border-box;
  117. padding: 2vw;
  118. margin-top: 2vw;
  119. }
  120. // display: flex;
  121. // justify-content: center;
  122. // align-items: center;
  123. }
  124. .foot{
  125. width: 100vw;
  126. height: 20vw;
  127. border-top: 1px solid lightgray;
  128. position: fixed;
  129. bottom: 0;
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. }
  134. .button{
  135. width: 90vw;
  136. height: 12vw;
  137. text-align: center;
  138. line-height: 12vw;
  139. background-color: #f83036;
  140. color: white;
  141. border-radius: 32px;
  142. }
  143. }
  144. </style>