index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
  6. var _utils = require("../utils");
  7. var _functional = require("../utils/functional");
  8. var _icon = _interopRequireDefault(require("../icon"));
  9. var _button = _interopRequireDefault(require("../button"));
  10. // Utils
  11. // Components
  12. var _createNamespace = (0, _utils.createNamespace)('submit-bar'),
  13. createComponent = _createNamespace[0],
  14. bem = _createNamespace[1],
  15. t = _createNamespace[2];
  16. function SubmitBar(h, props, slots, ctx) {
  17. var tip = props.tip,
  18. price = props.price,
  19. tipIcon = props.tipIcon;
  20. function Text() {
  21. if (typeof price === 'number') {
  22. var priceArr = (price / 100).toFixed(props.decimalLength).split('.');
  23. var decimalStr = props.decimalLength ? "." + priceArr[1] : '';
  24. return h("div", {
  25. "style": {
  26. textAlign: props.textAlign ? props.textAlign : ''
  27. },
  28. "class": bem('text')
  29. }, [h("span", [props.label || t('label')]), h("span", {
  30. "class": bem('price')
  31. }, [props.currency, h("span", {
  32. "class": bem('price', 'integer')
  33. }, [priceArr[0]]), decimalStr]), props.suffixLabel && h("span", {
  34. "class": bem('suffix-label')
  35. }, [props.suffixLabel])]);
  36. }
  37. }
  38. function Tip() {
  39. if (slots.tip || tip) {
  40. return h("div", {
  41. "class": bem('tip')
  42. }, [tipIcon && h(_icon.default, {
  43. "class": bem('tip-icon'),
  44. "attrs": {
  45. "name": tipIcon
  46. }
  47. }), tip && h("span", {
  48. "class": bem('tip-text')
  49. }, [tip]), slots.tip && slots.tip()]);
  50. }
  51. }
  52. return h("div", (0, _babelHelperVueJsxMergeProps.default)([{
  53. "class": bem({
  54. unfit: !props.safeAreaInsetBottom
  55. })
  56. }, (0, _functional.inherit)(ctx)]), [slots.top && slots.top(), Tip(), h("div", {
  57. "class": bem('bar')
  58. }, [slots.default && slots.default(), Text(), slots.button ? slots.button() : h(_button.default, {
  59. "attrs": {
  60. "round": true,
  61. "type": props.buttonType,
  62. "text": props.loading ? '' : props.buttonText,
  63. "color": props.buttonColor,
  64. "loading": props.loading,
  65. "disabled": props.disabled
  66. },
  67. "class": bem('button', props.buttonType),
  68. "on": {
  69. "click": function click() {
  70. (0, _functional.emit)(ctx, 'submit');
  71. }
  72. }
  73. })])]);
  74. }
  75. SubmitBar.props = {
  76. tip: String,
  77. label: String,
  78. price: Number,
  79. tipIcon: String,
  80. loading: Boolean,
  81. disabled: Boolean,
  82. textAlign: String,
  83. buttonText: String,
  84. buttonColor: String,
  85. suffixLabel: String,
  86. safeAreaInsetBottom: {
  87. type: Boolean,
  88. default: true
  89. },
  90. decimalLength: {
  91. type: [Number, String],
  92. default: 2
  93. },
  94. currency: {
  95. type: String,
  96. default: '¥'
  97. },
  98. buttonType: {
  99. type: String,
  100. default: 'danger'
  101. }
  102. };
  103. var _default = createComponent(SubmitBar);
  104. exports.default = _default;