|
|
|
@ -20,11 +20,24 @@ class ShareCardCreateForm extends Form |
|
|
|
public function handle(array $input) |
|
|
|
{ |
|
|
|
$list = Redis::hgetall(RedisKey::PROGRAM_SHARE_CARD); |
|
|
|
|
|
|
|
$id = count($list) + 1; |
|
|
|
if(key_exists($id,$list)){ |
|
|
|
$rand = []; |
|
|
|
for($i = 1; $i <= $id; $i++){ |
|
|
|
$rand[] = $i; |
|
|
|
} |
|
|
|
$keyExist = array_keys($list); |
|
|
|
$vacant = array_diff($rand,$keyExist); |
|
|
|
$id = array_shift($vacant) ?? time(); |
|
|
|
} |
|
|
|
$ossImageDir = config('filesystems.disks.oss.img_host'); |
|
|
|
|
|
|
|
$data = [ |
|
|
|
'id' => $id, |
|
|
|
'title' => $input['title'], |
|
|
|
'image' => $input['image'] |
|
|
|
'image' => $ossImageDir.'/'.$input['image'], |
|
|
|
'relative_path' => $input['image'], |
|
|
|
]; |
|
|
|
|
|
|
|
$data = json_encode($data); |
|
|
|
@ -33,7 +46,7 @@ class ShareCardCreateForm extends Form |
|
|
|
if($res){ |
|
|
|
return $this->success('添加成功','/share_card_setting'); |
|
|
|
}else{ |
|
|
|
return $this->error('添加失败'); |
|
|
|
return $this->error('添加失败或被替换'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -45,7 +58,7 @@ class ShareCardCreateForm extends Form |
|
|
|
$this->display('setting' , ' ')->value('小程序分享卡片设置'); |
|
|
|
|
|
|
|
$this->text('title','标题')->required(); |
|
|
|
$this->image('image','图片')->required()->autoUpload()->saveFullUrl()->width(3); |
|
|
|
$this->image('image','图片')->required()->autoUpload()->width(3); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|