en-button.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. centreText: {
  32. type: String,
  33. default: '取消'
  34. },
  35. leftText: {
  36. type: String,
  37. default: '取消'
  38. },
  39. rightText: {
  40. type: String,
  41. default: '确认'
  42. },
  43. color: {
  44. type: String,
  45. default: '#fff'
  46. },
  47. fontSize: {
  48. type: String,
  49. default: '28rpx'
  50. },
  51. width: {
  52. type: String,
  53. default: `100%`
  54. },
  55. bothWidth: {
  56. type: String,
  57. default: `50%`
  58. },
  59. height: {
  60. type: String,
  61. default: `70rpx`
  62. },
  63. borderRadius: {
  64. type: String,
  65. default: '100rpx'
  66. },
  67. },
  68. data() {
  69. return {}
  70. },
  71. methods: {
  72. onSubmit() {
  73. this.$emit('onSubmit')
  74. },
  75. onLeftSubmit() {
  76. this.$emit('onLeftSubmit')
  77. },
  78. onCentreSubmit(){
  79. this.$emit('onCentreSubmit')
  80. }
  81. }
  82. }
  83. </script>
  84. <style lang="scss" scoped>
  85. .en-button {
  86. line-height: 80rpx;
  87. border: none;
  88. }
  89. .en-button-left {
  90. color: #0FB160;
  91. border: 1rpx solid #0FB160 !important;
  92. line-height: 80rpx;
  93. background-color: #fff;
  94. }
  95. button::after {
  96. border: none;
  97. }
  98. .fixed-button {
  99. position: fixed;
  100. bottom: 0;
  101. z-index: 999999;
  102. background: #fff;
  103. width: calc(100% - 60rpx);
  104. padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
  105. }
  106. </style>