1
|
|
-{"version":3,"file":"index.js","sources":["../../src/components/Payment/PriceOptions/index.tsx"],"sourcesContent":["import React, { useState } from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { formatMoney } from \"../Utils/utils\";\r\n\r\nimport styles from \"./PriceOptions.less\";\r\n\r\ninterface Props {\r\n price: number;\r\n onPriceChange: (v: number) => void;\r\n size: \"small\" | \"normal\" | \"large\";\r\n focusScroll: boolean;\r\n withTitle: boolean;\r\n titleText: string;\r\n inputRef: React.RefObject<any>;\r\n}\r\n\r\nconst PriceOptions = ({\r\n price,\r\n onPriceChange,\r\n size = \"normal\",\r\n focusScroll = true,\r\n withTitle = true,\r\n titleText = \"Price\",\r\n inputRef\r\n}: Props) => {\r\n const defaultOptions = [100, 600, 800];\r\n // 控制是否为其他金额输入情况\r\n const [inputStatus, setInputStatus] = useState(false);\r\n\r\n return (\r\n <div\r\n className={classnames(styles.options)}\r\n >\r\n {withTitle ? (\r\n <p>\r\n {titleText}\r\n </p>\r\n ) : null}\r\n <div className={styles.infoItem}>\r\n <span className={styles.priceBtn}>\r\n {defaultOptions.map(item => (\r\n <span\r\n className={classnames({\r\n [styles.priceItem]: true,\r\n [styles.active]: price === item && !inputStatus\r\n })}\r\n key={item}\r\n onClick={() => {\r\n onPriceChange(item);\r\n setInputStatus(false);\r\n }}\r\n >\r\n {formatMoney(item/100, 0)}¥\r\n </span>\r\n ))}\r\n </span>\r\n {/* <Input\r\n ref={inputRef}\r\n onMouseEnter={() => {\r\n if (inputStatus && inputRef && inputRef.current) {\r\n inputRef.current.focus();\r\n inputRef.current.select();\r\n }\r\n }}\r\n suffix=\"¥\"\r\n className={styles.priceInput}\r\n value={inputStatus ? price / 100 || \"\" : \"\"}\r\n placeholder=\"Others\"\r\n onChange={e => {\r\n const n = +e.target.value;\r\n if (Number.isNaN(n)) {\r\n return;\r\n }\r\n // 测试暂时改成1分\r\n onPriceChange(n * 100);\r\n }}\r\n onClick={e => {\r\n onPriceChange(0);\r\n setInputStatus(true);\r\n }}\r\n onFocus={e => {\r\n if (focusScroll) {\r\n e.target.scrollIntoView();\r\n }\r\n }}\r\n /> */}\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default PriceOptions;\r\n"],"names":["PriceOptions","price","onPriceChange","size","focusScroll","withTitle","titleText","inputRef","defaultOptions","useState","inputStatus","setInputStatus","React","classnames","styles","options","infoItem","priceBtn","map","item","priceItem","active","formatMoney"],"mappings":";;;;;;;;;;;;;;;;;AAgBA,IAAMA,YAAY,GAAG,SAAfA,YAAe,OAQR;MAPXC,KAOW,QAPXA,KAOW;MANXC,aAMW,QANXA,aAMW;uBALXC,IAKW;MALXA,wBACAC,WAIW;MAJXA,sBACAC,SAGW;MAHXA,SAGW,+BAHC,IAGD;4BAFXC,SAEW;MAFXA,SAEW,+BAFC,OAED;MADXC,QACW,QADXA,QACW;MACLC,cAAc,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAvB,CADW;;kBAG2BC,cAAQ,CAAC,KAAD,CAHnC;;MAGJC,WAHI;MAGSC,cAHT;;SAMTC;IACE,SAAS,EAAEC,gBAAU,CAACC,MAAM,CAACC,OAAR;KAEpBV,SAAS,GACRO,wCACGN,SADH,CADQ,GAIN,IAPN,EAQEM;IAAK,SAAS,EAAEE,MAAM,CAACE;KACrBJ;IAAM,SAAS,EAAEE,MAAM,CAACG;KACrBT,cAAc,CAACU,GAAf,CAAmB,UAAAC,IAAI;;;WACtBP;MACE,SAAS,EAAEC,gBAAU,kEAClBC,MAAM,CAACM,SADW,EACC,IADD,iDAElBN,MAAM,CAACO,MAFW,EAEFpB,KAAK,KAAKkB,IAAV,IAAkB,CAACT,WAFjB,gBADvB;MAKE,GAAG,EAAES,IALP;MAME,OAAO,EAAE,mBAAM;QACbjB,aAAa,CAACiB,IAAD,CAAb;QACAR,cAAc,CAAC,KAAD,CAAd;;OAGDW,iBAAW,CAACH,IAAI,GAAC,GAAN,EAAW,CAAX,CAXd,SADsB;GAAvB,CADH,CADF,CARF,CADF;CAbF;;;;"}
|
|
1
|
+{"version":3,"file":"index.js","sources":["../../src/components/Payment/PriceOptions/index.tsx"],"sourcesContent":["import React, { useState } from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { Input } from 'antd';\r\nimport { formatMoney } from \"../Utils/utils\";\r\n\r\nimport styles from \"./PriceOptions.less\";\r\n\r\ninterface Props {\r\n price: number;\r\n onPriceChange: (v: number) => void;\r\n size: \"small\" | \"normal\" | \"large\";\r\n focusScroll: boolean;\r\n withTitle: boolean;\r\n titleText: string;\r\n inputRef: React.RefObject<any>;\r\n}\r\n\r\nconst PriceOptions = ({\r\n price,\r\n onPriceChange,\r\n size = \"normal\",\r\n focusScroll = true,\r\n withTitle = true,\r\n titleText = \"Price\",\r\n inputRef\r\n}: Props) => {\r\n const defaultOptions = [100, 600, 800];\r\n // 控制是否为其他金额输入情况\r\n const [inputStatus, setInputStatus] = useState(false);\r\n\r\n return (\r\n <div\r\n className={classnames(styles.options)}\r\n >\r\n {withTitle ? (\r\n <p>\r\n {titleText}\r\n </p>\r\n ) : null}\r\n <div className={styles.infoItem}>\r\n <span className={styles.priceBtn}>\r\n {defaultOptions.map(item => (\r\n <span\r\n className={classnames({\r\n [styles.priceItem]: true,\r\n [styles.active]: price === item && !inputStatus\r\n })}\r\n key={item}\r\n onClick={() => {\r\n onPriceChange(item);\r\n setInputStatus(false);\r\n }}\r\n >\r\n {formatMoney(item/100, 0)}¥\r\n </span>\r\n ))}\r\n </span>\r\n <Input\r\n ref={inputRef}\r\n onMouseEnter={() => {\r\n if (inputStatus && inputRef && inputRef.current) {\r\n inputRef.current.focus();\r\n inputRef.current.select();\r\n }\r\n }}\r\n suffix=\"¥\"\r\n className={styles.priceInput}\r\n value={inputStatus ? price / 100 || \"\" : \"\"}\r\n placeholder=\"Others\"\r\n onChange={e => {\r\n const n = +e.target.value;\r\n if (Number.isNaN(n)) {\r\n return;\r\n }\r\n // 测试暂时改成1分\r\n onPriceChange(n * 100);\r\n }}\r\n onClick={e => {\r\n onPriceChange(0);\r\n setInputStatus(true);\r\n }}\r\n onFocus={e => {\r\n if (focusScroll) {\r\n e.target.scrollIntoView();\r\n }\r\n }}\r\n />\r\n </div>\r\n </div>\r\n );\r\n};\r\n\r\nexport default PriceOptions;\r\n"],"names":["PriceOptions","price","onPriceChange","size","focusScroll","withTitle","titleText","inputRef","defaultOptions","useState","inputStatus","setInputStatus","React","classnames","styles","options","infoItem","priceBtn","map","item","priceItem","active","formatMoney","Input","current","focus","select","priceInput","e","n","target","value","Number","isNaN","scrollIntoView"],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,IAAMA,YAAY,GAAG,SAAfA,YAAe,OAQR;MAPXC,KAOW,QAPXA,KAOW;MANXC,aAMW,QANXA,aAMW;uBALXC,IAKW;MALXA,wBACAC,WAIW;MAJXA,WAIW,iCAJG,IAIH;4BAHXC,SAGW;MAHXA,SAGW,+BAHC,IAGD;4BAFXC,SAEW;MAFXA,SAEW,+BAFC,OAED;MADXC,QACW,QADXA,QACW;MACLC,cAAc,GAAG,CAAC,GAAD,EAAM,GAAN,EAAW,GAAX,CAAvB,CADW;;kBAG2BC,cAAQ,CAAC,KAAD,CAHnC;;MAGJC,WAHI;MAGSC,cAHT;;SAMTC;IACE,SAAS,EAAEC,gBAAU,CAACC,MAAM,CAACC,OAAR;KAEpBV,SAAS,GACRO,wCACGN,SADH,CADQ,GAIN,IAPN,EAQEM;IAAK,SAAS,EAAEE,MAAM,CAACE;KACrBJ;IAAM,SAAS,EAAEE,MAAM,CAACG;KACrBT,cAAc,CAACU,GAAf,CAAmB,UAAAC,IAAI;;;WACtBP;MACE,SAAS,EAAEC,gBAAU,kEAClBC,MAAM,CAACM,SADW,EACC,IADD,iDAElBN,MAAM,CAACO,MAFW,EAEFpB,KAAK,KAAKkB,IAAV,IAAkB,CAACT,WAFjB,gBADvB;MAKE,GAAG,EAAES,IALP;MAME,OAAO,EAAE,mBAAM;QACbjB,aAAa,CAACiB,IAAD,CAAb;QAC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