运维小程序
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

cell.js 2.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. import { calcIcon } from '../common/utils';
  11. const { prefix } = config;
  12. const name = `${prefix}-cell`;
  13. let Cell = class Cell extends SuperComponent {
  14. constructor() {
  15. super(...arguments);
  16. this.externalClasses = [
  17. `${prefix}-class`,
  18. `${prefix}-class-title`,
  19. `${prefix}-class-description`,
  20. `${prefix}-class-note`,
  21. `${prefix}-class-hover`,
  22. `${prefix}-class-image`,
  23. `${prefix}-class-left`,
  24. `${prefix}-class-left-icon`,
  25. `${prefix}-class-center`,
  26. `${prefix}-class-right`,
  27. `${prefix}-class-right-icon`,
  28. ];
  29. this.relations = {
  30. '../cell-group/cell-group': {
  31. type: 'parent',
  32. },
  33. };
  34. this.options = {
  35. multipleSlots: true,
  36. };
  37. this.properties = props;
  38. this.data = {
  39. prefix,
  40. classPrefix: name,
  41. isLastChild: false,
  42. };
  43. this.observers = {
  44. leftIcon(v) {
  45. this.setIcon('_leftIcon', v, '');
  46. },
  47. rightIcon(v) {
  48. this.setIcon('_rightIcon', v, '');
  49. },
  50. arrow(v) {
  51. this.setIcon('_arrow', v, 'chevron-right');
  52. },
  53. };
  54. }
  55. setIcon(name, value, defaultValue) {
  56. if (!value)
  57. return;
  58. this.setData({
  59. [name]: calcIcon(value, defaultValue),
  60. });
  61. }
  62. onClick(e) {
  63. this.triggerEvent('click', e.detail);
  64. this.jumpLink();
  65. }
  66. jumpLink(urlKey = 'url', link = 'jumpType') {
  67. const url = this.data[urlKey];
  68. const jumpType = this.data[link];
  69. if (url) {
  70. wx[jumpType]({ url });
  71. }
  72. }
  73. };
  74. Cell = __decorate([
  75. wxComponent()
  76. ], Cell);
  77. export default Cell;