Bez popisu

index.js 6.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 { f as formatMoney } from '../utils-82346768.js';
  6. import { Input } from 'antd';
  7. 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";
  8. 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_"};
  9. styleInject(css);
  10. var PriceOptions = function PriceOptions(_ref) {
  11. var price = _ref.price,
  12. onPriceChange = _ref.onPriceChange,
  13. _ref$size = _ref.size,
  14. _ref$focusScroll = _ref.focusScroll,
  15. focusScroll = _ref$focusScroll === void 0 ? true : _ref$focusScroll,
  16. _ref$withTitle = _ref.withTitle,
  17. withTitle = _ref$withTitle === void 0 ? true : _ref$withTitle,
  18. _ref$titleText = _ref.titleText,
  19. titleText = _ref$titleText === void 0 ? "Price" : _ref$titleText,
  20. inputRef = _ref.inputRef;
  21. var defaultOptions = [100, 600, 800]; // 控制是否为其他金额输入情况
  22. var _useState = useState(false),
  23. _useState2 = _slicedToArray(_useState, 2),
  24. inputStatus = _useState2[0],
  25. setInputStatus = _useState2[1];
  26. return React.createElement("div", {
  27. className: classnames(styles.options)
  28. }, withTitle ? React.createElement("p", null, titleText) : null, React.createElement("div", {
  29. className: styles.infoItem
  30. }, React.createElement("span", {
  31. className: styles.priceBtn
  32. }, defaultOptions.map(function (item) {
  33. var _classnames;
  34. return React.createElement("span", {
  35. className: classnames((_classnames = {}, _defineProperty(_classnames, styles.priceItem, true), _defineProperty(_classnames, styles.active, price === item && !inputStatus), _classnames)),
  36. key: item,
  37. onClick: function onClick() {
  38. onPriceChange(item);
  39. setInputStatus(false);
  40. }
  41. }, formatMoney(item / 100, 0), "\xA5");
  42. })), React.createElement(Input, {
  43. ref: inputRef,
  44. onMouseEnter: function onMouseEnter() {
  45. if (inputStatus && inputRef && inputRef.current) {
  46. inputRef.current.focus();
  47. inputRef.current.select();
  48. }
  49. },
  50. suffix: "\xA5",
  51. className: styles.priceInput,
  52. value: inputStatus ? price / 100 || "" : "",
  53. placeholder: "Others",
  54. onChange: function onChange(e) {
  55. var n = +e.target.value;
  56. if (Number.isNaN(n)) {
  57. return;
  58. } // 测试暂时改成1分
  59. onPriceChange(n * 100);
  60. },
  61. onClick: function onClick(e) {
  62. onPriceChange(0);
  63. setInputStatus(true);
  64. },
  65. onFocus: function onFocus(e) {
  66. if (focusScroll) {
  67. e.target.scrollIntoView();
  68. }
  69. }
  70. })));
  71. };
  72. export default PriceOptions;
  73. //# sourceMappingURL=index.js.map