Ingen beskrivning

index.js 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var inherits = require('../inherits-c86d64c1.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. require('react-dom');
  8. var Modal = require('../Modal/index.js');
  9. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  10. var antd = require('antd');
  11. var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABMAAAATCAYAAAByUDbMAAACMUlEQVQ4T52Uz4tSURTHPxP9oCkKy0UuIqvZSAsrHHgLEaFSDCJoU0GpQaBgqOCmP6AWKrR5kIELNzZZUUQLlReFFowOboQK2oyLkgExsxqJoprixlx5yXs1dXbvnO/93HPPO+dM8WfbCuwANgNfgA/A0OzIlElgH3AIsBrEl4EXwEvguz4+CdsIHAV2/yVjEX4PVFez/SXXwzYAJ4GdawBJyWfggQTqYSKj/f8AklKR4V1gRcJ2rWY1Zvl8PqumaW8n4YFAwFqpVCb988BzCTsCzMiDDodjut1uX11YWGh4PJ470p/L5ZRIJHI+kUhcU1V1UXfRR+CWhF0ARPHHpqrqbCwWC7darXm32z2Xz+fdoVDobL1ef+z1eu8ZlOO2gIkeChrVKpPJHEylUhd7vd5rm822V9O0it/vf2hS16qAbQfOmBW+3W6HnU6nMhgMlux2+5XRaLRion0iYJuAsJGgWq2e8Pv9x5vN5lOXy6V0Op1XiqLkh8PhNwN9WdbsHLBFL6jVaqc8Hs+xYrE4FwwGnyWTyZl0On2p2+0uKopyo9/vf9XpfwA3JcwNHND/zUajcblUKpWj0WhT+qPRqD2bzUbi8fj1QqHwRgfrA/clbBtwGlgnBRaLZb3Rc0z8j4COfgJmgcP/MQEiw/LkbAqwGCmxMdZq7wDRKmI9/Tbo8ltk6NQ/2YTcAWrA+EeY7TPRewK4B5jWwcRB8Syxy5YmLzGD6XViQuSm/QSINjC0n/ltqZBTCKFgAAAAAElFTkSuQmCC";
  12. var css = ".AllocWantedModal_wantedModalContent__1VodF {\n background-color: white;\n width: 360px;\n height: 314px;\n padding: 22px 28px;\n border-radius: 7px;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_title__31i9F {\n font-size: 18px;\n font-weight: 400;\n text-align: center;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_wantedValueText___uNQe {\n color: #565656;\n margin-top: 48px;\n font-size: 14px;\n line-height: 20px;\n text-align: center;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_wantedInputNumber__3MyO5 {\n margin: 11px auto;\n text-align: center;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_wantedInputNumber__3MyO5 .ant-input {\n color: #FB4B56;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_wantedValueTipBottom__3WBt0 {\n margin: 0 auto;\n font-size: 12px;\n text-align: center;\n width: 208px;\n color: #9B9B9B;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX {\n display: flex;\n justify-content: center;\n align-items: center;\n margin-top: 23px;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX .AllocWantedModal_confirmButton__1yXDN {\n color: white;\n background-color: #71C135;\n width: 170px;\n height: 36px;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX .AllocWantedModal_confirmButton__1yXDN:hover,\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX .AllocWantedModal_confirmButton__1yXDN:focus {\n outline: none;\n border-color: #8cd158;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX .AllocWantedModal_tipsButton__UmFpw {\n margin-left: 22px;\n width: 20px;\n}\n.AllocWantedModal_wantedModalContent__1VodF .AllocWantedModal_buttonRow__FegZX .AllocWantedModal_tipsButton__UmFpw .schedule {\n font-size: 18px;\n cursor: pointer;\n}\n.AllocWantedModal_closeButton__1d4p- {\n position: absolute;\n right: 10px;\n top: 10px;\n display: block;\n width: 20px;\n height: 20px;\n border-radius: 50%;\n cursor: pointer;\n}\n.AllocWantedModal_closeButton__1d4p- img {\n width: 100%;\n height: 100%;\n}\n.AllocWantedModal_tipsView__3my0J h6 {\n margin: 0;\n font-size: 12px;\n line-height: 22px;\n color: #3D3D3D;\n}\n.AllocWantedModal_tipsView__3my0J div {\n font-size: 12px;\n}\n.AllocWantedModal_outRangeTextTip__3R4mw .ant-tooltip-inner {\n color: red;\n}\n";
  13. var styles = {
  14. "wantedModalContent": "AllocWantedModal_wantedModalContent__1VodF",
  15. "title": "AllocWantedModal_title__31i9F",
  16. "wantedValueText": "AllocWantedModal_wantedValueText___uNQe",
  17. "wantedInputNumber": "AllocWantedModal_wantedInputNumber__3MyO5",
  18. "wantedValueTipBottom": "AllocWantedModal_wantedValueTipBottom__3WBt0",
  19. "buttonRow": "AllocWantedModal_buttonRow__FegZX",
  20. "confirmButton": "AllocWantedModal_confirmButton__1yXDN",
  21. "tipsButton": "AllocWantedModal_tipsButton__UmFpw",
  22. "closeButton": "AllocWantedModal_closeButton__1d4p-",
  23. "tipsView": "AllocWantedModal_tipsView__3my0J",
  24. "outRangeTextTip": "AllocWantedModal_outRangeTextTip__3R4mw"
  25. };
  26. styleInject_es.styleInject(css);
  27. var AllocWantedModal =
  28. /*#__PURE__*/
  29. function (_React$Component) {
  30. inherits._inherits(AllocWantedModal, _React$Component);
  31. function AllocWantedModal(props) {
  32. var _this;
  33. inherits._classCallCheck(this, AllocWantedModal);
  34. _this = inherits._possibleConstructorReturn(this, inherits._getPrototypeOf(AllocWantedModal).call(this, props));
  35. _this.handleSendValueChange = function (v) {
  36. if (_this.state.outRangeTip) {
  37. _this.setState({
  38. outRangeTip: !_this.checkSendValue()
  39. });
  40. }
  41. _this.setState({
  42. sendValue: v
  43. });
  44. };
  45. _this.checkSendValue = function () {
  46. var sendValueRange = _this.props.sendValueRange;
  47. var sendValue = _this.state.sendValue;
  48. var min = 0;
  49. var max = Number(_this.props.allocValue);
  50. if (sendValueRange) {
  51. min = Number(sendValueRange[0]);
  52. max = Number(sendValueRange[1]);
  53. }
  54. if (sendValue > max) {
  55. _this.setState({
  56. outRangeTip: true
  57. });
  58. return false;
  59. } else if (sendValue < min) {
  60. _this.setState({
  61. outRangeTip: true
  62. });
  63. return false;
  64. }
  65. return true;
  66. };
  67. _this.handleCloseAction = function () {
  68. _this.setState({
  69. visible: false,
  70. sendValue: 0,
  71. outRangeTip: false
  72. }, function () {
  73. _this.props.handleVisibleChange(false);
  74. });
  75. };
  76. _this.handleShowAction = function () {
  77. _this.setState({
  78. visible: true
  79. }, function () {
  80. _this.props.handleVisibleChange(true);
  81. });
  82. };
  83. _this.handleConfirm = function () {
  84. var sendGiftData = _this.props.sendGiftData;
  85. var checkResult = _this.checkSendValue();
  86. if (!checkResult) {
  87. return null;
  88. }
  89. Promise.resolve(_this.props.sendRequest({
  90. business_type: 14,
  91. ref_id: sendGiftData.answerId.toString(),
  92. origin_id: sendGiftData.questionId,
  93. to_user: sendGiftData.toUserId,
  94. goods_id: 2,
  95. num: Number(_this.state.sendValue)
  96. })).then(function (res) {
  97. if (res) {
  98. _this.handleCloseAction();
  99. } else {
  100. _this.handleCloseAction();
  101. }
  102. });
  103. };
  104. _this.renderCloseButton = function () {
  105. return React__default.createElement("div", {
  106. role: "button",
  107. tabIndex: -1,
  108. className: styles.closeButton,
  109. onClick: function onClick() {
  110. _this.handleCloseAction();
  111. }
  112. }, React__default.createElement("img", {
  113. src: img,
  114. alt: "close button for send wanted"
  115. }));
  116. };
  117. _this.renderModalContent = function () {
  118. return React__default.createElement("div", {
  119. className: styles.wantedModalContent,
  120. ref: _this.ModalContentRef
  121. }, _this.renderCloseButton(), React__default.createElement("h4", {
  122. className: styles.title
  123. }, "\u5206\u914D\u60AC\u8D4F\u5956\u91D1"), React__default.createElement("div", {
  124. className: styles.wantedValueText
  125. }, "\u5269\u4F59\u53EF\u5206\u914D ".concat(_this.props.allocValue, "\u5143")), React__default.createElement(antd.Tooltip, {
  126. visible: _this.state.outRangeTip,
  127. title: "\u8D85\u8FC7\u8303\u56F4\u503C",
  128. placement: "bottom",
  129. overlayClassName: styles.outRangeTextTip,
  130. getTooltipContainer: function getTooltipContainer() {
  131. return _this.ModalContentRef && _this.ModalContentRef.current;
  132. }
  133. }, React__default.createElement(antd.Input, {
  134. ref: _this.ModalInputRef,
  135. className: styles.wantedInputNumber,
  136. suffix: "\u5143",
  137. value: _this.state.sendValue,
  138. onChange: function onChange(e) {
  139. return _this.handleSendValueChange(e.target.value);
  140. },
  141. onFocus: function onFocus(e) {
  142. return e.target.setSelectionRange(0, String(_this.state.sendValue).length);
  143. }
  144. })), React__default.createElement("div", {
  145. className: styles.wantedValueTipBottom
  146. }, "\u9700\u8981\u5728\u60AC\u8D4F\u65F6\u95F4\u7ED3\u675F\u524D\u5C06\u5956\u91D1\u5206\u914D\u5B8C\u6210, \u5426\u5219\u5C06\u6309\u7167\u89C4\u5219\u81EA\u52A8\u5206\u914D"), React__default.createElement("div", {
  147. className: styles.buttonRow
  148. }, React__default.createElement("div", {
  149. className: styles.tipsButton
  150. }), React__default.createElement(antd.Button, {
  151. className: styles.confirmButton,
  152. onClick: _this.handleConfirm
  153. }, "\u786E\u8BA4"), React__default.createElement("div", {
  154. className: styles.tipsButton
  155. }, React__default.createElement(antd.Popover, {
  156. placement: "bottom",
  157. trigger: "click",
  158. getPopupContainer: function getPopupContainer() {
  159. return _this.ModalContentRef && _this.ModalContentRef.current;
  160. },
  161. overlayStyle: {
  162. width: "320px"
  163. },
  164. content: React__default.createElement("div", {
  165. className: styles.tipsView
  166. }, React__default.createElement("h6", null, "1\u3001\u5982\u4F55\u53C2\u4E0E\u60AC\u8D4F\uFF1F"), React__default.createElement("div", null, "\u60AC\u8D4F\u95EE\u9898\u7686\u6709\u6709\u6548\u671F\uFF0C\u9ED8\u8BA4\u4E3A120\u5C0F\u65F6\uFF085\u5929\uFF09\uFF0C\u5728\u6709\u6548\u671F\u5185\u56DE\u590D\u7684\u7B54\u6848\uFF0C\u624D\u6709\u8D44\u683C\u88AB\u9009\u4E3A\u6700\u4F73\u7B54\u6848\uFF0C\u4EE5\u53CA\u5206\u5F97\u8D4F\u91D1\u3002"), React__default.createElement("h6", null, "2\u3001\u8D4F\u91D1\u5982\u4F55\u5206\uFF1F"), React__default.createElement("div", null, "\u60AC\u8D4F\u65F6\u95F4\u7ED3\u675F\u524D\uFF0C\u63D0\u95EE\u8005\u53EF\u968F\u65F6\u9009\u51FA\u6700\u4F18\u7B54\u6848\uFF0C\u5E76\u5BF9\u8D4F\u91D1\u8FDB\u884C\u5206\u914D\uFF0C\u76F4\u81F3\u8D4F\u91D1\u88AB\u5206\u5B8C\u6216\u65F6\u95F4\u5230\u671F\u4E3A\u6B62\u3002\u82E5\u60AC\u8D4F\u65F6\u95F4\u5230\u671F\uFF0C\u60AC\u8D4F\u8005\u4ECD\u672A\u5206\u914D\u8D4F\u91D1\uFF0C\u4E14\u56DE\u7B54\u6570\u5927\u4E8E\u7B49\u4E8E2\uFF0C\u7CFB\u7EDF\u5219\u9ED8\u8BA4\u5C06\u8D4F\u91D1\u5E73\u5206\u7ED9\u70B9\u8D5E\u6570\u524D3\u540D\u7684\u56DE\u7B54\u3002"), React__default.createElement("h6", null, "3\u3001\u8D4F\u91D1\u80FD\u9000\u6B3E\u5417\uFF1F"), React__default.createElement("div", null, "\u8D4F\u91D1\u53EA\u4F1A\u5728\u4EE5\u4E0B2\u79CD\u60C5\u51B5\u8FDB\u884C\u9000\u6B3E\uFF1A\u4E00\u3001\u60AC\u8D4F\u65F6\u95F4\u5230\u671F\uFF0C\u56DE\u7B54\u6570\u5C0F\u4E8E2\uFF0C\u8D4F\u91D1\u5C06\u81EA\u52A8\u9000\u8FD8\u81F3\u63D0\u95EE\u8005\u7684\u94B1\u5305\uFF1B\u4E8C\u3001\u60AC\u8D4F\u65F6\u95F4\u5230\u671F\uFF0C\u60AC\u8D4F\u8005\u672A\u5206\u914D\u5B8C\u8D4F\u91D1\uFF0C\u7CFB\u7EDF\u81EA\u52A8\u5C06\u5269\u4F59\u7684\u8D4F\u91D1\u9000\u8FD8\u81F3\u63D0\u95EE\u8005\u7684\u94B1\u5305\u3002"))
  167. }, React__default.createElement("i", {
  168. className: "schedule schedule-icon_rewardtips"
  169. })))));
  170. };
  171. _this.state = {
  172. visible: false,
  173. sendValue: 0,
  174. outRangeTip: false
  175. };
  176. _this.ModalContentRef = React__default.createRef();
  177. _this.ModalInputRef = React__default.createRef();
  178. return _this;
  179. }
  180. inherits._createClass(AllocWantedModal, [{
  181. key: "render",
  182. value: function render() {
  183. var _this2 = this;
  184. var children = this.props.children;
  185. return React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
  186. className: styles.wrapper,
  187. onClick: function onClick() {
  188. return _this2.handleShowAction();
  189. }
  190. }, children), React__default.createElement(Modal.Modal, {
  191. visible: this.state.visible,
  192. onCancel: function onCancel() {
  193. return _this2.handleCloseAction();
  194. }
  195. }, this.renderModalContent()));
  196. }
  197. }]);
  198. return AllocWantedModal;
  199. }(React__default.Component);
  200. exports.default = AllocWantedModal;
  201. //# sourceMappingURL=index.js.map