index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var component_1 = require("../common/component");
  4. (0, component_1.VantComponent)({
  5. classes: ['bar-class', 'price-class', 'button-class'],
  6. props: {
  7. tip: {
  8. type: null,
  9. observer: 'updateTip',
  10. },
  11. tipIcon: String,
  12. type: Number,
  13. price: {
  14. type: null,
  15. observer: 'updatePrice',
  16. },
  17. label: String,
  18. loading: Boolean,
  19. disabled: Boolean,
  20. buttonText: String,
  21. currency: {
  22. type: String,
  23. value: '¥',
  24. },
  25. buttonType: {
  26. type: String,
  27. value: 'danger',
  28. },
  29. decimalLength: {
  30. type: Number,
  31. value: 2,
  32. observer: 'updatePrice',
  33. },
  34. suffixLabel: String,
  35. safeAreaInsetBottom: {
  36. type: Boolean,
  37. value: true,
  38. },
  39. },
  40. methods: {
  41. updatePrice: function () {
  42. var _a = this.data, price = _a.price, decimalLength = _a.decimalLength;
  43. var priceStrArr = typeof price === 'number' &&
  44. (price / 100).toFixed(decimalLength).split('.');
  45. this.setData({
  46. hasPrice: typeof price === 'number',
  47. integerStr: priceStrArr && priceStrArr[0],
  48. decimalStr: decimalLength && priceStrArr ? ".".concat(priceStrArr[1]) : '',
  49. });
  50. },
  51. updateTip: function () {
  52. this.setData({ hasTip: typeof this.data.tip === 'string' });
  53. },
  54. onSubmit: function (event) {
  55. this.$emit('submit', event.detail);
  56. },
  57. },
  58. });