UNPKG

37.3 kBJavaScriptView Raw
1import "core-js/modules/es6.regexp.split";
2import "core-js/modules/es6.object.assign";
3import "core-js/modules/es6.regexp.match";
4import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5import _createClass from "@babel/runtime/helpers/createClass";
6import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
9import _inherits from "@babel/runtime/helpers/inherits";
10
11/* eslint-disable */
12import React, { Component } from 'react';
13import { decode } from '@beisen-platform/common-func';
14import BaseButton from '@beisen-platform/base-button';
15import ArrowDownIcon from '@beisen-platform/react-icons/lib/icons/Arrowdown2Nomal.js';
16import AttentionIcon from '@beisen-platform/react-icons/lib/icons/ZhuyiNomal.js';
17import { computeTargetCenterPosition, genPopStyleIfPosition, computePositionToMakePopCenter, MAX_CONFIRM_HEIGHT } from "./utils";
18import './styles/all.css';
19
20var PopLayer =
21/*#__PURE__*/
22function (_Component) {
23 _inherits(PopLayer, _Component);
24
25 function PopLayer(props) {
26 var _this;
27
28 _classCallCheck(this, PopLayer);
29
30 _this = _possibleConstructorReturn(this, _getPrototypeOf(PopLayer).call(this, props));
31
32 _this.showAllInfo = function () {
33 _this.refs.tipsContent.style.maxHeight = '280px';
34 _this.refs.tipsContent.style.overflowY = 'auto';
35
36 if (_this.refs.tipsContent.scrollHeight > 280) {
37 if (_this.refs.manualClose) {
38 _this.refs.manualClose.className = 'manual-close manual-close-hasShadow';
39 }
40
41 if (_this.refs.hasNoButtonShadowLine) {
42 _this.refs.hasNoButtonShadowLine.className = 'hasNoButtonLine hasNoButtonLine_hasShadow';
43 }
44 }
45
46 if (_this.refs.showAllBtn) {
47 _this.refs.showAllBtn.style.display = 'none';
48 }
49 };
50
51 _this.DetermineChineseCharacterNum = function (str) {
52 var sum = 0;
53 var re = /[\u4E00-\u9FA5]/g; //测试中文字符的正则
54
55 if (str) {
56 if (re.test(str)) {
57 //使用正则判断是否存在中文
58 return str.match(re).length; //返回中文的个数
59 }
60 }
61
62 return 0;
63 };
64
65 _this.renderIcon = function (style, type) {
66 if (style == 'round-pattern') {
67 if (type == 'success') {
68 return React.createElement("div", {
69 className: "round-pattern-tips-icon-border round-pattern-tips-icon-border-success"
70 }, React.createElement("div", {
71 className: "round-pattern-tips-icon"
72 }, React.createElement("div", {
73 className: "successEyesBorder",
74 ref: "eyesBorder"
75 }, React.createElement("div", {
76 className: "successFaceLeftEyes",
77 ref: "successFaceLeftEyes"
78 }), React.createElement("div", {
79 className: "successFaceRightEyes",
80 ref: "successFaceRightEyes"
81 })), React.createElement("div", {
82 className: "successFaceMouse",
83 ref: "mouseActive"
84 }, React.createElement("div", {
85 className: "successMouseFadeOut fadeOut-top",
86 ref: "fadeOutTop"
87 }))));
88 } else if (type == 'error') {
89 return React.createElement("div", {
90 className: "round-pattern-tips-icon-border round-pattern-tips-icon-border-error"
91 }, React.createElement("div", {
92 className: "round-pattern-tips-icon",
93 ref: "roundPatternTipsIcon"
94 }, React.createElement("div", {
95 className: "errorEyesBorder",
96 ref: "eyesBorder"
97 }, React.createElement("div", {
98 className: "errorFaceLeftEyes",
99 ref: "errorFaceLeftEyes"
100 }), React.createElement("div", {
101 className: "errorFaceRightEyes",
102 ref: "errorFaceRightEyes"
103 })), React.createElement("div", {
104 className: "errorFaceMouse",
105 ref: "mouseActive"
106 }, React.createElement("div", {
107 className: "errorMouseFadeOut fadeOut-bottom",
108 ref: "fadeOutBottom"
109 }))));
110 } else if (type == 'warning') {
111 return React.createElement("div", {
112 className: "round-pattern-tips-icon-border round-pattern-tips-icon-border-warning"
113 }, React.createElement("div", {
114 className: "round-pattern-tips-icon",
115 ref: "roundPatternTipsIcon"
116 }, React.createElement("div", {
117 className: "warningEyesBorder",
118 ref: "eyesBorder"
119 }, React.createElement("div", {
120 className: "warningFaceLeftEyes",
121 ref: "warningFaceLeftEyes"
122 }), React.createElement("div", {
123 className: "warningFaceRightEyes",
124 ref: "warningFaceRightEyes"
125 })), React.createElement("div", {
126 className: "warningFaceMouse",
127 ref: "mouseActive"
128 })));
129 } else if (type == 'remind') {
130 return React.createElement("div", {
131 className: "round-pattern-tips-icon-border round-pattern-tips-icon-border-remind"
132 }, React.createElement("div", {
133 className: "round-pattern-tips-icon"
134 }, React.createElement("div", {
135 className: "remindEyesBorder",
136 ref: "eyesBorder"
137 }, React.createElement("div", {
138 className: "remindFaceLeftEyes",
139 ref: "remindFaceLeftEyes"
140 }), React.createElement("div", {
141 className: "remindFaceRightEyes",
142 ref: "remindFaceRightEyes"
143 })), React.createElement("div", {
144 className: "remindFaceMouse",
145 ref: "mouseActive"
146 }, React.createElement("div", {
147 className: "remindMouseFadeOut fadeOut-top",
148 ref: "fadeOutTop"
149 }))));
150 }
151 } else {
152 if (type == 'success') {
153 return React.createElement("div", {
154 className: "tips-icon-border tips-icon-border-success"
155 }, React.createElement("div", {
156 className: "tips-icon"
157 }, React.createElement("div", {
158 className: "successEyesBorder",
159 ref: "eyesBorder"
160 }, React.createElement("div", {
161 className: "successFaceLeftEyes",
162 ref: "successFaceLeftEyes"
163 }), React.createElement("div", {
164 className: "successFaceRightEyes",
165 ref: "successFaceRightEyes"
166 })), React.createElement("div", {
167 className: "successFaceMouse",
168 ref: "mouseActive"
169 }, React.createElement("div", {
170 className: "successMouseFadeOut fadeOut-top",
171 ref: "fadeOutTop"
172 }))));
173 } else if (type == 'error') {
174 return React.createElement("div", {
175 className: "tips-icon-border tips-icon-border-error"
176 }, React.createElement("div", {
177 className: "tips-icon",
178 ref: "roundPatternTipsIcon"
179 }, React.createElement("div", {
180 className: "errorEyesBorder",
181 ref: "eyesBorder"
182 }, React.createElement("div", {
183 className: "errorFaceLeftEyes",
184 ref: "errorFaceLeftEyes"
185 }), React.createElement("div", {
186 className: "errorFaceRightEyes",
187 ref: "errorFaceRightEyes"
188 })), React.createElement("div", {
189 className: "errorFaceMouse",
190 ref: "mouseActive"
191 }, React.createElement("div", {
192 className: "errorMouseFadeOut fadeOut-bottom",
193 ref: "fadeOutBottom"
194 }))));
195 } else if (type == 'warning') {
196 return React.createElement("div", {
197 className: "tips-icon-border tips-icon-border-warning"
198 }, React.createElement("div", {
199 className: "tips-icon",
200 ref: "roundPatternTipsIcon"
201 }, React.createElement("div", {
202 className: "warningEyesBorder",
203 ref: "eyesBorder"
204 }, React.createElement("div", {
205 className: "warningFaceLeftEyes",
206 ref: "warningFaceLeftEyes"
207 }), React.createElement("div", {
208 className: "warningFaceRightEyes",
209 ref: "warningFaceRightEyes"
210 })), React.createElement("div", {
211 className: "warningFaceMouse",
212 ref: "mouseActive"
213 })));
214 } else if (type == 'remind') {
215 return React.createElement("div", {
216 className: "tips-icon-border tips-icon-border-remind"
217 }, React.createElement("div", {
218 className: "tips-icon"
219 }, React.createElement("div", {
220 className: "remindEyesBorder",
221 ref: "eyesBorder"
222 }, React.createElement("div", {
223 className: "remindFaceLeftEyes",
224 ref: "remindFaceLeftEyes"
225 }), React.createElement("div", {
226 className: "remindFaceRightEyes",
227 ref: "remindFaceRightEyes"
228 })), React.createElement("div", {
229 className: "remindFaceMouse",
230 ref: "mouseActive"
231 }, React.createElement("div", {
232 className: "remindMouseFadeOut fadeOut-top",
233 ref: "fadeOutTop"
234 }))));
235 }
236 }
237 };
238
239 _this.showFaceActive = function (type) {
240 if (type == 'success') {
241 setTimeout(function () {
242 var mouseActive = _this.refs.mouseActive;
243
244 if (mouseActive) {
245 mouseActive.className = mouseActive.className + ' successMouseMove';
246 }
247
248 setTimeout(function () {
249 var eyesDom = _this.refs.eyesBorder;
250
251 if (eyesDom) {
252 eyesDom.className = eyesDom.className + ' successEyesMove';
253 }
254 }, 300);
255 }, 1000);
256 } else if (type == 'error') {
257 setTimeout(function () {
258 var fadeOutBottom = _this.refs.fadeOutBottom;
259 var eyesDom = _this.refs.eyesBorder;
260
261 if (fadeOutBottom && eyesDom) {
262 fadeOutBottom.className = fadeOutBottom.className + ' fadeOutMove';
263 eyesDom.className = eyesDom.className + ' errorEyesMove';
264 }
265
266 setTimeout(function () {
267 var icon = _this.refs.roundPatternTipsIcon;
268
269 if (icon) {
270 icon.className = icon.className + ' iconshake';
271 }
272 }, 0);
273 }, 1000);
274 } else if (type == 'warning') {
275 setTimeout(function () {
276 var eyesDom = _this.refs.eyesBorder;
277
278 if (eyesDom) {
279 var timeTag = 0;
280 _this.warningTimeOut = setInterval(function () {
281 timeTag++;
282
283 if (timeTag > 0 && timeTag < 50) {
284 _this.refs.warningFaceLeftEyes.style.left = '2px';
285 _this.refs.warningFaceRightEyes.style.left = '9px';
286 } else {
287 _this.refs.warningFaceLeftEyes.style.left = '1px';
288 _this.refs.warningFaceRightEyes.style.left = '10px';
289 }
290
291 setTimeout(function () {
292 clearInterval(_this.warningTimeOut);
293 }, 600);
294 }, 10);
295 }
296
297 setTimeout(function () {
298 var icon = _this.refs.roundPatternTipsIcon;
299
300 if (icon) {
301 icon.className = icon.className + ' iconshake';
302 }
303 }, 0);
304 }, 1000);
305 } else if (type == 'remind') {
306 setTimeout(function () {
307 React.createElement("div", {
308 className: "remindMouseFadeOut fadeOut-top",
309 ref: "fadeOutTop"
310 });
311 var fadeOutTop = _this.refs.fadeOutTop;
312
313 if (fadeOutTop) {
314 fadeOutTop.className = fadeOutTop.className + ' fadeOutMove';
315 }
316
317 setTimeout(function () {
318 var eyesDom = _this.refs.eyesBorder;
319
320 if (eyesDom) {
321 eyesDom.className = eyesDom.className + ' warningEyesMove';
322 }
323 }, 400);
324 }, 1000);
325 }
326 };
327
328 _this.setCenterPosition = function () {
329 if (_this.refs.popDirection) {
330 if (_this.props.target) {
331 var _computePositionToMak = computePositionToMakePopCenter(_this.refs.popDirection, _this.props.target),
332 top = _computePositionToMak.top,
333 left = _computePositionToMak.left,
334 marginTop = _computePositionToMak.marginTop,
335 marginLeft = _computePositionToMak.marginLeft;
336
337 _this.refs.popDirection.style.top = top;
338 _this.refs.popDirection.style.left = left;
339 _this.refs.popDirection.style.marginTop = "".concat(marginTop, "px");
340 _this.refs.popDirection.style.marginLeft = "".concat(marginLeft, "px");
341 } else {
342 console.warn('当布局方式为居中时,相对居中对象target是必需的');
343 }
344 }
345 };
346
347 _this.createMask = function (hidden) {
348 var dom = document.getElementsByClassName('pop-layer_is-show')[0];
349
350 if (!hidden && !dom && _this.props.showMask) {
351 _this.container = document.body;
352 _this.wrapper = document.createElement('div');
353 _this.wrapper.className = 'pop-layer_is-show';
354
355 _this.container.appendChild(_this.wrapper);
356 }
357 };
358
359 _this.removeMask = function () {
360 var dom = document.getElementsByClassName('pop-layer_is-show')[0];
361 if (dom) document.body.removeChild(dom);
362 };
363
364 var disappearTime = _this.props.disappearTime ? _this.props.disappearTime : '3000';
365 _this.clickClose = _this.clickClose.bind(_assertThisInitialized(_this));
366 _this.moveTips = _this.moveTips.bind(_assertThisInitialized(_this));
367 var disTime = disappearTime;
368 var infoType = _this.props.infoType ? _this.props.infoType : '0';
369 var infoColor, iconName, title, roundInfoColor, roundIconName, roundCloseIconName, promptMessageType;
370 var showStateDuring = false;
371
372 switch (infoType) {
373 case '0':
374 promptMessageType = 'success';
375 infoColor = ' color-zero';
376 iconName = ' successFace-tip-icon';
377 roundInfoColor = ' color-zero';
378 roundIconName = ' successFace-tip-icon';
379 roundCloseIconName = ' successClose';
380 title = _this.props.title ? _this.props.title : '正确!';
381 break;
382
383 case '1':
384 promptMessageType = 'error';
385 infoColor = ' color-one';
386 iconName = ' errorFace-tip-icon';
387 roundInfoColor = ' color-one';
388 roundIconName = ' errorFace-tip-icon';
389 roundCloseIconName = ' errorClose';
390 title = _this.props.title ? _this.props.title : '错误!';
391 break;
392
393 case '2':
394 promptMessageType = 'warning';
395 infoColor = ' color-two';
396 iconName = ' warningFace-tip-icon';
397 roundInfoColor = ' color-two';
398 roundIconName = ' warningFace-tip-icon';
399 roundCloseIconName = ' warningClose';
400 title = _this.props.title ? _this.props.title : '注意!';
401 break;
402
403 case '3':
404 promptMessageType = 'remind';
405 infoColor = ' color-three';
406 iconName = ' remindFace-tip-icon';
407 roundInfoColor = ' color-three';
408 roundIconName = ' remindFace-tip-icon';
409 roundCloseIconName = ' remindClose';
410 title = _this.props.title ? _this.props.title : '问号!';
411 break;
412
413 case '4':
414 promptMessageType = 'info';
415 infoColor = ' color-four';
416 iconName = ' infoFace-tip-icon';
417 roundInfoColor = ' color-four';
418 roundIconName = ' infoFace-tip-icon';
419 roundCloseIconName = ' infoClose';
420 title = _this.props.title ? _this.props.title : '信息!';
421 break;
422
423 case '5':
424 promptMessageType = 'caution';
425 infoColor = ' color-five';
426 iconName = ' cautionFace-tip-icon';
427 roundInfoColor = ' color-five';
428 roundIconName = ' cautionFace-tip-icon';
429 roundCloseIconName = ' cautionClose';
430 title = _this.props.title ? _this.props.title : '提示!';
431 break;
432
433 default:
434 return _possibleConstructorReturn(_this);
435 }
436
437 var sureButton = {
438 bsStyle: 'default',
439 bsSize: 'small',
440 active: true,
441 title: _this.props.sureButtonContent ? _this.props.sureButtonContent : '确定',
442 onClick: _this.sureClick.bind(_assertThisInitialized(_this))
443 };
444 var cancelButton = {
445 bsStyle: 'weaken',
446 bsSize: 'small',
447 active: true,
448 title: _this.props.cancleButtonContent ? _this.props.cancleButtonContent : '取消',
449 onClick: _this.closeClick.bind(_assertThisInitialized(_this))
450 };
451 var autoDirection;
452
453 if (_this.props.autoDirection == undefined) {
454 autoDirection = true;
455 } else {
456 autoDirection = _this.props.autoDirection;
457 }
458
459 var setPosition = true;
460
461 if (_this.props.top === undefined && _this.props.left === undefined && _this.props.right === undefined && _this.props.bottom === undefined) {
462 setPosition = false;
463 }
464
465 var defualt = {
466 popType: _this.props.popType ? _this.props.popType : '0',
467 infoType: infoType,
468 infoColor: infoColor,
469 iconName: iconName,
470 roundInfoColor: roundInfoColor,
471 roundIconName: roundIconName,
472 roundCloseIconName: roundCloseIconName,
473 showMask: false,
474 manualClose: _this.props.manualClose ? _this.props.manualClose : false,
475 disappearTime: disappearTime,
476 disTime: disTime,
477 promptMessageType: promptMessageType,
478 title: _this.props.title ? _this.props.title : '提示!',
479 content: _this.props.content ? _this.props.content : [],
480 popShow: false,
481 moveTips: false,
482 moveRountTips: false,
483 moveConform: false,
484 sureButton: sureButton,
485 cancelButton: cancelButton,
486 autoDirection: autoDirection,
487 direction: _this.props.direction ? _this.props.direction : 'left-down',
488 target: _this.props.target ? _this.props.target : '',
489 listViewDirection: _this.props.autoDirection ? 'left-down' : _this.props.direction,
490 left: _this.props.left ? _this.props.left : 0,
491 right: _this.props.right ? _this.props.right : 0,
492 top: _this.props.top ? _this.props.top : 0,
493 bottom: _this.props.bottom ? _this.props.bottom : 0,
494 setPosition: setPosition,
495 count: 0
496 };
497 _this.state = Object.assign({}, defualt, props);
498 _this.popClose = _this.popClose.bind(_assertThisInitialized(_this));
499 return _this;
500 }
501 /*
502 确定回调
503 */
504
505
506 _createClass(PopLayer, [{
507 key: "sureClick",
508 value: function sureClick(val) {
509 val.stopPropagation();
510 this.props.onSure && this.props.onSure(val);
511 this.popClose(true);
512 }
513 /*
514 取消回调
515 */
516
517 }, {
518 key: "closeClick",
519 value: function closeClick(val) {
520 val.stopPropagation();
521 this.props.onClose && this.props.onClose(val);
522 this.popClose(true);
523 }
524 }, {
525 key: "popClose",
526 value: function popClose(flag, e) {
527 var self = this;
528
529 if (e && e.stopPropagation) {
530 e && e.stopPropagation();
531 }
532
533 this.setState({
534 popShow: false
535 });
536 this.removeMask();
537 setTimeout(function () {
538 self.props.showHide && self.props.showHide(flag, e);
539 }, 300);
540 }
541 }, {
542 key: "componentWillMount",
543 value: function componentWillMount(props) {
544 if (!this.props.hidden) {
545 document.removeEventListener('mousedown', this.moveTips);
546 this.setState({
547 popShow: true
548 });
549 }
550 }
551 }, {
552 key: "componentWillUnmount",
553 value: function componentWillUnmount() {
554 this.removeMask();
555 document.removeEventListener('mousedown', this.moveTips);
556 document.removeEventListener('mousedown', this.clickClose);
557 }
558 }, {
559 key: "componentWillReceiveProps",
560 value: function componentWillReceiveProps(nextProps) {
561 var self = this;
562 var _this$state = this.state,
563 autoDirection = _this$state.autoDirection,
564 direction = _this$state.direction;
565
566 if (this.props.title == nextProps.title && this.props.cancleButtonContent == nextProps.cancleButtonContent && this.props.hidden == nextProps.hidden && this.props.direction == nextProps.direction && this.props.disappearTime == nextProps.disappearTime && this.props.infoType == nextProps.infoType && this.props.left == nextProps.left && this.props.manualClose == nextProps.manualClose && this.props.popType == nextProps.popType && this.props.sureButtonContent == nextProps.sureButtonContent && this.props.target == nextProps.target && this.props.title == nextProps.title && this.props.top == nextProps.top && this.props.bottom == nextProps.bottom && this.props.right == nextProps.right) {
567 this.showStateDuring = false;
568 } else {
569 this.showStateDuring = true;
570 }
571
572 if (!nextProps.hidden && !this.showStateDuring) {
573 this.setState({
574 popShow: true
575 });
576 this.createMask(nextProps.hidden);
577
578 if (self.state.popType === '1') {
579 self.setState({
580 target: nextProps.target ? nextProps.target : ''
581 });
582
583 if (nextProps.target && self.refs.popDirection) {
584 var newTarget = nextProps.target;
585 var popTarget = self.refs.popDirection.getBoundingClientRect();
586 var length = popTarget.height;
587 var winHeight = window.innerHeight;
588 var winWidth = window.innerWidth;
589 var horizontal = winWidth / 2 > newTarget.left ? 'right' : 'left';
590 var vertical = winHeight / 2 > newTarget.top ? winHeight - newTarget.top > length ? '-down' : '-top' : winHeight - newTarget.top > length ? '-down' : '-top';
591 this.state.listViewDirection = autoDirection ? horizontal + vertical : direction;
592 this.setState(this.state);
593 }
594 }
595 }
596
597 if (nextProps.content != this.props.content) {
598 this.setState({
599 content: nextProps.content
600 });
601 }
602 }
603 }, {
604 key: "shouldComponentUpdate",
605 value: function shouldComponentUpdate(nextProps) {
606 this.state.count++;
607
608 if (this.props.popType === '0' && this.props.manualClose === false && this.state.count !== 1) {
609 var res = true;
610
611 if (this.props.cancleButtonContent == nextProps.cancleButtonContent && this.props.hidden == nextProps.hidden && this.props.direction == nextProps.direction && this.props.disappearTime == nextProps.disappearTime && this.props.infoType == nextProps.infoType && this.props.left == nextProps.left && this.props.manualClose == nextProps.manualClose && this.props.popType == nextProps.popType && this.props.sureButtonContent == nextProps.sureButtonContent && this.props.target == nextProps.target && this.props.title == nextProps.title && this.props.top == nextProps.top && this.props.bottom == nextProps.bottom && this.props.right == nextProps.right) {
612 res = false;
613 }
614
615 return res;
616 } else {
617 return true;
618 }
619 }
620 }, {
621 key: "render",
622 value: function render() {
623 var _this$state2 = this.state,
624 popType = _this$state2.popType,
625 infoColor = _this$state2.infoColor,
626 iconName = _this$state2.iconName,
627 manualClose = _this$state2.manualClose,
628 title = _this$state2.title,
629 content = _this$state2.content,
630 sureButton = _this$state2.sureButton,
631 cancelButton = _this$state2.cancelButton,
632 listViewDirection = _this$state2.listViewDirection,
633 left = _this$state2.left,
634 top = _this$state2.top,
635 setPosition = _this$state2.setPosition,
636 moveTips = _this$state2.moveTips,
637 moveRountTips = _this$state2.moveRountTips,
638 bottom = _this$state2.bottom,
639 right = _this$state2.right,
640 roundIconName = _this$state2.roundIconName,
641 roundInfoColor = _this$state2.roundInfoColor,
642 roundCloseIconName = _this$state2.roundCloseIconName,
643 promptMessageType = _this$state2.promptMessageType;
644 var _this$props = this.props,
645 hidden = _this$props.hidden,
646 maxHeight = _this$props.maxHeight,
647 removeSubBtn = _this$props.removeSubBtn,
648 direction = _this$props.direction,
649 target = _this$props.target;
650 var manualClosePart;
651 var manualCloseForRoundPatter;
652
653 if (!manualClose) {
654 manualClosePart = React.createElement("div", {
655 className: "hasNoButtonLine",
656 ref: "hasNoButtonShadowLine"
657 });
658 manualCloseForRoundPatter = '';
659 } else {
660 manualClosePart = React.createElement("div", {
661 className: 'manual-close',
662 ref: "manualClose"
663 }, React.createElement("div", {
664 className: "manual-close-content",
665 onClick: this.popClose
666 }, React.createElement("span", {
667 className: 'manual-close-word'
668 }, "\u6211\u77E5\u9053\u4E86")));
669 manualCloseForRoundPatter = React.createElement("div", {
670 className: "round-pattern-manual-close"
671 }, React.createElement("div", {
672 className: "round-pattern-divide-line"
673 }), React.createElement("div", {
674 className: 'round-pattern-close-btn' + roundCloseIconName,
675 onClick: this.popClose
676 }));
677 }
678
679 var tipsContent = [];
680 var tipsContentConfirm = [];
681
682 if (content) {
683 if (content.length == 1) {
684 var _html = {
685 __html: decode(content[0])
686 };
687 tipsContent.push(React.createElement("li", {
688 key: "0",
689 dangerouslySetInnerHTML: _html
690 }));
691 tipsContentConfirm.push(React.createElement("li", {
692 key: "0",
693 dangerouslySetInnerHTML: _html
694 }));
695 } else {
696 content.map(function (item, index) {
697 var _html = {
698 __html: index + 1 + '、' + decode(content[index])
699 };
700 var _html1 = {
701 __html: decode(content[index])
702 };
703 tipsContent.push(React.createElement("li", {
704 key: index,
705 dangerouslySetInnerHTML: _html
706 }));
707 tipsContentConfirm.push(React.createElement("li", {
708 key: index,
709 dangerouslySetInnerHTML: _html1
710 }));
711 });
712 }
713 }
714
715 if (hidden) {
716 return React.createElement("div", null);
717 } else if (popType === '0') {
718 var num = this.DetermineChineseCharacterNum(decode(title));
719 var maxCharacter = manualClose ? 108 : 120;
720
721 if (tipsContent.length == 0 && decode(title).length + num <= maxCharacter) {
722 return React.createElement("div", {
723 className: 'round-pattern-pop-outer ' + roundInfoColor + (this.state.popShow ? ' pop-open-tip' : ' pop-close') + (moveRountTips ? ' round-pattern-pop-outer-move' : ''),
724 style: {
725 maxHeight: maxHeight,
726 left: left + 'px',
727 top: top + 'px'
728 },
729 ref: "roundPatternPopOuter"
730 }, React.createElement("div", {
731 className: 'round-pattern-tips-container',
732 ref: "roundPatternTipsContainer"
733 }, this.renderIcon('round-pattern', promptMessageType), React.createElement("div", {
734 className: manualClose ? 'round-pattern-tips-wrap round-pattern-tips-wrap-short' : 'round-pattern-tips-wrap round-pattern-tips-wrap-long',
735 ref: "roundPatternTipsWrap"
736 }, React.createElement("span", {
737 className: 'round-pattern-tips-title',
738 style: {
739 fontSize: 16
740 }
741 }, decode(title))), manualCloseForRoundPatter));
742 } else {
743 return React.createElement("div", {
744 className: 'pop-outer hint-pop' + (this.state.popShow ? ' pop-open-tip' : ' pop-close') + infoColor + (content.length > 0 ? ' with-content' : '') + (moveTips ? ' pop-out-move' : ''),
745 style: {
746 maxHeight: maxHeight,
747 left: left + 'px',
748 top: top + 'px'
749 },
750 ref: "popOut"
751 }, React.createElement("div", {
752 className: 'tips-container'
753 }, this.renderIcon('no-round-pattern', promptMessageType), React.createElement("div", {
754 className: "tips-wrap"
755 }, React.createElement("span", {
756 className: 'tips-title'
757 }, decode(title))), React.createElement("ul", {
758 className: 'tips-content',
759 ref: "tipsContent"
760 }, tipsContent), React.createElement("div", {
761 className: "showallBtn",
762 ref: "showAllBtn",
763 onClick: this.showAllInfo
764 }, "\u67E5\u770B\u66F4\u591A", React.createElement("div", {
765 className: "arrowdown",
766 ref: "showAllIcon"
767 }, React.createElement(ArrowDownIcon, null)))), manualClosePart);
768 }
769 } else {
770 var dirClass;
771
772 switch (listViewDirection) {
773 case 'right-down':
774 dirClass = 'top left';
775 break;
776
777 case 'left-down':
778 dirClass = 'top right';
779 break;
780
781 case 'left-top':
782 dirClass = 'bottom right';
783 break;
784
785 case 'right-top':
786 dirClass = 'bottom left';
787 break;
788
789 default:
790 }
791
792 var popStyle, popClassName;
793 popClassName = "".concat(setPosition ? '' : listViewDirection, " pop-outer confirm-pop ").concat(this.state.popShow ? "pop-open" : "pop-close", " ").concat(direction === 'center' && target ? 'pop-layer__center' : '');
794 popStyle = genPopStyleIfPosition(dirClass, maxHeight, setPosition, this.props);
795
796 if (direction === 'center') {
797 if (target) {
798 var _computeTargetCenterP = computeTargetCenterPosition(target),
799 _top = _computeTargetCenterP.top,
800 _left = _computeTargetCenterP.left;
801
802 popStyle = genPopStyleIfPosition(dirClass, (maxHeight || MAX_CONFIRM_HEIGHT) - 44, true, {
803 top: _top,
804 left: _left
805 });
806
807 if (this.state.popShow === false) {
808 popClassName += ' pop-layer__center_close';
809 }
810 } else {
811 console.warn('当布局方式为居中时,相对居中对象target是必需的');
812 }
813 }
814
815 var confirm_connect_style = this.props.connectStyle ? this.props.connectStyle : {
816 top: '-9px',
817 left: '0px'
818 };
819 var centerConfirmStyle = direction === 'center' ? {
820 maxHeight: maxHeight ? maxHeight - 44 - 36 : MAX_CONFIRM_HEIGHT - 44 - 36,
821 overflowY: 'scroll'
822 } : {};
823 return React.createElement("div", {
824 ref: "popDirection",
825 className: this.state.moveConform ? popClassName + ' acConfirmMove' : popClassName,
826 style: popStyle
827 }, listViewDirection !== 'center' && React.createElement("div", {
828 className: "confirm-connect",
829 style: confirm_connect_style
830 })
831 /* 当布局方式为居中时,不显示气泡的小尖角 */
832 , React.createElement("div", {
833 style: centerConfirmStyle,
834 className: "confirm-content-container"
835 }, React.createElement("div", {
836 className: "confirm-title"
837 }, React.createElement("div", {
838 className: "confirm-title-image pc_sys_zhuyi_nomal"
839 }), React.createElement("div", {
840 className: "confirm-title-message"
841 }, decode(title))), React.createElement("ul", {
842 className: tipsContent.length > 0 ? "confirm-message confirm-message-hasInfo" : "confirm-message confirm-message-emptyInfo",
843 style: listViewDirection === 'center' ? {
844 maxHeight: 10000
845 } : {}
846 }, tipsContentConfirm)), React.createElement("div", {
847 className: "us-footer clearfix"
848 }, removeSubBtn ? '' : React.createElement(BaseButton, sureButton), React.createElement(BaseButton, cancelButton)));
849 }
850 }
851 }, {
852 key: "componentDidMount",
853 value: function componentDidMount() {
854 //这里要做创建虚拟dom的操作 因为可能存在didMount操作的时候找得到节点 但是节点因为涉及到变淡弹层弹出 没显示问题 造成表单无权限提示信息错乱的问题
855 var textvalveBorder = document.createElement('span');
856 textvalveBorder.style.display = 'inline-block';
857
858 if (this.props.manualClose) {
859 textvalveBorder.className = 'poplayer_text_Border poplayer_text_Border_short';
860 } else {
861 textvalveBorder.className = 'poplayer_text_Border poplayer_text_Border_long';
862 }
863
864 textvalveBorder.innerHTML = this.props.title;
865 document.body.appendChild(textvalveBorder);
866
867 if (this.refs.roundPatternTipsContainer) {
868 if (this.props.manualClose) {
869 this.refs.roundPatternPopOuter.style.width = textvalveBorder.clientWidth + 54 + 'px';
870 this.refs.roundPatternTipsContainer.style.height = textvalveBorder.clientHeight + 'px';
871 } else {
872 this.refs.roundPatternPopOuter.style.width = textvalveBorder.clientWidth + 30 + 'px';
873 this.refs.roundPatternTipsContainer.style.height = textvalveBorder.clientHeight + 'px';
874 }
875 }
876
877 document.body.removeChild(textvalveBorder);
878 this.showFaceActive(this.state.promptMessageType);
879
880 if (this.refs.tipsContent) {
881 if (this.refs.tipsContent.scrollHeight > 100) {} else {
882 if (this.refs.showAllBtn) {
883 this.refs.showAllBtn.style.display = 'none';
884 }
885 }
886 }
887
888 var _this$state3 = this.state,
889 popType = _this$state3.popType,
890 manualClose = _this$state3.manualClose,
891 disTime = _this$state3.disTime;
892 var self = this;
893
894 if (popType === '0' && !manualClose) {
895 setTimeout(function () {
896 self.setState({
897 popShow: false
898 });
899 setTimeout(function () {
900 self.props.showHide && self.props.showHide();
901 }, 300);
902 }, disTime);
903 } else if (popType === '1') {
904 document.removeEventListener('mousedown', this.clickClose);
905 document.addEventListener('mousedown', this.clickClose);
906
907 if (this.props.direction === 'center') {
908 this.setCenterPosition();
909 }
910 } else if (popType === '0' && manualClose) {
911 document.removeEventListener('mousedown', this.moveTips);
912 document.addEventListener('mousedown', this.moveTips);
913 }
914
915 this.createMask(this.props.hidden);
916 }
917 }, {
918 key: "componentDidUpdate",
919 value: function componentDidUpdate() {
920 if (this.props.direction === 'center') {
921 this.setCenterPosition();
922 }
923 }
924 }, {
925 key: "moveTips",
926 value: function moveTips(e) {
927 var _this2 = this;
928
929 var area = this.refs.popOut;
930 var area1 = this.refs.roundPatternPopOuter;
931
932 if (area && area.contains(e.target)) {
933 return;
934 } else if (area1 && area1.contains(e.target)) {
935 return;
936 }
937
938 var self = this;
939
940 if (!this.moveUnAble) {
941 var popOutTest = this.refs.popOut;
942 var popOutTest1 = this.refs.roundPatternPopOuter;
943
944 if (popOutTest1) {
945 this.moveUnAble = true;
946 popOutTest1.className = popOutTest1.className.split('pop-open-after')[0] + ' round-pattern-pop-outer-move';
947 setTimeout(function () {
948 popOutTest1.className = popOutTest1.className.split('round-pattern-pop-outer-move')[0] + ' pop-open-after';
949 _this2.moveUnAble = false;
950 }, 1200);
951 }
952
953 if (popOutTest) {
954 this.moveUnAble = true;
955 popOutTest.className = popOutTest.className.split('pop-open-after')[0] + ' pop-out-move';
956 setTimeout(function () {
957 popOutTest.className = popOutTest.className.split('pop-out-move')[0] + ' pop-open-after';
958 _this2.moveUnAble = false;
959 }, 1200);
960 }
961 }
962 }
963 }, {
964 key: "clickClose",
965 value: function clickClose(e) {
966 var _this3 = this;
967
968 var area = this.refs.popDirection;
969 if (area == undefined) return;
970 if (area.contains(e.target)) return; //这里做点击其他处 弹层晃动的操作
971 // this.popClose(false, e);
972
973 if (!this.clickBool) {
974 this.clickClassName = this.refs.popDirection.className + ' pop-open-after';
975 this.clickBool = 1;
976 }
977
978 if (this.clickBool == 1) {
979 if (this.refs.popDirection.className.split('pop-open-after')[0].indexOf('acConfirmMove') <= 0) {
980 this.refs.popDirection.className = this.refs.popDirection.className.split('pop-open-after')[0] + ' acConfirmMove';
981 }
982 }
983
984 clearTimeout(this.timeOut);
985 this.timeOut = setTimeout(function () {
986 _this3.refs.popDirection.className = _this3.clickClassName;
987 _this3.clickBool == 0;
988 }, 900); // document.removeEventListener('mousedown', this.clickClose);
989 }
990 }]);
991
992 return PopLayer;
993}(Component);
994
995export { PopLayer as default };
\No newline at end of file