index.js 1.3KB

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