index.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. "use strict";
  2. var _component = require("../common/component");
  3. (0, _component.VantComponent)({
  4. classes: ["bar-class", "price-class", "button-class"],
  5. props: {
  6. tip: {
  7. type: null,
  8. observer: "updateTip"
  9. },
  10. tipIcon: String,
  11. type: Number,
  12. price: {
  13. type: null,
  14. observer: "updatePrice"
  15. },
  16. label: String,
  17. loading: Boolean,
  18. disabled: Boolean,
  19. buttonText: String,
  20. currency: {
  21. type: String,
  22. value: "¥"
  23. },
  24. buttonType: {
  25. type: String,
  26. value: "danger"
  27. },
  28. decimalLength: {
  29. type: Number,
  30. value: 2,
  31. observer: "updatePrice"
  32. },
  33. suffixLabel: String,
  34. safeAreaInsetBottom: {
  35. type: Boolean,
  36. value: true
  37. }
  38. },
  39. methods: {
  40. updatePrice: function updatePrice() {
  41. var _this$data = this.data,
  42. price = _this$data.price,
  43. decimalLength = _this$data.decimalLength;
  44. var priceStrArr = typeof price === "number" && (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 updateTip() {
  52. this.setData({
  53. hasTip: typeof this.data.tip === "string"
  54. });
  55. },
  56. onSubmit: function onSubmit(event) {
  57. this.$emit("submit", event.detail);
  58. }
  59. }
  60. });