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.

133 lines
2.9 KiB

8 months ago
  1. <template>
  2. <view class="redact-address">
  3. <template #default>
  4. <view class="redact-address-title">{{title}}</view>
  5. <van-form label-width="110rpx" ref="form">
  6. <van-cell-group inset>
  7. <van-field v-model="addressDetail.name" name="联系人" label="联系人" placeholder="请输入联系人姓名"
  8. :rules="[{ required: true, message: '请填写联系人' }]" />
  9. <van-field v-model="addressDetail.phone" name="手机号" label="手机号" placeholder="请输入手机号"
  10. :rules="[{ required: true, message: '请填写手机号' }]" />
  11. <van-field @click="$emit('clickAddressIcon')" v-model="addressDetail.address" name="所在地区" label="所在地区" placeholder="选择省市区街道"
  12. :rules="[{ required: true, message: '请选择省市区街道' }]">
  13. <template #right-icon>
  14. <image @click.stop="$emit('clickAddressIcon')" src="../../static/address/position-icon.png" mode="aspectFit"></image>定位
  15. </template>
  16. </van-field>
  17. <van-field v-model="addressDetail.addressDetail" name="详细地址" label="详细地址" placeholder="小区楼栋、门牌号、村等"
  18. :rules="[{ required: true, message: '请填写详细地址' }]" />
  19. </van-cell-group>
  20. </van-form>
  21. <view @click="onSubmit" class="save">{{ addressDetail.id ? '修改地址' : '新增地址'}}</view>
  22. </template>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {}
  29. },
  30. props : {
  31. addressDetail : {
  32. type : Object,
  33. default : function(){ return {} }
  34. },
  35. title : {
  36. type : String,
  37. default : '新增地址'
  38. }
  39. },
  40. methods: {
  41. //新增和修改地址
  42. onSubmit() {
  43. this.$emit('saveOrUpdate', this.addressDetail)
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="scss" scoped>
  49. .redact-address {
  50. box-sizing: border-box;
  51. .redact-address-title {
  52. height: 80rpx;
  53. line-height: 80rpx;
  54. font-size: 30rpx;
  55. color: #333333;
  56. font-weight: 600;
  57. }
  58. .save {
  59. display: flex;
  60. align-items: center;
  61. justify-content: center;
  62. width: 90%;
  63. height: 80rpx;
  64. border-radius: 40rpx;
  65. color: white;
  66. font-size: 28rpx;
  67. margin: 0rpx auto;
  68. background: linear-gradient(180deg, #6FDFBE, #5AC796);
  69. }
  70. image {
  71. width: 25rpx;
  72. height: 25rpx;
  73. }
  74. //修改组件默认样式
  75. .van-form {
  76. padding: 30rpx 0rpx;
  77. }
  78. &::v-deep .van-cell {
  79. padding: 0rpx 0rpx;
  80. font-size: 26rpx;
  81. &::after {
  82. border: none !important;
  83. }
  84. .van-field__label {
  85. display: flex;
  86. align-items: center;
  87. height: 80rpx;
  88. }
  89. .van-field__control,
  90. .van-field__right-icon {
  91. height: 80rpx;
  92. font-size: 26rpx;
  93. border-bottom: 2rpx solid #cbc8c8;
  94. }
  95. .van-field__right-icon {
  96. display: flex;
  97. align-items: center;
  98. height: 78rpx;
  99. color: #5FCC9F;
  100. }
  101. .van-cell__value {
  102. height: 120rpx;
  103. }
  104. }
  105. &::v-deep .van-field__error-message {
  106. color: #5AC796;
  107. font-size: 20rpx;
  108. margin-top: 10rpx;
  109. }
  110. }
  111. </style>