dialog.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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}-dialog`;
  12. let Dialog = class Dialog extends SuperComponent {
  13. constructor() {
  14. super(...arguments);
  15. this.options = {
  16. multipleSlots: true,
  17. addGlobalClass: true,
  18. };
  19. this.externalClasses = [
  20. `${prefix}-class`,
  21. `${prefix}-class-content`,
  22. `${prefix}-class-confirm`,
  23. `${prefix}-class-cancel`,
  24. `${prefix}-class-action`,
  25. ];
  26. this.properties = props;
  27. this.data = {
  28. prefix,
  29. classPrefix: name,
  30. };
  31. this.methods = {
  32. onTplButtonTap(e) {
  33. const evtType = e.type;
  34. const { type } = e.target.dataset;
  35. if (`bind${evtType}` in this.data[`${type}Btn`]) {
  36. this.data[`${type}Btn`][`bind${evtType}`](e.detail);
  37. }
  38. },
  39. onConfirm() {
  40. this.triggerEvent('confirm');
  41. if (this._onComfirm) {
  42. this._onComfirm();
  43. this.close();
  44. }
  45. },
  46. onCancel() {
  47. this.triggerEvent('close', { trigger: 'cancel' });
  48. this.triggerEvent('cancel');
  49. if (this._onCancel) {
  50. this._onCancel();
  51. this.close();
  52. }
  53. },
  54. close() {
  55. this.setData({ visible: false });
  56. },
  57. overlayClick() {
  58. if (this.properties.closeOnOverlayClick) {
  59. this.triggerEvent('close', { trigger: 'overlay' });
  60. }
  61. this.triggerEvent('overlayClick');
  62. },
  63. onActionTap(e) {
  64. const { index } = e.currentTarget.dataset;
  65. this.triggerEvent('action', { index });
  66. if (this._onAction) {
  67. this._onAction({ index });
  68. this.close();
  69. }
  70. },
  71. openValueCBHandle(e) {
  72. this.triggerEvent('open-type-event', e.detail);
  73. },
  74. openValueErrCBHandle(e) {
  75. this.triggerEvent('open-type-error-event', e.detail);
  76. },
  77. };
  78. }
  79. };
  80. Dialog = __decorate([
  81. wxComponent()
  82. ], Dialog);
  83. export default Dialog;
  84. //# sourceMappingURL=dialog.js.map