index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var component_1 = require('../common/component');
  4. 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,
  43. price = _a.price,
  44. decimalLength = _a.decimalLength;
  45. var priceStrArr =
  46. typeof price === 'number' &&
  47. (price / 100).toFixed(decimalLength).split('.');
  48. this.setData({
  49. hasPrice: typeof price === 'number',
  50. integerStr: priceStrArr && priceStrArr[0],
  51. decimalStr: decimalLength && priceStrArr ? '.' + priceStrArr[1] : '',
  52. });
  53. },
  54. updateTip: function () {
  55. this.setData({ hasTip: typeof this.data.tip === 'string' });
  56. },
  57. onSubmit: function (event) {
  58. this.$emit('submit', event.detail);
  59. },
  60. },
  61. });