first commit
This commit is contained in:
118
application/adminghd/controller/Files.php
Normal file
118
application/adminghd/controller/Files.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
//use think\Db;
|
||||
//use think\Log;
|
||||
//use think\Image;
|
||||
use think\Response;
|
||||
/**
|
||||
*上传文件
|
||||
*/
|
||||
class Files extends Base
|
||||
{
|
||||
/**
|
||||
*上传图片
|
||||
*@param
|
||||
*/
|
||||
public function uploadImg(Request $request)
|
||||
{
|
||||
$typeArr = array("jpg","png",'jpeg');//图片类型
|
||||
$path = "uploads/" . date('Y/m/d/');//上传路径
|
||||
if(!file_exists($path)){
|
||||
//创建文件
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
if ($_FILES) {
|
||||
$name = $_FILES['file']['name'];
|
||||
$size = $_FILES['file']['size'];
|
||||
$name_tmp = $_FILES['file']['tmp_name'];
|
||||
if (empty($name)) {
|
||||
return json(array("status"=>"-1","error"=>"图片不能为空"));
|
||||
exit;
|
||||
}
|
||||
$type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型
|
||||
|
||||
if (!in_array($type, $typeArr)) {
|
||||
return json(array("status"=>"-1","error"=>"请上传jpg,png,或jpeg类型的文件!"));//mov,webm
|
||||
exit;
|
||||
}
|
||||
if ($size > (2 * 1024 * 1024)) {
|
||||
return json(array("status"=>"-1","error"=>"文件大小已超过2MB!"));
|
||||
exit;
|
||||
}
|
||||
|
||||
/* if($_GET['type'] == 'cx'){
|
||||
$imageType = 'cx';
|
||||
}*/
|
||||
$imageType='';
|
||||
$pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称
|
||||
$pic_url =$path . $pic_name;//上传后图片路径+名称
|
||||
|
||||
if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹
|
||||
/* $_POST['name'] = $pic_name;
|
||||
$_POST['topic'] = $imageType;
|
||||
$_POST['albumPath'] = $pic_url;*/
|
||||
return json(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url));
|
||||
die();
|
||||
} else {
|
||||
return json(array("status"=>"-1","error"=>"上传有误,请检查服务器配置!"));
|
||||
die();
|
||||
}
|
||||
}else{
|
||||
return json(array("status"=>"-1","error"=>"系统错误!"));
|
||||
die();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*上传视频
|
||||
*/
|
||||
public function uploadVideo(Request $request){
|
||||
$typeArr = array("mp4","wkv");//官方推荐 mp4
|
||||
$path = "uploadnv/" . date('Y/m/d/');//上传路径
|
||||
if(!file_exists($path)){
|
||||
//创建文件
|
||||
mkdir($path,0777,true);
|
||||
}
|
||||
// if ($_FILES) {
|
||||
$name = $_FILES['file']['name'];
|
||||
$size = $_FILES['file']['size'];
|
||||
$name_tmp = $_FILES['file']['tmp_name'];
|
||||
if (empty($name)) {
|
||||
// return json_encode(['status'=>0,'msg'=>'查询失败']);
|
||||
echo json_encode(array("error"=>"您还未选择文件"));
|
||||
exit;
|
||||
}
|
||||
$type = strtolower(substr(strrchr($name, '.'), 1)); //获取文件类型
|
||||
|
||||
if (!in_array($type, $typeArr)) {
|
||||
echo json_encode(array("error"=>"请上传mp4,wkv类型的文件!"));//mov,webm
|
||||
exit;
|
||||
}
|
||||
if ($size > (15 * 1024 * 1024)) {
|
||||
echo json_encode(array("error"=>"文件大小已超过30MB!"));
|
||||
exit;
|
||||
}
|
||||
|
||||
/* if($_GET['type'] == 'cx'){
|
||||
$imageType = 'cx';
|
||||
}*/
|
||||
$imageType='';
|
||||
$pic_name = $imageType.time() . rand(10000, 99999) . "." . $type;//图片名称
|
||||
$pic_url =$path . $pic_name;//上传后图片路径+名称
|
||||
|
||||
if (move_uploaded_file($name_tmp, $pic_url)) { //临时文件转移到目标文件夹
|
||||
/* $_POST['name'] = $pic_name;
|
||||
$_POST['topic'] = $imageType;
|
||||
$_POST['albumPath'] = $pic_url;*/
|
||||
echo json_encode(array("status"=>"0","file_name"=>$pic_name,"file_path"=>$request->domain().'/'.$pic_url));
|
||||
die();
|
||||
} else {
|
||||
echo json_encode(array("error"=>"上传有误,请检查服务器配置!"));
|
||||
die();
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
196
application/adminghd/controller/Index.php
Normal file
196
application/adminghd/controller/Index.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
//use think\Log;
|
||||
class Menu extends Base
|
||||
{
|
||||
/**
|
||||
*初始化
|
||||
*/
|
||||
protected function _initialize(){
|
||||
parent::_initialize();
|
||||
if(session('admin_user_type') != 1){
|
||||
$result['erro']=-1;
|
||||
$result['msg']='权限不足';
|
||||
Response::create($result,'json')->send();
|
||||
exit;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getMenuList(Request $request){
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result = Db::name('menu')
|
||||
->field('id,pid,menu_name,url,seq_on,menu_icon')
|
||||
->order('seq_on')
|
||||
->select();
|
||||
//找二级菜单
|
||||
$second=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != ''){
|
||||
//二级
|
||||
$second[]=$value;
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
$result=array_values($result);
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['type']=1;
|
||||
$result[$key]['No']=$key+1;
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['menu_id']==$v['pid']){
|
||||
$v['type']=2;
|
||||
$result[$key]['children'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]);
|
||||
}
|
||||
/**
|
||||
* 权限菜单列表
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getPermissionMenu(Request $request){
|
||||
$data=$request->param();
|
||||
//$this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select();
|
||||
//找二级三级菜单
|
||||
$second=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != ''){
|
||||
$second[]=$value;
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['type']=1;
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['menu_id']==$v['pid']){
|
||||
$v['type']=2;
|
||||
$result[$key]['second'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]);
|
||||
}
|
||||
|
||||
public function getMenuOption(Request $request){
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result = Db::name('menu')
|
||||
->field('id,pid,menu_name')
|
||||
//->where('status',0)
|
||||
->order('seq_on')
|
||||
->select();
|
||||
//找二级三级菜单
|
||||
$second=[];
|
||||
// $third=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != ''){
|
||||
//二级
|
||||
$second[$key]['value']=$value['id'];
|
||||
$second[$key]['label']=$value['menu_name'];
|
||||
$second[$key]['pid']=$value['pid'];
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
$first=[];
|
||||
foreach ($result as $key => $value) {
|
||||
$first[$key]['value']=$value['id'];
|
||||
$first[$key]['label']=$value['menu_name'];
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['menu_id']==$v['pid']){
|
||||
unset($v['pid']);
|
||||
$first[$key]['children'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($first){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$first]);
|
||||
}
|
||||
//获取当前菜单最大序号
|
||||
public function getMaxSeq($map){
|
||||
$result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find();
|
||||
if($result){
|
||||
return $result['seq_on']+1;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//添加菜单
|
||||
public function doaddMenu(Request $request){
|
||||
//获取一下表单提交的数据,并保存在变量中
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
unset($data['Token']);
|
||||
$menu_id=md5(uniqid(''));//一级菜单id
|
||||
$create_time=date('Y-m-d H:i:s');//插入时间
|
||||
$data1=[];
|
||||
//添加一级菜单
|
||||
if(empty($data['father'])){
|
||||
$map['pid']='';
|
||||
}else{
|
||||
$map['pid']=$data['father'];
|
||||
}
|
||||
//获取一级菜单最大序号
|
||||
$seq_on=$this->getMaxSeq($map);
|
||||
$data1=$map;
|
||||
if(!empty($data['urs'])){
|
||||
$data1['url']=$data['url'];
|
||||
}
|
||||
if(!empty($data['menu_icon'])){
|
||||
$data1['menu_icon']=$data['menu_icon'];
|
||||
}
|
||||
$data1['id']=$menu_id;
|
||||
$data1['menu_name']=$data['title'];
|
||||
$data1['seq_on']=$seq_on;
|
||||
$data1['create_time']=$create_time;
|
||||
$res=Db::name('menu')->insert($data1);
|
||||
if($res){
|
||||
$status=1;
|
||||
$msg='添加菜单成功!!';
|
||||
}else{
|
||||
$status=0;
|
||||
$msg='添加菜单失败!!';
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg]);
|
||||
}
|
||||
}
|
||||
92
application/adminghd/controller/Login.php
Normal file
92
application/adminghd/controller/Login.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
// use app\admin\model\Admin;
|
||||
use think\Session;
|
||||
use think\Db;
|
||||
use think\Controller;
|
||||
|
||||
class Login extends Controller{
|
||||
/**
|
||||
* 渲染登陆界面
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
if(!session('adminghd_user_id')){//没有登录信息
|
||||
return $this->view->fetch('login');
|
||||
}else{
|
||||
//登录信息超时
|
||||
$log_time=session('adminghd_user_login_time')-time();
|
||||
if($log_time < 0){
|
||||
return $this->view->fetch('login');
|
||||
}
|
||||
}
|
||||
return $this->view->fetch('nav');
|
||||
}
|
||||
/**
|
||||
* 验证用户身份.
|
||||
*
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
//判断是否是post方法发送的数据:如果是则开始登陆
|
||||
if(Request::instance()->isPost()){
|
||||
$user_name=Request::instance()->param("username");
|
||||
$password=Request::instance()->param('password');
|
||||
if(empty($user_name) || empty($password)){
|
||||
$result=['status'=>0,'msg'=>'用户名或密码为空'];
|
||||
return json($result);
|
||||
}
|
||||
//数据查询
|
||||
$infor=Db::name("user")
|
||||
->field('id,user_name,user_head')
|
||||
->where('phone',$user_name)
|
||||
->where('password',md5($password))
|
||||
->where("status",1)
|
||||
->where('type',1)
|
||||
->find();
|
||||
if(empty($infor)){
|
||||
$result=['status'=>0,'msg'=>'用户不存在或密码不正确'];
|
||||
}else{
|
||||
//Session::set('admin_user_type',$infor['role_id']);
|
||||
Session::set('adminghd_user_id',$infor['id']);
|
||||
//Session::set('admin_mechanism_id',$infor['mechanism_id']);
|
||||
$time_out=time()+3600;
|
||||
Session::set('adminghd_user_login_time',$time_out);
|
||||
$result=['status'=>1,'msg'=>'登录成功','token'=>1];
|
||||
}
|
||||
return json($result);
|
||||
}
|
||||
//如果不是post,则返回登陆界面
|
||||
else{
|
||||
$result=['status'=>0,'msg'=>'未获取到参数'];
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function logout(Request $request)
|
||||
{
|
||||
Session::clear();
|
||||
return json(['status'=>1,'msg'=>'退出成功']);
|
||||
}
|
||||
/**
|
||||
* 超时登录推出跳转页面
|
||||
*
|
||||
* @param \think\Request $request
|
||||
* @return \think\Response
|
||||
*/
|
||||
public function logoutJump(Request $request)
|
||||
{
|
||||
return $this->view->fetch('logoutJump');
|
||||
}
|
||||
}
|
||||
325
application/adminghd/controller/Menu.php
Normal file
325
application/adminghd/controller/Menu.php
Normal file
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
//use think\Log;
|
||||
|
||||
class Menu extends Base
|
||||
{
|
||||
/**
|
||||
*初始化
|
||||
*/
|
||||
protected function _initialize(){
|
||||
/* parent::_initialize();
|
||||
if(session('admin_user_type') != 1){
|
||||
$result['erro']=-1;
|
||||
$result['msg']='权限不足';
|
||||
Response::create($result,'json')->send();
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
// $this->alreadyLogin();
|
||||
return $this->view->fetch('index');
|
||||
}
|
||||
public function nav()
|
||||
{
|
||||
// $this->alreadyLogin();
|
||||
return $this->view->fetch('nav');
|
||||
}
|
||||
public function getUserInfor(){
|
||||
$data=Db::name("user")
|
||||
->field('user_name,user_head')
|
||||
->where('id',session('admin_user_id'))
|
||||
->find();
|
||||
$result=['status'=>1,'msg'=>'查询成功','infro'=>$data];
|
||||
return json($result);
|
||||
}
|
||||
/**
|
||||
* 获取菜单列表
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getMenuList(Request $request){
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result = Db::name('menu')
|
||||
->field('id,pid,menu_name,url,seq_on,menu_icon')
|
||||
->order('seq_on')
|
||||
->select();
|
||||
//找二级菜单
|
||||
$second=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != '' && $value['pid'] != 0){
|
||||
//二级
|
||||
$value['grade']="二级菜单";
|
||||
$second[]=$value;
|
||||
unset($result[$key]);
|
||||
}else{
|
||||
$result[$key]['grade']="一级菜单";
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
$result=array_values($result);
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['type']=1;
|
||||
$result[$key]['No']=$key+1;
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['id']==$v['pid']){
|
||||
$v['type']=2;
|
||||
$result[$key]['children'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json(['status'=>$status,'msg'=>$msg,'data'=>$result]);
|
||||
}
|
||||
/**
|
||||
* 权限菜单列表
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getPermissionMenu(Request $request){
|
||||
$data=$request->param();
|
||||
//$this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result=Db::name('menu')->field('id,pid,menu_name,url,seq_on,menu_icon')->order('seq_on')->select();
|
||||
//找二级三级菜单
|
||||
$second=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != ''){
|
||||
$second[]=$value;
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
foreach ($result as $key => $value) {
|
||||
$result[$key]['type']=1;
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['menu_id']==$v['pid']){
|
||||
$v['type']=2;
|
||||
$result[$key]['second'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($result){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json(['status'=>$status,'msg'=>$msg,'data'=>$result]);
|
||||
}
|
||||
|
||||
public function getMenuOption(Request $request){
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
//升序获取菜单列表
|
||||
$result = Db::name('menu')
|
||||
->field('id,pid,menu_name')
|
||||
//->where('status',0)
|
||||
->order('seq_on')
|
||||
->select();
|
||||
//找二级三级菜单
|
||||
$second=[];
|
||||
// $third=[];
|
||||
foreach ($result as $key => $value) {
|
||||
if($value['pid'] != ''){
|
||||
//二级
|
||||
$second[$key]['value']=$value['id'];
|
||||
$second[$key]['label']=$value['menu_name'];
|
||||
$second[$key]['pid']=$value['pid'];
|
||||
unset($result[$key]);
|
||||
}
|
||||
}
|
||||
//二级组装到一级
|
||||
$first=[];
|
||||
foreach ($result as $key => $value) {
|
||||
$first[$key]['value']=$value['id'];
|
||||
$first[$key]['label']=$value['menu_name'];
|
||||
foreach ($second as $k => $v) {
|
||||
if($value['menu_id']==$v['pid']){
|
||||
unset($v['pid']);
|
||||
$first[$key]['children'][]=$v;
|
||||
}
|
||||
}
|
||||
}
|
||||
if($first){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}
|
||||
else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json(['status'=>$status,'msg'=>$msg,'data'=>$first]);
|
||||
}
|
||||
//获取当前菜单最大序号
|
||||
public function getMaxSeq($map){
|
||||
$result=Db::name('menu')->field('seq_on')->where($map)->order('seq_on','desc')->find();
|
||||
if($result){
|
||||
return $result['seq_on']+1;
|
||||
}else{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
//添加菜单
|
||||
public function doaddMenu(Request $request){
|
||||
//获取一下表单提交的数据,并保存在变量中
|
||||
$data=$request->param();
|
||||
// $this->checkToken($data['Token']);
|
||||
unset($data['Token']);
|
||||
$menu_id=md5(uniqid(''));//一级菜单id
|
||||
$create_time=date('Y-m-d H:i:s');//插入时间
|
||||
$data1=[];
|
||||
//添加一级菜单
|
||||
if(empty($data['father'])){
|
||||
$map['pid']='';
|
||||
}else{
|
||||
$map['pid']=$data['father'];
|
||||
}
|
||||
//获取一级菜单最大序号
|
||||
$seq_on=$this->getMaxSeq($map);
|
||||
$data1=$map;
|
||||
if(!empty($data['urs'])){
|
||||
$data1['url']=$data['url'];
|
||||
}
|
||||
if(!empty($data['menu_icon'])){
|
||||
$data1['menu_icon']=$data['menu_icon'];
|
||||
}
|
||||
$data1['id']=$menu_id;
|
||||
$data1['menu_name']=$data['title'];
|
||||
$data1['seq_on']=$seq_on;
|
||||
$data1['create_time']=$create_time;
|
||||
$res=Db::name('menu')->insert($data1);
|
||||
if($res){
|
||||
$status=1;
|
||||
$msg='添加菜单成功!!';
|
||||
}else{
|
||||
$status=0;
|
||||
$msg='添加菜单失败!!';
|
||||
}
|
||||
return json(['status'=>$status,'msg'=>$msg]);
|
||||
}
|
||||
/**
|
||||
* 修改菜单详情
|
||||
* @param $data 菜单id(一级菜单、二级菜单)
|
||||
* @param $data 菜单详情
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function updMenu(Request $request){
|
||||
$data=$request->param();
|
||||
$result=Db::name('menu')->field('id,pid,menu_name,url,menu_icon')->where('menu_id',$data['menu_id'])->find();
|
||||
$result['type']=1;
|
||||
if(!empty($result['pid'])){
|
||||
$result['type']=2;
|
||||
$result['father']=$result['pid'];
|
||||
}
|
||||
unset($result['pid']);
|
||||
if($result){
|
||||
$status=1;
|
||||
$msg="获取数据成功!!";
|
||||
}else{
|
||||
$status=0;
|
||||
$msg="获取数据失败!!";
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg,'data'=>$result]);
|
||||
}
|
||||
public function doupdMenu(Request $request){
|
||||
$data=$request->param();
|
||||
$data1=[];
|
||||
//添加一级菜单
|
||||
if(empty($data['father'])){
|
||||
$data1['pid']='';
|
||||
if(!empty($data['menu_icon'])){
|
||||
$data1['menu_icon']=$data['menu_icon'];
|
||||
}
|
||||
}else{
|
||||
$data1['pid']=$data['father'];
|
||||
//获取一级菜单最大序号
|
||||
if(!empty($data['url'])){
|
||||
$data1['url']=$data['url'];
|
||||
}
|
||||
}
|
||||
$data1['menu_name']=$data['menu_name'];
|
||||
$res=Db::name('menu')->where('id',$data['id'])->update($data1);
|
||||
if($res){
|
||||
$status=1;
|
||||
$msg='修改菜单成功!!';
|
||||
}else{
|
||||
$status=0;
|
||||
$msg='修改菜单失败!!';
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg]);
|
||||
}
|
||||
/**
|
||||
* 设置菜单状态
|
||||
* @param $data 一级菜单id、二级菜单id
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function setMenuStatus(Request $request){
|
||||
$data=$request->param();
|
||||
$this->checkToken($data['Token']);
|
||||
$res=Db::name('menu')->where('id',$data['id'])->update(['status'=>$data['status']]);
|
||||
if($res){
|
||||
$status=1;
|
||||
$msg='设置成功!!';
|
||||
}else{
|
||||
$status=0;
|
||||
$msg='设置失败!!';
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg]);
|
||||
}
|
||||
/**
|
||||
* 删除菜单
|
||||
* @param $data 一级菜单id、二级菜单id
|
||||
*@author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function delMenu(Request $request){
|
||||
$data=$request->param();
|
||||
$res=Db::name('menu')->where('id',$data['id'])->find();
|
||||
//一级菜单
|
||||
if($res['pid']==''){
|
||||
$map1['id|pid']=$data['id'];
|
||||
$map2['id']=['in',[$data['id'],$res['pid']]];
|
||||
}else{
|
||||
$map1['id']=$data['id'];
|
||||
$map2['id']=$data['id'];
|
||||
}
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try{
|
||||
//删除二级菜单
|
||||
Db::name('menu')->where($map1)->delete();
|
||||
// Db::table('t_nv_role_menu')->where($map2)->delete();
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
$status=1;
|
||||
$msg='删除菜单成功!!';
|
||||
} catch (\Exception $e) {
|
||||
Log::record($e->getMessage(),'error');
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
$status=0;
|
||||
$msg='删除菜单失败!!';
|
||||
}
|
||||
return json_encode(['status'=>$status,'msg'=>$msg]);
|
||||
}
|
||||
}
|
||||
105
application/adminghd/controller/Wechatinfro.php
Normal file
105
application/adminghd/controller/Wechatinfro.php
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
//use think\Log;
|
||||
|
||||
|
||||
class Wechatinfro extends Base
|
||||
{
|
||||
/**
|
||||
*初始化
|
||||
*/
|
||||
protected function _initialize(){
|
||||
parent::_initialize();
|
||||
/*if(session('admin_user_type') != 1){
|
||||
$result['erro']=-1;
|
||||
$result['msg']='权限不足';
|
||||
Response::create($result,'json')->send();
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
public function wechatUserList()
|
||||
{
|
||||
return $this->view->fetch('userList');
|
||||
}
|
||||
/**
|
||||
* 查看小程序注册用户信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatUserList(Request $request){
|
||||
$post=$request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数
|
||||
//搜索
|
||||
$where=[];
|
||||
if(isset($post['title']) && !empty($post['title'])){
|
||||
$where['nickname']=['like','%'.$post['title'].'%'];
|
||||
}
|
||||
//升序获取菜单列表
|
||||
$res = Db::name('ghd_wechat_user')
|
||||
->field('uid,nickname,headimg,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size,false,['page'=>$page]);
|
||||
|
||||
$lists=$res->items();
|
||||
$start=($page-1)*$page_size;
|
||||
foreach($lists as $k=>$v){
|
||||
$start+=1;
|
||||
$lists[$k]['no_id']=$start;
|
||||
}
|
||||
$result['lists'] =$lists;
|
||||
$result['lastPage'] = $res->lastPage();//总页数
|
||||
$result['currentPage'] = $res->currentPage();//当前页
|
||||
// $result['total'] = $res->total();//数据总条数
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
public function wechatRecordList()
|
||||
{
|
||||
return $this->view->fetch('wechatRecordList');
|
||||
}
|
||||
/**
|
||||
* 查看小程序记录
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatRecordList(Request $request){
|
||||
$post=$request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数
|
||||
//搜索
|
||||
$where=[];
|
||||
if(isset($post['title']) && !empty($post['title'])){
|
||||
$where['name']=['like','%'.$post['title'].'%'];
|
||||
}
|
||||
// 查询列表
|
||||
$res = Db::name('wechat_calculate_record')
|
||||
->field('id,name,age,height,bone_age,father_height,mother_height,IGF,LH,uterus_thickness,calculate_resutlt,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size,false,['page'=>$page]);
|
||||
$lists=$res->items();
|
||||
$start=($page-1)*$page_size;
|
||||
foreach($lists as $k=>$v){
|
||||
$start+=1;
|
||||
$lists[$k]['no_id']=$start;
|
||||
}
|
||||
$result = array();
|
||||
$result['lists'] =$lists;
|
||||
$result['lastPage'] = $res->lastPage();//总页数
|
||||
$result['currentPage'] = $res->currentPage();//当前页
|
||||
// $result['total'] = $res->total();//数据总条数
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
182
application/adminghd/controller/Wechatset.php
Normal file
182
application/adminghd/controller/Wechatset.php
Normal file
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
|
||||
namespace app\adminghd\controller;
|
||||
|
||||
use app\adminghd\common\Base;
|
||||
use think\Request;
|
||||
use think\Db;
|
||||
//use think\Log;
|
||||
|
||||
|
||||
class Wechatset extends Base
|
||||
{
|
||||
/**
|
||||
*初始化
|
||||
*/
|
||||
protected function _initialize(){
|
||||
parent::_initialize();
|
||||
/*if(session('admin_user_type') != 1){
|
||||
$result['erro']=-1;
|
||||
$result['msg']='权限不足';
|
||||
Response::create($result,'json')->send();
|
||||
exit;
|
||||
}*/
|
||||
}
|
||||
/**
|
||||
* 小程序资讯信息页面
|
||||
*/
|
||||
public function wechatRealTimeInfo()
|
||||
{
|
||||
return $this->view->fetch('realTimeInfo');
|
||||
}
|
||||
/**
|
||||
* 小程序添加资讯信息页面
|
||||
*/
|
||||
public function wechatRealTimeInfoAdd()
|
||||
{
|
||||
return $this->view->fetch('realTimeInfoAdd');
|
||||
}
|
||||
/**
|
||||
* 小程序添加资讯信息页面
|
||||
*/
|
||||
public function wechatRealTimeInfoUpdate(Request $request)
|
||||
{
|
||||
$id=$request->get('id');
|
||||
$this->assign('id',$id);
|
||||
return $this->view->fetch('realTimeInfoUpdate');
|
||||
}
|
||||
/**
|
||||
* 查询小程序资讯信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function getWechatRealTimeInfoList(Request $request){
|
||||
$post=$request->param();
|
||||
|
||||
$page = isset($post['page']) && !empty($post['page']) ? $post['page'] : 1;//页数
|
||||
$page_size = isset($post['page_size']) && !empty($post['page_size']) ? $post['page_size'] : 30;//每页条数
|
||||
//搜索
|
||||
$where=[];
|
||||
if(isset($post['title']) && !empty($post['title'])){
|
||||
$where['title_plain']=['like','%'.$post['title'].'%'];
|
||||
}
|
||||
//升序获取菜单列表
|
||||
$res = Db::name('wechat_real_time_info')
|
||||
->field('id,title_plain,thumbnail,excerpt_plain,url,create_time')
|
||||
->where($where)
|
||||
->order('create_time desc')
|
||||
->paginate($page_size,false,['page'=>$page]);
|
||||
$lists=$res->items();
|
||||
$start=($page-1)*$page_size;
|
||||
foreach($lists as $k=>$v){
|
||||
$start+=1;
|
||||
$lists[$k]['no_id']=$start;
|
||||
}
|
||||
$result['lists'] =$lists;
|
||||
$result['lastPage'] = $res->lastPage();//总页数
|
||||
$result['currentPage'] = $res->currentPage();//当前页
|
||||
// $result['total'] = $res->total();//数据总条数
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '查询成功';
|
||||
return json($result);
|
||||
}
|
||||
public function wechatRecordList()
|
||||
{
|
||||
return $this->view->fetch('wechatRecordList');
|
||||
}
|
||||
/**
|
||||
* 删除小程序资讯信息
|
||||
* @author hjc
|
||||
* @date 2024-05-14
|
||||
*/
|
||||
public function delWechatRealTimeInfo(Request $request){
|
||||
$post=$request->param();
|
||||
if(!isset($post['id']) || empty($post['id']) ){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "请选择要删除的记录";
|
||||
return json($result);
|
||||
}
|
||||
$id=Db::name('wechat_real_time_info')->where('id',$post['id'])->value('id');
|
||||
if(empty($id)){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "该记录异常,无法删除";
|
||||
return json($result);
|
||||
}
|
||||
$res=Db::name('wechat_real_time_info')->where('id',$id)->delete();
|
||||
if($res > 0){
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = '删除成功';
|
||||
}else{
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = '删除失败';
|
||||
}
|
||||
return json($result);
|
||||
}
|
||||
/***
|
||||
*保存小程序资讯信息
|
||||
**/
|
||||
public function saveWechatRealTimeInfo(Request $request){
|
||||
$post=$request->param();
|
||||
|
||||
if(!isset($post['title_plain']) || empty($post['title_plain']) ){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入标题";
|
||||
return json($result);
|
||||
}
|
||||
if(!isset($post['thumbnail']) || empty($post['thumbnail']) ){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入图片";
|
||||
return json($result);
|
||||
}
|
||||
if(!isset($post['excerpt_plain']) || empty($post['excerpt_plain']) ){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入简介";
|
||||
return json($result);
|
||||
}
|
||||
if(!isset($post['url']) || empty($post['url'])){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入资讯跳转链接";
|
||||
return json($result);
|
||||
}
|
||||
//提交数据
|
||||
$data=[];
|
||||
$data['title_plain']=$post['title_plain'];//标题
|
||||
$data['thumbnail']=$post['thumbnail'];//图片
|
||||
$data['excerpt_plain']=$post['excerpt_plain'];//介绍
|
||||
$data['url']=$post['url'];//跳转连接
|
||||
if(isset($post['id']) && !empty($post['id'])){
|
||||
//修改数据
|
||||
$res=Db::name('wechat_real_time_info')->where('id',$post['id'])->update($data);
|
||||
}else{
|
||||
//保存记录数据
|
||||
$data['id']=md5(time().rand(100000,999999));
|
||||
$data['create_time']=date('Y-m-d H:i:s');
|
||||
$res=Db::name('wechat_real_time_info')->insert($data);
|
||||
}
|
||||
if($res===false){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "添加失败";
|
||||
return json($result);
|
||||
}else{
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = "添加成功";
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
/**
|
||||
*查询资讯信息详情
|
||||
*/
|
||||
public function getRealTimeInfoDetail(Request $request){
|
||||
$post=$request->param();
|
||||
if(!isset($post['id']) || empty($post['id'])){
|
||||
$result['erro'] = -1;
|
||||
$result['msg'] = "未传入资讯id";
|
||||
return json($result);
|
||||
}
|
||||
//修改数据
|
||||
$result['infro']=Db::name('wechat_real_time_info')->where('id',$post['id'])->find();
|
||||
$result['erro'] = 0;
|
||||
$result['msg'] = "查询成功";
|
||||
return json($result);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user