en-button.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view :style="[{lineHeight:height}]">
  3. <view class="p-t20 p-lr30" :class="is_fixed?'fixed-button':''" v-if="!is_both">
  4. <button class="en-button button-background sys-weight-500" type="default" hover-class="is-hover"
  5. :style="[{width},{borderRadius},{fontSize},{color}]" @click="onSubmit">{{text}}</button>
  6. </view>
  7. <view class="row-justify-sb center p-lr30 p-t20" :class="is_fixed?'fixed-button':''" v-else>
  8. <button class="en-button-left button-background button-color sys-weight-500 m-r30" type="default"
  9. hover-class="is-hover" :style="[{width:bothWidth},{borderRadius},{fontSize}]"
  10. @click="onLeftSubmit">{{leftText}}</button>
  11. <button class="en-button button-background sys-weight-500" type="default" hover-class="is-hover"
  12. :style="[{width:bothWidth},{borderRadius},{fontSize},{color}]" @click="onSubmit">{{rightText}}</button>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. export default {
  18. props: {
  19. is_both: {
  20. type: Boolean,
  21. default: false
  22. },
  23. is_fixed: {
  24. type: Boolean,
  25. default: true
  26. },
  27. text: {
  28. type: String,
  29. default: '提交'
  30. },
  31. leftText: {
  32. type: String,
  33. default: '取消'
  34. },
  35. rightText: {
  36. type: String,
  37. default: '确认'
  38. },
  39. color: {
  40. type: String,
  41. default: '#fff'
  42. },
  43. fontSize: {
  44. type: String,
  45. default: '28rpx'
  46. },
  47. width: {
  48. type: String,
  49. default: `100%`
  50. },
  51. bothWidth: {
  52. type: String,
  53. default: `50%`
  54. },
  55. height: {
  56. type: String,
  57. default: `70rpx`
  58. },
  59. borderRadius: {
  60. type: String,
  61. default: '100rpx'
  62. },
  63. },
  64. data() {
  65. return {}
  66. },
  67. methods: {
  68. onSubmit() {
  69. this.$emit('onSubmit')
  70. },
  71. onLeftSubmit() {
  72. this.$emit('onLeftSubmit')
  73. },
  74. }
  75. }
  76. </script>
  77. <style lang="scss" scoped>
  78. .en-button {
  79. line-height: 80rpx;
  80. border: none;
  81. }
  82. .en-button-left {
  83. color: #0FB160;
  84. border: 1rpx solid #0FB160 !important;
  85. line-height: 80rpx;
  86. background-color: #fff;
  87. }
  88. button::after {
  89. border: none;
  90. }
  91. .fixed-button {
  92. position: fixed;
  93. bottom: 0;
  94. z-index: 999999;
  95. background: #fff;
  96. width: calc(100% - 60rpx);
  97. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  98. }
  99. </style>