Bez popisu

index.js 7.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { i as _slicedToArray, _ as _defineProperty } from '../_commonjsHelpers-aeb41076.js';
  2. import React, { useState } from 'react';
  3. import { c as classnames } from '../index-7951fb2f.js';
  4. import { s as styleInject } from '../style-inject.es-1f59c1d0.js';
  5. import { Input } from 'antd';
  6. 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";
  7. 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_"};
  8. styleInject(css);
  9. var PriceOptions = function PriceOptions(_ref) {
  10. var price = _ref.price,
  11. onPriceChange = _ref.onPriceChange,
  12. _ref$size = _ref.size,
  13. _ref$focusScroll = _ref.focusScroll,
  14. focusScroll = _ref$focusScroll === void 0 ? true : _ref$focusScroll,
  15. _ref$withTitle = _ref.withTitle,
  16. withTitle = _ref$withTitle === void 0 ? true : _ref$withTitle,
  17. _ref$titleText = _ref.titleText,
  18. titleText = _ref$titleText === void 0 ? "Price" : _ref$titleText,
  19. _ref$inputPlaceholder = _ref.inputPlaceholderText,
  20. inputPlaceholderText = _ref$inputPlaceholder === void 0 ? "Others" : _ref$inputPlaceholder,
  21. _ref$priceOptions = _ref.priceOptions,
  22. priceOptions = _ref$priceOptions === void 0 ? [100, 600, 800] : _ref$priceOptions,
  23. _ref$priceRender = _ref.priceRender,
  24. priceRender = _ref$priceRender === void 0 ? function (i) {
  25. return i / 100;
  26. } : _ref$priceRender,
  27. _ref$inputPriceRender = _ref.inputPriceRender,
  28. inputPriceRender = _ref$inputPriceRender === void 0 ? function (i) {
  29. return i ? i / 100 : "";
  30. } : _ref$inputPriceRender,
  31. inputRef = _ref.inputRef;
  32. var defaultOptions = priceOptions; // 控制是否为其他金额输入情况
  33. var _useState = useState(false),
  34. _useState2 = _slicedToArray(_useState, 2),
  35. inputStatus = _useState2[0],
  36. setInputStatus = _useState2[1];
  37. return React.createElement("div", {
  38. className: classnames(styles.options)
  39. }, withTitle ? titleText || null : null, React.createElement("div", {
  40. className: styles.infoItem
  41. }, React.createElement("span", {
  42. className: styles.priceBtn
  43. }, defaultOptions.map(function (item) {
  44. var _classnames;
  45. return React.createElement("span", {
  46. className: classnames((_classnames = {}, _defineProperty(_classnames, styles.priceItem, true), _defineProperty(_classnames, styles.active, price === item && !inputStatus), _classnames)),
  47. key: item,
  48. onClick: function onClick() {
  49. onPriceChange(item);
  50. setInputStatus(false);
  51. }
  52. }, priceRender(item));
  53. })), React.createElement(Input, {
  54. ref: inputRef,
  55. onMouseEnter: function onMouseEnter() {
  56. if (inputStatus && inputRef && inputRef.current) {
  57. inputRef.current.focus();
  58. inputRef.current.select();
  59. }
  60. },
  61. suffix: "\xA5",
  62. className: styles.priceInput,
  63. value: inputStatus ? inputPriceRender(price) : "",
  64. placeholder: inputPlaceholderText,
  65. onChange: function onChange(e) {
  66. var n = +e.target.value;
  67. if (Number.isNaN(n)) {
  68. return;
  69. } // 测试暂时改成1分
  70. onPriceChange(n * 100);
  71. },
  72. onClick: function onClick(e) {
  73. onPriceChange(0);
  74. setInputStatus(true);
  75. },
  76. onFocus: function onFocus(e) {
  77. e.target.placeholder = "";
  78. setInputStatus(true);
  79. if (focusScroll) {
  80. e.target.scrollIntoView();
  81. }
  82. },
  83. onBlur: function onBlur(e) {
  84. e.target.placeholder = inputPlaceholderText;
  85. if (price) {
  86. setInputStatus(true);
  87. } else {
  88. setInputStatus(false);
  89. }
  90. }
  91. })));
  92. };
  93. export default PriceOptions;
  94. //# sourceMappingURL=index.js.map