index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use } from '../utils';
  3. import { emit, inherit } from '../utils/functional';
  4. import Button from '../button'; // Types
  5. var _use = use('submit-bar'),
  6. sfc = _use[0],
  7. bem = _use[1],
  8. t = _use[2];
  9. function SubmitBar(h, props, slots, ctx) {
  10. var tip = props.tip,
  11. price = props.price;
  12. var hasPrice = typeof price === 'number';
  13. return h("div", _mergeJSXProps([{
  14. "class": bem({
  15. 'safe-area-inset-bottom': props.safeAreaInsetBottom
  16. })
  17. }, inherit(ctx)]), [slots.top && slots.top(), (slots.tip || tip) && h("div", {
  18. "class": bem('tip')
  19. }, [tip, slots.tip && slots.tip()]), h("div", {
  20. "class": bem('bar')
  21. }, [slots["default"] && slots["default"](), h("div", {
  22. "class": bem('text')
  23. }, [hasPrice && [h("span", [props.label || t('label')]), h("span", {
  24. "class": bem('price')
  25. }, [props.currency + " " + (price / 100).toFixed(props.decimalLength)])]]), h(Button, {
  26. "attrs": {
  27. "square": true,
  28. "size": "large",
  29. "type": props.buttonType,
  30. "loading": props.loading,
  31. "disabled": props.disabled,
  32. "text": props.loading ? '' : props.buttonText
  33. },
  34. "on": {
  35. "click": function click() {
  36. emit(ctx, 'submit');
  37. }
  38. }
  39. })])]);
  40. }
  41. SubmitBar.props = {
  42. tip: String,
  43. label: String,
  44. loading: Boolean,
  45. disabled: Boolean,
  46. buttonText: String,
  47. safeAreaInsetBottom: Boolean,
  48. price: {
  49. type: Number,
  50. "default": null
  51. },
  52. decimalLength: {
  53. type: Number,
  54. "default": 2
  55. },
  56. currency: {
  57. type: String,
  58. "default": '¥'
  59. },
  60. buttonType: {
  61. type: String,
  62. "default": 'danger'
  63. }
  64. };
  65. export default sfc(SubmitBar);