SkuActions.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. // Utils
  3. import { createNamespace } from '../../utils';
  4. import { inherit } from '../../utils/functional'; // Components
  5. import Button from '../../button'; // Types
  6. var _createNamespace = createNamespace('sku-actions'),
  7. createComponent = _createNamespace[0],
  8. bem = _createNamespace[1],
  9. t = _createNamespace[2];
  10. function SkuActions(h, props, slots, ctx) {
  11. var createEmitter = function createEmitter(name) {
  12. return function () {
  13. props.skuEventBus.$emit(name);
  14. };
  15. };
  16. return h("div", _mergeJSXProps([{
  17. "class": bem()
  18. }, inherit(ctx)]), [props.showAddCartBtn && h(Button, {
  19. "attrs": {
  20. "size": "large",
  21. "type": "warning",
  22. "text": props.addCartText || t('addCart')
  23. },
  24. "on": {
  25. "click": createEmitter('sku:addCart')
  26. }
  27. }), h(Button, {
  28. "attrs": {
  29. "size": "large",
  30. "type": "danger",
  31. "text": props.buyText || t('buy')
  32. },
  33. "on": {
  34. "click": createEmitter('sku:buy')
  35. }
  36. })]);
  37. }
  38. SkuActions.props = {
  39. buyText: String,
  40. addCartText: String,
  41. skuEventBus: Object,
  42. showAddCartBtn: Boolean
  43. };
  44. export default createComponent(SkuActions);