关服提示和注册

This commit is contained in:
kulawawa 2025-05-08 11:27:49 +08:00
parent 550b67bb40
commit f77b009f8d
5 changed files with 102 additions and 4 deletions

View File

@ -23,12 +23,12 @@ class GameGmController extends Controller
$param = $request->param(); // 获取请求参数 $param = $request->param(); // 获取请求参数
// 校验密码场景,验证管理员输入的 GM 操作密码是否正确 // 校验密码场景,验证管理员输入的 GM 操作密码是否正确
$validate->scene('password')->check($param) or admin_error($validate->getError()); //$validate->scene('password')->check($param) or admin_error($validate->getError());
// 验证密码是否匹配配置项中的加密密码 // 验证密码是否匹配配置项中的加密密码
if (!password_verify($param['password'], base64_decode(Config::get('game.gm.password')))) { //if (!password_verify($param['password'], base64_decode(Config::get('game.gm.password')))) {
// admin_error(lang('gm_password_error')); // admin_error(lang('gm_password_error'));
} //}
// 根据前端传入的 type 参数判断要执行的 GM 操作类型 // 根据前端传入的 type 参数判断要执行的 GM 操作类型
switch ($param['type']) { switch ($param['type']) {
@ -203,6 +203,15 @@ class GameGmController extends Controller
admin_error($e->getMessage()); admin_error($e->getMessage());
} }
break; break;
case 'closeserver':
//设置关服时间
try {
$result = $model::closeserver($param['times']); // 标识多少分钟后关闭
} catch (\Exception $e) {
admin_error($e->getMessage());
}
break;
} }
// 操作成功,统一返回成功提示;否则返回 GM 接口失败 // 操作成功,统一返回成功提示;否则返回 GM 接口失败

View File

@ -267,6 +267,20 @@
<button type="button" id="set_comment" class="btn btn-block btn-success btn-sm"> </button> <button type="button" id="set_comment" class="btn btn-block btn-success btn-sm"> </button>
</div> </div>
</div> </div>
<div class="form-group">
<label for="notice_content" class="col-sm-2 control-label">关服时间</label>
<div class="col-sm-10 col-md-4">
<input id="closetime" name="interval" value=""
placeholder="请输入关服时间(单位:分钟)" type="number" class="form-control field-text">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label"></label>
<div class="col-sm-10 col-md-4">
<button type="button" id="set_close" class="btn btn-block bg-purple btn-sm"> </button>
</div>
</div>
</div> </div>
</form> </form>

View File

@ -247,6 +247,17 @@ class GameGm extends Model
return self::apiResult($result); return self::apiResult($result);
} }
public static function closeserver($time, int $server_id=0)
{
$data = [
'sign' => self::$sign,
'server_id' => $server_id,
'time' => $time
];
$result = self::$Curl->url(self::$api_url . '/say_close?' . http_build_query($data));
return self::apiResult($result);
}
public static function get_item_list() public static function get_item_list()
{ {
$path = Env::get('config_path'); $path = Env::get('config_path');

View File

@ -0,0 +1,40 @@
<?php
// +----------------------------------------------------------------------
// | 作者:修缘 联系QQ278896498 QQ群1054861244
// | 声明:未经作者许可,禁止倒卖等商业运营,违者必究
// | 另接php业务网站制作、代理后台、gm后台、支付对接等
// +----------------------------------------------------------------------
// | 创建时间: 2022/1/6 23:52
// +----------------------------------------------------------------------
namespace app\game\controller;
use app\common\model\User;
use think\Request;
class UserController extends Controller
{
public function register(Request $request, User $model)
{
if ($request->isPost()) {
$param = $request->param();
try {
$inset = [
'account' => $param['email'],
'salt' => $param['salt'],
'password' => $param['password'],
'invite' => rand(100000,999999),
'register_time' => date("Y-m-d H:i:s",time())
];
$result = $model->insertGetId($inset);
} catch (\Exception $e) {
return error($e->getMessage());
}
return success('success');
}
}
}

View File

@ -33,7 +33,6 @@ $("#create_robot").on("click", function () {
return false; return false;
}); });
$("#clear_robot").on("click", function () { $("#clear_robot").on("click", function () {
// 通过则发起ajax请求提交表单 // 通过则发起ajax请求提交表单
$.post({ $.post({
@ -486,3 +485,28 @@ $("#inform").on("click", function () {
}); });
return false; return false;
}); });
$("#set_close").on("click", function () {
// 通过则发起ajax请求提交表单
$.post({
url: GM_URL,
data: {
type: 'closeserver',
times: $('#closetime').val(),
},
cache: false,
dataType: 'json',
success: function (result) {
if (result.code == 1) {
layer.msg(result.msg, {icon: 6});
} else {
layer.msg(result.msg, {icon: 5});
}
},
error: function () {
layer.msg('连接失败...请重试', {icon: 5});
}
});
return false;
});