index.js 1.3 KB

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