合伙人运营小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 { canIUseFormFieldButton } from '../common/version';
  11. import { setIcon } from '../common/utils';
  12. const { prefix } = config;
  13. const name = `${prefix}-button`;
  14. let Button = class Button extends SuperComponent {
  15. constructor() {
  16. super(...arguments);
  17. this.externalClasses = [`${prefix}-class`, `${prefix}-class-icon`, `${prefix}-class-loading`];
  18. this.behaviors = canIUseFormFieldButton() ? ['wx://form-field-button'] : [];
  19. this.properties = props;
  20. this.options = {
  21. multipleSlots: true,
  22. };
  23. this.data = {
  24. prefix,
  25. className: '',
  26. classPrefix: name,
  27. };
  28. this.observers = {
  29. 'theme, size, plain, block, shape, disabled, loading, variant'() {
  30. this.setClass();
  31. },
  32. icon(icon) {
  33. const obj = setIcon('icon', icon, '');
  34. this.setData(Object.assign({}, obj));
  35. },
  36. };
  37. this.lifetimes = {
  38. attached() {
  39. this.setClass();
  40. },
  41. };
  42. this.methods = {
  43. setClass() {
  44. const classList = [
  45. name,
  46. `${prefix}-class`,
  47. `${name}--${this.data.variant || 'base'}`,
  48. `${name}--${this.data.theme || 'default'}`,
  49. `${name}--${this.data.shape || 'rectangle'}`,
  50. `${name}--size-${this.data.size || 'medium'}`,
  51. ];
  52. if (this.data.block) {
  53. classList.push(`${name}--block`);
  54. }
  55. if (this.data.disabled) {
  56. classList.push(`${name}--disabled`);
  57. }
  58. if (this.data.ghost) {
  59. classList.push(`${name}--ghost`);
  60. }
  61. this.setData({
  62. className: classList.join(' '),
  63. });
  64. },
  65. getuserinfo(e) {
  66. this.triggerEvent('getuserinfo', e.detail);
  67. },
  68. contact(e) {
  69. this.triggerEvent('contact', e.detail);
  70. },
  71. getphonenumber(e) {
  72. this.triggerEvent('getphonenumber', e.detail);
  73. },
  74. error(e) {
  75. this.triggerEvent('error', e.detail);
  76. },
  77. opensetting(e) {
  78. this.triggerEvent('opensetting', e.detail);
  79. },
  80. launchapp(e) {
  81. this.triggerEvent('launchapp', e.detail);
  82. },
  83. chooseavatar(e) {
  84. this.triggerEvent('chooseavatar', e.detail);
  85. },
  86. agreeprivacyauthorization(e) {
  87. this.triggerEvent('agreeprivacyauthorization', e.detail);
  88. },
  89. handleTap(e) {
  90. if (this.data.disabled || this.data.loading)
  91. return;
  92. this.triggerEvent('tap', e);
  93. },
  94. };
  95. }
  96. };
  97. Button = __decorate([
  98. wxComponent()
  99. ], Button);
  100. export default Button;