From 01a66ff33ca6c4ec0584f2a4fb6400416427ad0d Mon Sep 17 00:00:00 2001 From: CaIon <1808837298@qq.com> Date: Sat, 9 Sep 2023 05:04:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=85=85=E5=80=BCbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/constants.go | 2 +- controller/topup.go | 2 +- model/option.go | 4 ++-- web/src/components/SystemSetting.js | 9 ++++++--- web/src/pages/TopUp/index.js | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/common/constants.go b/common/constants.go index e0d1b73f..89c27973 100644 --- a/common/constants.go +++ b/common/constants.go @@ -16,7 +16,7 @@ var ServerAddress = "http://localhost:3000" var PayAddress = "" var EpayId = "" var EpayKey = "" -var Price = 7 +var Price = 7.3 var Footer = "" var Logo = "" var TopUpLink = "" diff --git a/controller/topup.go b/controller/topup.go index 1a83e79f..4a7a62e7 100644 --- a/controller/topup.go +++ b/controller/topup.go @@ -40,7 +40,7 @@ func GetEpayClient() *epay.Client { func GetAmount(count float64) float64 { // 别问为什么用float64,问就是这么点钱没必要 - amount := count * float64(common.Price) + amount := count * common.Price return amount } diff --git a/model/option.go b/model/option.go index 905ef3d5..84841e08 100644 --- a/model/option.go +++ b/model/option.go @@ -56,7 +56,7 @@ func InitOptionMap() { common.OptionMap["PayAddress"] = "" common.OptionMap["EpayId"] = "" common.OptionMap["EpayKey"] = "" - common.OptionMap["Price"] = strconv.Itoa(common.Price) + common.OptionMap["Price"] = strconv.FormatFloat(common.Price, 'f', -1, 64) common.OptionMap["GitHubClientId"] = "" common.OptionMap["GitHubClientSecret"] = "" common.OptionMap["WeChatServerAddress"] = "" @@ -183,7 +183,7 @@ func updateOptionMap(key string, value string) (err error) { case "EpayKey": common.EpayKey = value case "Price": - common.Price, _ = strconv.Atoi(value) + common.Price, _ = strconv.ParseFloat(value, 64) case "GitHubClientId": common.GitHubClientId = value case "GitHubClientSecret": diff --git a/web/src/components/SystemSetting.js b/web/src/components/SystemSetting.js index 250b9bad..efb437ab 100644 --- a/web/src/components/SystemSetting.js +++ b/web/src/components/SystemSetting.js @@ -19,7 +19,7 @@ const SystemSetting = () => { ServerAddress: '', EpayId: '', EpayKey: '', - Price: '', + Price: 7.3, PayAddress: '', Footer: '', WeChatAuthEnabled: '', @@ -90,6 +90,9 @@ const SystemSetting = () => { if (key === 'EmailDomainWhitelist') { value = value.split(','); } + if (key === 'Price') { + value = parseFloat(value); + } setInputs((inputs) => ({ ...inputs, [key]: value })); @@ -142,7 +145,7 @@ const SystemSetting = () => { await updateOption('PayAddress', PayAddress); await updateOption('EpayId', inputs.EpayId); await updateOption('EpayKey', inputs.EpayKey); - await updateOption('Price', inputs.Price); + await updateOption('Price', "" + inputs.Price); }; const submitSMTP = async () => { @@ -289,7 +292,7 @@ const SystemSetting = () => { placeholder='例如:7,就是7元/美金' value={inputs.Price} name='Price' - type='number' + min={0} onChange={handleInputChange} /> diff --git a/web/src/pages/TopUp/index.js b/web/src/pages/TopUp/index.js index 059a72c3..1ad5b0d4 100644 --- a/web/src/pages/TopUp/index.js +++ b/web/src/pages/TopUp/index.js @@ -132,9 +132,9 @@ const TopUp = () => { if (message === 'success') { setAmount(parseInt(data)); } else { - showError(message); + showError(data); // setTopUpCount(parseInt(res.data.count)); - setAmount(parseInt(data)); + // setAmount(parseInt(data)); } } else { showError(res); @@ -179,12 +179,12 @@ const TopUp = () => { -
在线充值
+
在线充值,最低1