avatar.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 avatarProps from './props';
  10. const { prefix } = config;
  11. const name = `${prefix}-avatar`;
  12. let Avatar = class Avatar extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.options = {
  16. multipleSlots: true,
  17. };
  18. this.externalClasses = [
  19. `${prefix}-class`,
  20. `${prefix}-class-image`,
  21. `${prefix}-class-icon`,
  22. `${prefix}-class-alt`,
  23. `${prefix}-class-content`,
  24. ];
  25. this.properties = avatarProps;
  26. this.data = {
  27. prefix,
  28. classPrefix: name,
  29. isShow: true,
  30. zIndex: 0,
  31. isChild: false,
  32. borderSize: '',
  33. };
  34. this.relations = {
  35. './avatar-group': {
  36. type: 'ancestor',
  37. linked(target) {
  38. this.parent = target;
  39. },
  40. },
  41. };
  42. this.methods = {
  43. updateIsChild(isChild) {
  44. this.setData({
  45. isChild,
  46. });
  47. },
  48. updateShow() {
  49. this.setData({
  50. isShow: false,
  51. });
  52. },
  53. updateSize(size) {
  54. if (this.properties.size)
  55. return;
  56. this.setData({ size });
  57. },
  58. updateCascading(zIndex) {
  59. this.setData({ zIndex });
  60. },
  61. updateBorder(borderSize) {
  62. this.setData({ borderSize });
  63. },
  64. };
  65. }
  66. onLoadError(e) {
  67. if (this.properties.hideOnLoadFailed) {
  68. this.setData({
  69. isShow: false,
  70. });
  71. }
  72. this.triggerEvent('error', e.detail);
  73. }
  74. };
  75. Avatar = __decorate([
  76. wxComponent()
  77. ], Avatar);
  78. export default Avatar;