en-button.vue 3.1 KB

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