step-item.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. sequence: 'positive',
  40. };
  41. this.observers = {
  42. status(value) {
  43. const { curStatus } = this.data;
  44. if (curStatus === '' || value === curStatus)
  45. return;
  46. this.setData({ curStatus: value });
  47. },
  48. };
  49. this.methods = {
  50. updateStatus({ current, currentStatus, index, theme, layout, items, sequence }) {
  51. let curStatus = this.data.status;
  52. if (curStatus === 'default') {
  53. if (index < Number(current)) {
  54. curStatus = 'finish';
  55. }
  56. else if (index === Number(current)) {
  57. curStatus = currentStatus;
  58. }
  59. }
  60. this.setData({
  61. curStatus,
  62. index,
  63. isDot: theme === 'dot',
  64. layout,
  65. theme,
  66. sequence,
  67. isLastChild: index === (sequence === 'positive' ? items.length - 1 : 0),
  68. });
  69. },
  70. onTap() {
  71. this.$parent.handleClick(this.data.index);
  72. },
  73. };
  74. }
  75. };
  76. StepItem = __decorate([
  77. wxComponent()
  78. ], StepItem);
  79. export default StepItem;