cell.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 { SuperComponent, wxComponent } from '../common/src/index';
  8. import config from '../common/config';
  9. import props from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-cell`;
  12. let Cell = class Cell extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.externalClasses = [
  16. `${prefix}-class`,
  17. `${prefix}-class-title`,
  18. `${prefix}-class-description`,
  19. `${prefix}-class-note`,
  20. `${prefix}-class-hover`,
  21. `${prefix}-class-image`,
  22. `${prefix}-class-left`,
  23. `${prefix}-class-left-icon`,
  24. `${prefix}-class-right`,
  25. `${prefix}-class-right-icon`,
  26. ];
  27. this.relations = {
  28. '../cell-group/cell-group': {
  29. type: 'parent',
  30. },
  31. };
  32. this.options = {
  33. multipleSlots: true,
  34. };
  35. this.properties = props;
  36. this.data = {
  37. prefix,
  38. classPrefix: name,
  39. isLastChild: false,
  40. };
  41. }
  42. onClick(e) {
  43. this.triggerEvent('click', e.detail);
  44. this.jumpLink();
  45. }
  46. jumpLink(urlKey = 'url', link = 'jumpType') {
  47. const url = this.data[urlKey];
  48. const jumpType = this.data[link];
  49. if (url) {
  50. wx[jumpType]({ url });
  51. }
  52. }
  53. };
  54. Cell = __decorate([
  55. wxComponent()
  56. ], Cell);
  57. export default Cell;