index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import { __awaiter, __generator } from "tslib";
  2. import { GuideTourDefaultProps } from './props';
  3. import mixinValue from '../mixins/value';
  4. import '../_util/assert-component2';
  5. Component({
  6. mixins: [
  7. mixinValue({
  8. valueKey: 'current',
  9. defaultValueKey: 'defaultCurrent',
  10. }),
  11. ],
  12. props: GuideTourDefaultProps,
  13. methods: {
  14. onNext: function () {
  15. return __awaiter(this, void 0, void 0, function () {
  16. var currentValue, onChange, newCurrent;
  17. return __generator(this, function (_a) {
  18. currentValue = this.getValue();
  19. onChange = this.props.onChange;
  20. newCurrent = currentValue + 1;
  21. if (!this.isControlled()) {
  22. this.update(newCurrent);
  23. }
  24. if (onChange) {
  25. onChange(newCurrent);
  26. }
  27. return [2 /*return*/];
  28. });
  29. });
  30. },
  31. onPrev: function () {
  32. return __awaiter(this, void 0, void 0, function () {
  33. var currentValue, onChange, newCurrent;
  34. return __generator(this, function (_a) {
  35. currentValue = this.getValue();
  36. onChange = this.props.onChange;
  37. newCurrent = currentValue - 1;
  38. if (!this.isControlled()) {
  39. this.update(newCurrent);
  40. }
  41. if (onChange) {
  42. onChange(newCurrent);
  43. }
  44. return [2 /*return*/];
  45. });
  46. });
  47. },
  48. onCancel: function () {
  49. var onCancel = this.props.onCancel;
  50. if (onCancel) {
  51. onCancel();
  52. }
  53. },
  54. onSwiperChange: function (e) {
  55. return __awaiter(this, void 0, void 0, function () {
  56. var current, onChange;
  57. return __generator(this, function (_a) {
  58. current = e.detail.current;
  59. onChange = this.props.onChange;
  60. if (!this.isControlled()) {
  61. this.update(current);
  62. }
  63. if (onChange) {
  64. onChange(current);
  65. }
  66. return [2 /*return*/];
  67. });
  68. });
  69. },
  70. },
  71. });