public function addinfo(){


$info = request()->param();
if(strlen($info['name'])>30){
$this->error('新增失败,活动名字过长');
}
// print_r($_FILES);die();
if($_FILES['image']['size']>2097152){
$this->error('新增失败,图片过大');
}
$fileurl = Images:: fileImg('image',$path='uploads/image');
// print_r($fileurl);die();
$data['image'] = 'https://'.$_SERVER['SERVER_NAME'].'/'.$fileurl['img'];
$data['name'] = $info['name'];
$data['type'] = $info['type'];
$data['money'] = $info['money'];
$data['number'] = $info['number'];
$data['remark'] = $info['remark'];
$data['ctime'] =time();
// print_r($data);exit;

$res = Db::name('activity')->insertGetId($data);
if($res){
//return json(['code'=>'1','msg'=>'添加成功']);
if($info['type'] == 0){
$this->success('新增成功', 'activity/onelist','',1);
}else{
$this->success('新增成功', 'activity/twolist','',1);
}


}else{
//return json(['code'=>'0','msg'=>'添加失败']);
$this->error('新增失败');
}
}

/*************************************************
* @cjw
* @DateTime 2021-04-08
* Function: fileImg
* Description: 上传服务图片
*************************************************/
static public function fileImg($name,$path='uploads/image')
{
$file = request()->file($name);
//上传到目录为public/uploads下

$info = $file->rule('uniqid')->move($path);
// print_r($info);die();

if ($info) {
//获取到上传图片的路径名称
$name_img = $path .'/'.$info->getFilename();
$msg = '上传文件成功';
} else {
$name_img = '';
$msg = $file->getError();
}
return ['code' => 1, 'msg' => $msg, 'img' => $name_img];

}