From 18c3e95f30852c197f7a127a553715c7e3082183 Mon Sep 17 00:00:00 2001
From: ELF <360197197@qq.com>
Date: Fri, 16 Oct 2020 11:21:27 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Admin/View/TestingResource/apply.html | 36 +++++++++++++++++++
.../View/TestingResource/gameSettings.html | 19 ++++++++++
.../Admin/View/TestingResource/index.html | 13 +++++++
.../TestingResourceController.class.php | 4 +--
.../View/default/TestingResource/apply.html | 36 +++++++++++++++++++
5 files changed, 106 insertions(+), 2 deletions(-)
diff --git a/Application/Admin/View/TestingResource/apply.html b/Application/Admin/View/TestingResource/apply.html
index 494a731b6..e1d6aa86a 100644
--- a/Application/Admin/View/TestingResource/apply.html
+++ b/Application/Admin/View/TestingResource/apply.html
@@ -401,6 +401,36 @@ body {
}
})
+ function isFloat(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+(\.\d+)?$/;
+ if(!strPreg.test(num)) {
+ return false
+ }
+
+ try{
+ if(parseFloat(num) != num) {
+ return false
+ }
+ } catch(ex) {
+ return false
+ }
+ return true
+ }
+
+ function isNumber(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+$/
+ if(!strPreg.test(num)) {
+ return false
+ }
+ return true
+ }
+
function addRow() {
var remark = $('#remark-input').val()
var amount = $('#remark-amount').val()
@@ -410,6 +440,9 @@ body {
if (amount == '') {
return layer.msg('请输入资源价值')
}
+ if (!isNumber(amount)) {
+ return layer.msg('资源价值只能为正整数')
+ }
var html = '
' +
'' +
' | ' +
@@ -441,6 +474,9 @@ body {
if (num == '') {
return layer.msg('请输入资源数量')
}
+ if (!isNumber(num)) {
+ return layer.msg('资源数量只能为正整数')
+ }
var html = '
' +
'' + resourceTypeName + ' | ' +
diff --git a/Application/Admin/View/TestingResource/gameSettings.html b/Application/Admin/View/TestingResource/gameSettings.html
index 8c8be4fac..45b3c2be8 100644
--- a/Application/Admin/View/TestingResource/gameSettings.html
+++ b/Application/Admin/View/TestingResource/gameSettings.html
@@ -290,6 +290,17 @@
$(".select_gallery").select2();
});
+ function isNumber(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+$/
+ if(!strPreg.test(num)) {
+ return false
+ }
+ return true
+ }
+
$('#add-btn').click(function () {
var box = $('#add-box')
@@ -310,6 +321,14 @@
var baseGameId = box.find('[name=base_game_id]').val()
var baseQuota = box.find('[name=base_quota]').val()
var rate = box.find('[name=rate]').val()
+
+ if (!isNumber(baseQuota)) {
+ return layer.msg('初始额度只能为正整数')
+ }
+ if (!isNumber(rate)) {
+ return layer.msg('奖金池比例只能为正整数')
+ }
+
$.ajax({
url: '{:U("saveGameSetting")}',
type: 'post',
diff --git a/Application/Admin/View/TestingResource/index.html b/Application/Admin/View/TestingResource/index.html
index 1ed98ee81..d14705d1b 100644
--- a/Application/Admin/View/TestingResource/index.html
+++ b/Application/Admin/View/TestingResource/index.html
@@ -307,11 +307,24 @@
zIndex: 250,
})
})
+ function isNumber(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+$/
+ if(!strPreg.test(num)) {
+ return false
+ }
+ return true
+ }
$('.set-quota-btn').click(function () {
var box = $('#other-quota-box')
var tr = $(this).parents('tr').eq(0)
var id = tr.attr('data-id')
var otherQuota = tr.attr('data-other-quota')
+ if (!isNumber(otherQuota)) {
+ return layer.msg('额外额度只能为正整数')
+ }
box.find('[name=id]').val(id)
box.find('[name=other_quota]').val(otherQuota)
layer.open({
diff --git a/Application/Home/Controller/TestingResourceController.class.php b/Application/Home/Controller/TestingResourceController.class.php
index 94f1709b8..83fa00dcb 100644
--- a/Application/Home/Controller/TestingResourceController.class.php
+++ b/Application/Home/Controller/TestingResourceController.class.php
@@ -173,7 +173,7 @@ class TestingResourceController extends BaseController
$testingResourceService = new TestingResourceService();
$testingResourceService->apply($params, $loginPromote);
return $this->ajaxReturn(['status' => 1, 'message' => '申请成功,等待审核。']);
- } catch (\Throwable $e) {
+ } catch (\Exception $e) {
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
}
}
@@ -186,7 +186,7 @@ class TestingResourceController extends BaseController
$testingResourceService = new TestingResourceService();
$testingResourceService->bindRole($params, $loginPromote);
return $this->ajaxReturn(['status' => 1, 'message' => '绑定成功']);
- } catch (\Throwable $th) {
+ } catch (\Exception $e) {
return $this->ajaxReturn(['status' => 0, 'message' => $e->getMessage()]);
}
}
diff --git a/Application/Home/View/default/TestingResource/apply.html b/Application/Home/View/default/TestingResource/apply.html
index 258efc63f..56e488239 100644
--- a/Application/Home/View/default/TestingResource/apply.html
+++ b/Application/Home/View/default/TestingResource/apply.html
@@ -357,6 +357,36 @@
}
})
+ function isFloat(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+(\.\d+)?$/;
+ if(!strPreg.test(num)) {
+ return false
+ }
+
+ try{
+ if(parseFloat(num) != num) {
+ return false
+ }
+ } catch(ex) {
+ return false
+ }
+ return true
+ }
+
+ function isNumber(num){
+ if(!num) {
+ return false
+ }
+ var strPreg = /^\d+$/
+ if(!strPreg.test(num)) {
+ return false
+ }
+ return true
+ }
+
function addRow() {
var remark = $('#remark-input').val()
var amount = $('#remark-amount').val()
@@ -366,6 +396,9 @@
if (amount == '') {
return layer.msg('请输入资源价值')
}
+ if (!isNumber(amount)) {
+ return layer.msg('资源价值只能为正整数')
+ }
var html = '
' +
'' +
' | ' +
@@ -397,6 +430,9 @@
if (num == '') {
return layer.msg('请输入资源数量')
}
+ if (!isNumber(num)) {
+ return layer.msg('资源数量只能为正整数')
+ }
var html = '
' +
'' + resourceTypeName + ' | ' +