step-item.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  2. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  3. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  4. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  5. return c > 3 && r && Object.defineProperty(target, key, r), r;
  6. };
  7. import { wxComponent, SuperComponent } from '../common/src/index';
  8. import config from '../common/config';
  9. import props from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-steps-item`;
  12. let StepItem = class StepItem extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.options = {
  16. multipleSlots: true,
  17. };
  18. this.relations = {
  19. '../steps/steps': {
  20. type: 'parent',
  21. },
  22. };
  23. this.externalClasses = [
  24. `${prefix}-class`,
  25. `${prefix}-class-content`,
  26. `${prefix}-class-title`,
  27. `${prefix}-class-description`,
  28. `${prefix}-class-extra`,
  29. ];
  30. this.properties = props;
  31. this.data = {
  32. classPrefix: name,
  33. prefix,
  34. index: 0,
  35. isDot: false,
  36. curStatus: '',
  37. layout: 'vertical',
  38. isLastChild: false,
  39. };
  40. this.methods = {
  41. updateStatus(current, currentStatus, index, theme, layout, steps) {
  42. let curStatus = this.data.status;
  43. if (curStatus === 'default') {
  44. if (index < Number(current)) {
  45. curStatus = 'finish';
  46. }
  47. else if (index === Number(current)) {
  48. curStatus = currentStatus;
  49. }
  50. }
  51. this.setData({
  52. curStatus,
  53. index,
  54. isDot: theme === 'dot',
  55. layout,
  56. theme,
  57. isLastChild: steps.length - 1 === index,
  58. });
  59. },
  60. onTap() {
  61. this.$parent.handleClick(this.data.index);
  62. },
  63. };
  64. }
  65. };
  66. StepItem = __decorate([
  67. wxComponent()
  68. ], StepItem);
  69. export default StepItem;