提交代码

This commit is contained in:
zpc 2025-03-20 06:25:05 +08:00
parent 66a94e6f85
commit 9a6b882a1b
4 changed files with 81 additions and 6 deletions

View File

@ -19,6 +19,7 @@ use app\common\model\UserAccount;
use app\common\model\UserLoginIp;
use think\facade\Db;
use think\helper\Str;
use app\common\server\RedisHelper;
class User extends Base
{
/**
@ -207,9 +208,11 @@ class User extends Base
*/
public function usertest(Request $request)
{
$redis = new RedisHelper();
$redis->set('test', '123');
$id = request()->post('id/d', 0);
$type = request()->post('type/d', 0);
if ($type != 1 && $type != 0) {
if ($type != 1 && $type != 0 && $type != 2) {
return $this->renderError('请求参数错误');
}
$user = UserModel::getInfo(['id' => $id]);

View File

@ -141,11 +141,20 @@
<a style="text-decoration:none" name="{$vo.nickname}"
onClick="test({$vo.id},1,this.name,'设为推广账号')"
class="layui-btn layui-btn-danger layui-btn-xs">推广账号</a>
{else /}
<a style="text-decoration:none" name="{$vo.nickname}"
onClick="test({$vo.id},2,this.name,'设为测试账号')"
class="layui-btn layui-btn-danger layui-btn-xs">测试账号</a>
{/if}
{if condition="$vo['istest'] eq 1" /}
<a style="text-decoration:none" name="{$vo.nickname}"
onClick="test({$vo.id},0,this.name,'取消推广账号')"
class="layui-btn layui-btn-success layui-btn-xs">取消推广账号</a>
{/if}
{if condition="$vo['istest'] eq 2" /}
<a style="text-decoration:none" name="{$vo.nickname}"
onClick="test({$vo.id},0,this.name,'取消测试账号')"
class="layui-btn layui-btn-success layui-btn-xs">取消测试账号</a>
{/if}
<a title="查看详情" onClick="detail({$vo.id})"
class="layui-btn layui-btn-normal layui-btn-xs">查看下级</a>
<a title="查看ip登录列表" onClick="ipdetail({$vo.id})"
@ -321,7 +330,7 @@
}
//解封/封
//删除手机
function usermobileclear(id, type, username) {
title_str = '确认要执行' + username + '的清空手机号操作吗?清空后通过手机号将搜索不到用户!同时用户需要重新绑定手机号才能抽奖!';
layer.confirm(title_str, { icon: 2, title: '清除手机号' }, function () {
@ -330,7 +339,7 @@
var $ = layui.$;
$.post(url, { "id": id }, function (data) {
if (data.status == 1) {
layer.msg(data.msg+";请手动刷新页面!", { icon: 1, time: 1000 }, function () {
layer.msg(data.msg + ";请手动刷新页面!", { icon: 1, time: 1000 }, function () {
// location.reload();
layer.close(load);
});
@ -343,7 +352,7 @@
});
}
//解封/封号
//清除微信
function userwxclear(id, type, username) {
title_str = '确认要执行' + username + '的清空微信关联数据操作吗?清空后通过微信号将关联不到此账号!微信设为新账号需要同时清除手机号操作!!!';
layer.confirm(title_str, { icon: 2, title: '清除微信号' }, function () {
@ -352,7 +361,7 @@
var $ = layui.$;
$.post(url, { "id": id }, function (data) {
if (data.status == 1) {
layer.msg(data.msg+";请手动刷新页面!", { icon: 1, time: 1000 }, function () {
layer.msg(data.msg + ";请手动刷新页面!", { icon: 1, time: 1000 }, function () {
// location.reload();
layer.close(load);
});

View File

@ -0,0 +1,55 @@
<?php
namespace app\common\server;
class RedisHelper
{
public $redis;
public function __construct()
{
$host = getenv('REDIS_HOST') ?: '127.0.0.1';
// $config = include '/../../../config/redis.php'; // 确保路径正确
$port = getenv('REDIS_PORT') ?: 6379;
$this->redis = new \Redis();
$this->connect($host, $port);
}
private function connect($host, $port)
{
$this->redis->connect($host, $port);
}
public function get($key)
{
return $this->redis->get($key);
}
public function set($key, $value, $timeout = 0)
{
if ($timeout > 0) {
return $this->redis->setex($key, $timeout, $value);
}
return $this->redis->set($key, $value);
}
public function delete($key)
{
return $this->redis->del($key);
}
public function exists($key)
{
return $this->redis->exists($key);
}
public function expire($key, $timeout)
{
return $this->redis->expire($key, $timeout);
}
}

8
app/config/redis.php Normal file
View File

@ -0,0 +1,8 @@
<?php
return [
// 默认使用的数据库连接配置
'host' => env('redis.host', '127.0.0.1'),
'port' => env('redis.port', 6379),
'password' => env('redis.password', ''),
];