From 9c5c47eb776e67618ce0b7aeb96814ab16bb8da3 Mon Sep 17 00:00:00 2001 From: youda Date: Thu, 17 Apr 2025 20:51:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 23 +++ .gitattributes | 2 + .gitignore | 1 - app/admin/controller/FloatBall.php | 138 ++++++++++++++ app/admin/route/app.php | 9 + app/admin/view/float_ball/add.html | 249 ++++++++++++++++++++++++++ app/admin/view/float_ball/edit.html | 258 +++++++++++++++++++++++++++ app/admin/view/float_ball/index.html | 166 +++++++++++++++++ app/api/controller/Index.php | 29 +++ app/api/route/app.php | 5 + app/common/model/FloatBallConfig.php | 34 ++++ config/menu.php | 4 + 12 files changed, 917 insertions(+), 1 deletion(-) create mode 100644 .env create mode 100644 .gitattributes create mode 100644 app/admin/controller/FloatBall.php create mode 100644 app/admin/view/float_ball/add.html create mode 100644 app/admin/view/float_ball/edit.html create mode 100644 app/admin/view/float_ball/index.html create mode 100644 app/common/model/FloatBallConfig.php diff --git a/.env b/.env new file mode 100644 index 0000000..d30629e --- /dev/null +++ b/.env @@ -0,0 +1,23 @@ +APP_DEBUG = false + +[APP] +DEFAULT_TIMEZONE = Asia/Shanghai + +[DATABASE] +TYPE = mysql +HOSTNAME = 127.0.0.1 +DATABASE = youda_test +USERNAME = youda_test +PASSWORD = youda_test +HOSTPORT = 3306 +CHARSET = utf8 +DEBUG = false + +[LANG] +default_lang = zh-cn + +[REDIS] +HOST = 127.0.0.1 +PORT = 6379 +PASSWORD = +DB = 3 \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f8d5590 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.env merge=ours +config/api.php merge=ours \ No newline at end of file diff --git a/.gitignore b/.gitignore index d385ba9..de53188 100755 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,4 @@ runtime/* vendor/* 404.html public/.well-known/* -.env public/ueditor/* \ No newline at end of file diff --git a/app/admin/controller/FloatBall.php b/app/admin/controller/FloatBall.php new file mode 100644 index 0000000..6a89a18 --- /dev/null +++ b/app/admin/controller/FloatBall.php @@ -0,0 +1,138 @@ +isAjax()) { + $limit = input('param.limit', 15); + $offset = input('param.offset', 0); + $where = []; + + $res = FloatBallConfig::where($where) + ->order('id', 'desc') + ->limit($offset, $limit) + ->select(); + + $total = FloatBallConfig::where($where)->count(); + + return $this->renderTable('获取成功', $total, $res, 0); + } + + return View::fetch(); + } + + /** + * 添加悬浮球配置 + */ + public function add() + { + if (request()->isPost()) { + $param = input('post.'); + $validate = $this->validate($param, [ + 'type' => 'require|number', + 'image' => 'require', + 'position_x' => 'require', + 'position_y' => 'require', + 'width' => 'require', + 'height' => 'require', + 'effect' => 'require|number', + ]); + + if (true !== $validate) { + return $this->renderError($validate); + } + + $param['status'] = isset($param['status']) ? 1 : 0; + + $res = FloatBallConfig::create($param); + if ($res) { + return $this->renderSuccess('添加成功', ['url' => (string)url('float_ball')]); + } else { + return $this->renderError('添加失败'); + } + } + + return View::fetch(); + } + + /** + * 编辑悬浮球配置 + */ + public function edit() + { + $id = input('param.id', 0); + $info = FloatBallConfig::where('id', $id)->find(); + if (empty($info)) { + return $this->renderError('数据不存在'); + } + + if (request()->isPost()) { + $param = input('post.'); + // $validate = $this->validate($param, [ + // 'type' => 'require|number', + // 'image' => 'require', + // 'position_x' => 'require', + // 'position_y' => 'require', + // 'width' => 'require', + // 'height' => 'require', + // 'effect' => 'require|number', + // ]); + + // if (true !== $validate) { + // return $this->renderError($validate); + // } + + $param['status'] = isset($param['status']) ? 1 : 0; + + $res = FloatBallConfig::update($param, ['id' => $id]); + if ($res) { + return $this->renderSuccess('编辑成功', ['url' => (string)url('float_ball')]); + } else { + return $this->renderError('编辑失败'); + } + } + + View::assign('info', $info); + return View::fetch(); + } + + /** + * 修改状态 + */ + public function status() + { + $id = input('param.id', 0); + $status = input('param.status', 0); + + $res = FloatBallConfig::update(['status' => $status], ['id' => $id]); + if ($res) { + return $this->renderSuccess('操作成功'); + } else { + return $this->renderError('操作失败'); + } + } + + /** + * 删除悬浮球配置 + */ + public function del() + { + $id = input('param.id', 0); + $res = FloatBallConfig::destroy($id); + if ($res) { + return $this->renderSuccess('删除成功'); + } else { + return $this->renderError('删除失败'); + } + } +} \ No newline at end of file diff --git a/app/admin/route/app.php b/app/admin/route/app.php index a250304..bdc14d9 100755 --- a/app/admin/route/app.php +++ b/app/admin/route/app.php @@ -377,6 +377,15 @@ Route::rule('sign_config_sort', 'SignConfig/sort', 'POST'); Route::rule('sign_config_status', 'SignConfig/status', 'POST'); Route::rule('get_coupons', 'SignConfig/getCoupons', 'GET'); +#============================ +#FloatBall.php悬浮球配置管理 +#============================ +Route::rule('float_ball', 'FloatBall/index', 'GET|POST'); +Route::rule('float_ball_add', 'FloatBall/add', 'GET|POST'); +Route::rule('float_ball_edit', 'FloatBall/edit', 'GET|POST'); +Route::rule('float_ball_del', 'FloatBall/del', 'POST'); +Route::rule('float_ball_status', 'FloatBall/status', 'POST'); + #============================ #Reward.php奖励管理 #============================ diff --git a/app/admin/view/float_ball/add.html b/app/admin/view/float_ball/add.html new file mode 100644 index 0000000..d17d27e --- /dev/null +++ b/app/admin/view/float_ball/add.html @@ -0,0 +1,249 @@ +{include file="Public/header3" /} +
+
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ + +
+
+
+ +
+ +
+ +
+ +
+
+ + +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+{include file="Public/footer3" /} + + diff --git a/app/admin/view/float_ball/edit.html b/app/admin/view/float_ball/edit.html new file mode 100644 index 0000000..e4ec18f --- /dev/null +++ b/app/admin/view/float_ball/edit.html @@ -0,0 +1,258 @@ +{include file="Public:header3"/} +
+ + +
+ +
+ + +
+
+ +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+ +
+ +
+ +
+
+ + +
+
+ +
+ +
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+
+ +
+
+
+{include file="Public/footer3" /} + + diff --git a/app/admin/view/float_ball/index.html b/app/admin/view/float_ball/index.html new file mode 100644 index 0000000..e83562b --- /dev/null +++ b/app/admin/view/float_ball/index.html @@ -0,0 +1,166 @@ +{include file="Public:header3"/} +
+
+
悬浮球配置
+
+
+
+
+ 添加 +
+
+
+
+
+
+
+ + + + + + + + + + + + +{include file="Public/footer3" /} + diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 26897c6..226d2bb 100755 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -12,6 +12,7 @@ use app\common\model\GoodsList; use app\common\model\OrderList; use app\common\model\User; use app\common\model\Yushou; +use app\common\model\FloatBallConfig; use think\facade\Db; use \think\Request; use app\common\model\Order; @@ -281,4 +282,32 @@ class Index extends Base return $this->renderSuccess('请求成功', $data); } + /** + * 获取启用的悬浮球配置 + * @return \think\response\Json + */ + public function getFloatBall() + { + // 查询状态为启用的悬浮球配置 + $floatBalls = FloatBallConfig::where('status', 1)->select(); + + // 处理图片路径 + foreach ($floatBalls as &$item) { + if (!empty($item['image'])) { + $item['image'] = imageUrl($item['image']); + } + if (!empty($item['image_details'])) { + $item['image_details'] = imageUrl($item['image_details']); + } + if (!empty($item['image_bj'])) { + $item['image_bj'] = imageUrl($item['image_bj']); + } + unset($item['status']); + unset($item['create_time']); + unset($item['update_time']); + } + + return $this->renderSuccess('获取悬浮球配置成功', $floatBalls); + } + } diff --git a/app/api/route/app.php b/app/api/route/app.php index 80ba983..23d4267 100755 --- a/app/api/route/app.php +++ b/app/api/route/app.php @@ -207,6 +207,11 @@ Route::any('getRankList', 'Index/getRankList'); Route::any('order_list', 'Order/getOrderList'); Route::any('order_detail', 'Order/getOrderDetail'); +#============================ +#FloatBall.php悬浮球 +#============================ +Route::any('getFloatBall', 'Index/getFloatBall'); + // // getUserAccount // Route::any('getUserAccount', 'User/getUserAccount'); // Route::any('createUser', 'User/createUser'); diff --git a/app/common/model/FloatBallConfig.php b/app/common/model/FloatBallConfig.php new file mode 100644 index 0000000..4d5a45c --- /dev/null +++ b/app/common/model/FloatBallConfig.php @@ -0,0 +1,34 @@ + '关闭', 1 => '开启']; + return isset($status[$data['status']]) ? $status[$data['status']] : '未知'; + } + + // 类型获取器 + public function getTypeTextAttr($value, $data) + { + $types = [1 => '展示图片', 2 => '跳转页面']; + return isset($types[$data['type']]) ? $types[$data['type']] : '未知'; + } + + // 特效获取器 + public function getEffectTextAttr($value, $data) + { + $effects = [0 => '无', 1 => '特效1']; + return isset($effects[$data['effect']]) ? $effects[$data['effect']] : '未知'; + } +} \ No newline at end of file diff --git a/config/menu.php b/config/menu.php index 9562222..fdfdc32 100755 --- a/config/menu.php +++ b/config/menu.php @@ -188,6 +188,10 @@ return [ 'url' => '/admin/advert', 'name' => 'banner图片', ], + [ + 'url' => '/admin/float_ball', + 'name' => '悬浮球管理', + ], [ 'url' => '/admin/welfare_house', 'name' => '福利屋管理',