No Description

index.js 6.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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 _commonjsHelpers = require('../_commonjsHelpers-4ed3570f.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. var index = require('../index-c2424ad4.js');
  8. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  9. var utils = require('../utils-ed518bfc.js');
  10. var antd = require('antd');
  11. require('antd/lib/button/style');
  12. var css = ".PriceOptions_options__J-ZSS {\n padding: 20px 50px;\n border-bottom: 1px dashed #00000017;\n}\n.PriceOptions_options__J-ZSS p {\n font-size: 14px;\n font-weight: 400;\n color: #616a79;\n margin-bottom: 20px;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a {\n padding-right: 0;\n margin-bottom: -12px;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2 {\n background: rgba(243, 243, 243, 0.14);\n border-radius: 4px;\n border: 1px solid #cfcfcf;\n font-size: 14px;\n font-weight: 600;\n color: #616a79;\n display: inline-block;\n text-align: center;\n vertical-align: top;\n height: 30px;\n width: 70px;\n line-height: 30px;\n cursor: pointer;\n margin: 6px;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2.PriceOptions_active__3WyAU {\n background: rgba(255, 50, 102, 0.1);\n border-radius: 4px;\n border: 1px solid #ff3266;\n color: #616a79;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceInput__1MrVy {\n display: inline-block;\n min-width: 70px;\n width: auto;\n margin: 6px;\n text-align: center;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a button {\n border-top-left-radius: 0;\n border-bottom-left-radius: 0;\n height: 30px;\n width: 50px;\n vertical-align: top;\n padding: 0 5px;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_rate__QgHQ3 {\n margin-left: 10px;\n}\n.PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_rate__QgHQ3 i {\n margin-right: 5px;\n color: #1790FF;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl {\n padding: 0 0 12px 0;\n border-bottom: none;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl p {\n margin-bottom: 8px;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl .PriceOptions_infoItem__3IL3a {\n text-align: center;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2 {\n border-radius: 6px;\n height: 32px;\n width: 72px;\n margin: 0 0 12px 19px;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2:first-child {\n margin: 0 0 12px 0px;\n}\n.PriceOptions_options__J-ZSS.PriceOptions_small__2-wzl .PriceOptions_infoItem__3IL3a .PriceOptions_priceInput__1MrVy {\n display: block;\n width: 254px;\n border-radius: 6px;\n height: 32px;\n}\n@media (max-width: 768px) {\n .PriceOptions_options__J-ZSS {\n padding: 20px 20px;\n }\n .PriceOptions_options__J-ZSS p {\n font-size: 14px;\n font-weight: 400;\n color: #616a79;\n }\n .PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a {\n padding-right: 0;\n display: flex;\n flex-direction: column;\n justify-content: center;\n }\n .PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceBtn__Xz4m_ {\n display: flex;\n justify-content: space-between;\n }\n .PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2 {\n display: inline-block;\n background-color: #fff;\n width: 74px;\n height: 36px;\n line-height: 36px;\n border-radius: 6px;\n border: 1px solid #cfcfcf;\n }\n .PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceItem__rJ9o2.PriceOptions_active__3WyAU {\n background-color: #fff;\n color: #FF3266FF;\n border-radius: 4px;\n border: 1px solid #ff3266;\n }\n .PriceOptions_options__J-ZSS .PriceOptions_infoItem__3IL3a .PriceOptions_priceInput__1MrVy {\n border-radius: 6px;\n height: 36px;\n width: auto;\n }\n}\n";
  13. var styles = {"options":"PriceOptions_options__J-ZSS","infoItem":"PriceOptions_infoItem__3IL3a","priceItem":"PriceOptions_priceItem__rJ9o2","active":"PriceOptions_active__3WyAU","priceInput":"PriceOptions_priceInput__1MrVy","rate":"PriceOptions_rate__QgHQ3","small":"PriceOptions_small__2-wzl","priceBtn":"PriceOptions_priceBtn__Xz4m_"};
  14. styleInject_es.styleInject(css);
  15. var PriceOptions = function PriceOptions(_ref) {
  16. var price = _ref.price,
  17. onPriceChange = _ref.onPriceChange,
  18. _ref$size = _ref.size,
  19. _ref$focusScroll = _ref.focusScroll,
  20. focusScroll = _ref$focusScroll === void 0 ? true : _ref$focusScroll,
  21. _ref$withTitle = _ref.withTitle,
  22. withTitle = _ref$withTitle === void 0 ? true : _ref$withTitle,
  23. _ref$titleText = _ref.titleText,
  24. titleText = _ref$titleText === void 0 ? "Price" : _ref$titleText,
  25. inputRef = _ref.inputRef;
  26. var defaultOptions = [100, 600, 800]; // 控制是否为其他金额输入情况
  27. var _useState = React.useState(false),
  28. _useState2 = _commonjsHelpers._slicedToArray(_useState, 2),
  29. inputStatus = _useState2[0],
  30. setInputStatus = _useState2[1];
  31. return React__default.createElement("div", {
  32. className: index.classnames(styles.options)
  33. }, withTitle ? React__default.createElement("p", null, titleText) : null, React__default.createElement("div", {
  34. className: styles.infoItem
  35. }, React__default.createElement("span", {
  36. className: styles.priceBtn
  37. }, defaultOptions.map(function (item) {
  38. var _classnames;
  39. return React__default.createElement("span", {
  40. className: index.classnames((_classnames = {}, _commonjsHelpers._defineProperty(_classnames, styles.priceItem, true), _commonjsHelpers._defineProperty(_classnames, styles.active, price === item && !inputStatus), _classnames)),
  41. key: item,
  42. onClick: function onClick() {
  43. onPriceChange(item);
  44. setInputStatus(false);
  45. }
  46. }, utils.formatMoney(item / 100, 0), "\xA5");
  47. })), React__default.createElement(antd.Input, {
  48. ref: inputRef,
  49. onMouseEnter: function onMouseEnter() {
  50. if (inputStatus && inputRef && inputRef.current) {
  51. inputRef.current.focus();
  52. inputRef.current.select();
  53. }
  54. },
  55. suffix: "\xA5",
  56. className: styles.priceInput,
  57. value: inputStatus ? price / 100 || "" : "",
  58. placeholder: "Others",
  59. onChange: function onChange(e) {
  60. var n = +e.target.value;
  61. if (Number.isNaN(n)) {
  62. return;
  63. } // 测试暂时改成1分
  64. onPriceChange(n * 100);
  65. },
  66. onClick: function onClick(e) {
  67. onPriceChange(0);
  68. setInputStatus(true);
  69. },
  70. onFocus: function onFocus(e) {
  71. if (focusScroll) {
  72. e.target.scrollIntoView();
  73. }
  74. }
  75. })));
  76. };
  77. exports.default = PriceOptions;
  78. //# sourceMappingURL=index.js.map