普兆健康管家前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
2.8 KiB

  1. <template>
  2. <view class="card">
  3. <view class="top" @click="$emit('click')">
  4. <addressView :data="data"></addressView>
  5. </view>
  6. <view class="flex bottom">
  7. <view class="flex col">
  8. <view>
  9. <uv-radio-group
  10. v-model="radiovalue"
  11. shape="circle"
  12. size="36rpx"
  13. iconSize="36rpx"
  14. labelSize="24rpx"
  15. labelColor="#9B9B9B"
  16. activeColor="#7451DE"
  17. @change="onRadioChange"
  18. >
  19. <uv-radio :name="1">
  20. <view>默认地址</view>
  21. </uv-radio>
  22. </uv-radio-group>
  23. </view>
  24. </view>
  25. <button class="flex col btn" @click="onEdit">
  26. <image class="icon" src="@/pages_order/static/address/icon-edit.png" mode="scaleToFill"></image>
  27. <view>编辑</view>
  28. </button>
  29. <button class="flex col btn" @click="onDelete">
  30. <image class="icon" src="@/pages_order/static/address/icon-delete.png" mode="scaleToFill"></image>
  31. <view>删除</view>
  32. </button>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import addressView from './addressView.vue';
  38. export default {
  39. components: {
  40. addressView,
  41. },
  42. props: {
  43. data: {
  44. type: Object,
  45. default() {
  46. return {}
  47. }
  48. },
  49. },
  50. data() {
  51. return {
  52. radiovalue: null,
  53. }
  54. },
  55. computed: {
  56. isDefault: {
  57. set(val) {
  58. this.radiovalue = val ? 1 : null
  59. if (this.data.default == val) {
  60. return
  61. }
  62. // todo: set this address as default
  63. this.$emit('defaultChange', val)
  64. },
  65. get() {
  66. return this.radiovalue == 1 ? true : false
  67. }
  68. },
  69. },
  70. watch: {
  71. data: {
  72. handler(val) {
  73. this.isDefault = val.default
  74. },
  75. immediate: true,
  76. deep: true,
  77. }
  78. },
  79. methods: {
  80. onRadioChange() {
  81. this.isDefault = true
  82. },
  83. onEdit() {
  84. // todo
  85. this.$emit('edit')
  86. },
  87. onDelete() {
  88. uni.showModal({
  89. title: '确认删除?',
  90. success : e => {
  91. if(e.confirm){
  92. // todo
  93. this.$emit('delete')
  94. }
  95. }
  96. })
  97. },
  98. }
  99. }
  100. </script>
  101. <style scoped lang="scss">
  102. .card {
  103. padding: 24rpx 32rpx;
  104. background: #FFFFFF;
  105. border-radius: 24rpx;
  106. .top {
  107. padding-bottom: 24rpx;
  108. }
  109. .bottom {
  110. padding-top: 24rpx;
  111. column-gap: 24rpx;
  112. border-top: 2rpx dashed #DADADA;
  113. .col {
  114. flex: 1;
  115. column-gap: 8rpx;
  116. font-family: PingFang SC;
  117. font-weight: 400;
  118. font-size: 24rpx;
  119. line-height: 1.4;
  120. color: #9B9B9B;
  121. .icon {
  122. width: 36rpx;
  123. height: 36rpx;
  124. }
  125. }
  126. }
  127. }
  128. </style>