u-toolbar.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <view
  3. class="u-toolbar"
  4. @touchmove.stop.prevent="noop"
  5. v-if="show"
  6. >
  7. <view
  8. class="u-toolbar__cancel__wrapper"
  9. hover-class="u-hover-class"
  10. >
  11. <text
  12. class="u-toolbar__wrapper__cancel"
  13. @tap="cancel"
  14. :style="{
  15. color: cancelColor
  16. }"
  17. >{{ cancelText }}</text>
  18. </view>
  19. <text
  20. class="u-toolbar__title u-line-1"
  21. v-if="title"
  22. >{{ title }}</text>
  23. <view
  24. class="u-toolbar__confirm__wrapper"
  25. hover-class="u-hover-class"
  26. >
  27. <text
  28. v-if='!confirmType'
  29. class="u-toolbar__wrapper__confirm"
  30. @tap="confirm"
  31. :style="{
  32. color: confirmColor
  33. }"
  34. >{{ confirmText }}</text>
  35. <button v-if='confirmType=="share"' :style="{
  36. color: confirmColor
  37. }" class="shareBtn u-toolbar__wrapper__confirm" type="default" data-name="shareBtn" open-type="share">
  38. {{ confirmText }}
  39. </button>
  40. </view>
  41. </view>
  42. </template>
  43. <script>
  44. import props from './props.js';
  45. /**
  46. * Toolbar 工具条
  47. * @description
  48. * @tutorial https://www.uviewui.com/components/toolbar.html
  49. * @property {Boolean} show 是否展示工具条(默认 true )
  50. * @property {String} cancelText 取消按钮的文字(默认 '取消' )
  51. * @property {String} confirmText 确认按钮的文字(默认 '确认' )
  52. * @property {String} cancelColor 取消按钮的颜色(默认 '#909193' )
  53. * @property {String} confirmColor 确认按钮的颜色(默认 '#3c9cff' )
  54. * @property {String} title 标题文字
  55. * @event {Function}
  56. * @example
  57. */
  58. export default {
  59. name: 'u-toolbar',
  60. mixins: [uni.$u.mpMixin, uni.$u.mixin,props],
  61. methods: {
  62. // 点击取消按钮
  63. cancel() {
  64. this.$emit('cancel')
  65. },
  66. // 点击确定按钮
  67. confirm() {
  68. this.$emit('confirm')
  69. }
  70. },
  71. }
  72. </script>
  73. <style lang="scss" scoped>
  74. @import "../../libs/css/components.scss";
  75. .u-toolbar {
  76. height: 42px;
  77. @include flex;
  78. justify-content: space-between;
  79. align-items: center;
  80. &__wrapper {
  81. &__cancel {
  82. color: $u-tips-color;
  83. font-size: 15px;
  84. padding: 0 15px;
  85. }
  86. }
  87. &__title {
  88. color: $u-main-color;
  89. padding: 0 60rpx;
  90. font-size: 16px;
  91. flex: 1;
  92. text-align: center;
  93. }
  94. &__wrapper {
  95. &__confirm {
  96. color: $u-primary;
  97. font-size: 15px;
  98. padding: 0 15px;
  99. }
  100. }
  101. }
  102. .shareBtn{
  103. background:transparent;
  104. line-height:1;
  105. font-size:30rpx;
  106. }
  107. .shareBtn:after{
  108. border:none;
  109. }
  110. </style>