储能智慧云小程序
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 useCustomNavbar from '../mixins/using-custom-navbar';
  11. const systemInfo = wx.getSystemInfoSync();
  12. const { prefix } = config;
  13. const name = `${prefix}-fab`;
  14. const baseButtonProps = {
  15. size: 'large',
  16. shape: 'circle',
  17. theme: 'primary',
  18. externalClass: `${prefix}-fab__button`,
  19. };
  20. let Fab = class Fab extends SuperComponent {
  21. constructor() {
  22. super(...arguments);
  23. this.behaviors = [useCustomNavbar];
  24. this.properties = props;
  25. this.externalClasses = [`class`, `${prefix}-class`, `${prefix}-class-button`];
  26. this.data = {
  27. prefix,
  28. classPrefix: name,
  29. buttonData: baseButtonProps,
  30. moveStyle: null,
  31. };
  32. this.observers = {
  33. 'buttonProps.**, icon, text, ariaLabel'() {
  34. var _a;
  35. this.setData({
  36. buttonData: Object.assign(Object.assign(Object.assign(Object.assign({}, baseButtonProps), { shape: this.properties.text ? 'round' : 'circle', icon: this.properties.icon }), this.properties.buttonProps), { content: this.properties.text, ariaLabel: this.properties.ariaLabel }),
  37. }, (_a = this.computedSize) === null || _a === void 0 ? void 0 : _a.bind(this));
  38. },
  39. };
  40. this.methods = {
  41. onTplButtonTap(e) {
  42. this.triggerEvent('click', e);
  43. },
  44. onMove(e) {
  45. const { distanceTop } = this.data;
  46. const { x, y, rect } = e.detail;
  47. const maxX = systemInfo.windowWidth - rect.width;
  48. const maxY = systemInfo.windowHeight - distanceTop - rect.height;
  49. const right = Math.max(0, Math.min(x, maxX));
  50. const bottom = Math.max(0, Math.min(y, maxY));
  51. this.setData({
  52. moveStyle: `right: ${right}px; bottom: ${bottom}px;`,
  53. });
  54. },
  55. computedSize() {
  56. if (!this.properties.draggable)
  57. return;
  58. const insChild = this.selectComponent('#draggable');
  59. insChild.computedRect();
  60. },
  61. };
  62. }
  63. };
  64. Fab = __decorate([
  65. wxComponent()
  66. ], Fab);
  67. export default Fab;