You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.6 KiB
101 lines
3.6 KiB
<?php
|
|
|
|
namespace App\Admin\Forms\v3;
|
|
|
|
use Dcat\Admin\Widgets\Form;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use App\Libs\Redis\RedisKey;
|
|
use Dcat\Admin\Contracts\LazyRenderable;
|
|
use Dcat\Admin\Traits\LazyWidget;
|
|
|
|
use function Graze\GuzzleHttp\JsonRpc\json_decode;
|
|
|
|
class OfficialSubscribeInfoForm extends Form implements LazyRenderable
|
|
{
|
|
use LazyWidget;
|
|
/**
|
|
* Handle the form request.
|
|
*
|
|
* @param array $input
|
|
*
|
|
* @return Response
|
|
*/
|
|
public function handle(array $input)
|
|
{
|
|
|
|
$subscribed = [
|
|
'head_title' => $input['head_title'],
|
|
'logo' => $input['logo'],
|
|
'title' => $input['title'],
|
|
'sub_title' => $input['sub_title'],
|
|
'redirect_url' => $input['redirect_url'],
|
|
];
|
|
$notSubscribed = [
|
|
'head_title' => $input['not_head_title'],
|
|
'logo' => $input['not_logo'],
|
|
'title' => $input['not_title'],
|
|
'sub_title' => $input['not_sub_title'],
|
|
'redirect_url' => $input['not_redirect_url'],
|
|
];
|
|
|
|
|
|
$data = [
|
|
'subscribed' => json_encode($subscribed),
|
|
'not_subscribed' => json_encode($notSubscribed)
|
|
];
|
|
|
|
$res = Redis::hmset(RedisKey::OFFICIAL_SUBSCRIBE_INFO, $data);
|
|
if($res !== false){
|
|
return $this->success('修改成功','/official_subscribe_info');
|
|
}else{
|
|
return $this->error('修改失败');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Build a form here.
|
|
*/
|
|
public function form()
|
|
{
|
|
$data = Redis::hgetall(RedisKey::OFFICIAL_SUBSCRIBE_INFO);
|
|
|
|
$subscribed = isset($data['subscribed']) ? json_decode( $data['subscribed'],true):[];
|
|
$notSubscribed = isset($data['not_subscribed']) ? json_decode( $data['not_subscribed'],true):[];
|
|
|
|
$this->column(6,function(Form $form) use($subscribed){
|
|
$this->display( 'setting', ' ')->value('已关注公众号提示信息设置');
|
|
$this->text('head_title','顶部标题')->required()->value($subscribed['head_title']);
|
|
$this->image('logo','公众号logo连接')->required()->autoUpload()->saveFullUrl()
|
|
->customFormat(function() use($subscribed){
|
|
return [$subscribed['logo']];
|
|
});
|
|
$this->text('title','公众号名称或标题')->required()->value($subscribed['title']);
|
|
$this->text('sub_title','副标题,提示语')->required()->value($subscribed['sub_title']);
|
|
$this->text('redirect_url','跳转连接')->required()->value($subscribed['redirect_url']);
|
|
});
|
|
|
|
$this->column(6,function(Form $form) use($notSubscribed){
|
|
$this->display( 'setting', ' ')->value('未关注公众号提示信息设置');
|
|
$this->text('not_head_title','顶部标题')->required()->value($notSubscribed['head_title']);
|
|
$this->image('not_logo','公众号logo连接')->required()->autoUpload()->saveFullUrl()
|
|
->customFormat(function() use($notSubscribed){
|
|
return [$notSubscribed['logo']];
|
|
});
|
|
$this->text('not_title','公众号名称或标题')->required()->value($notSubscribed['title']);
|
|
$this->text('not_sub_title','副标题,提示语')->required()->value($notSubscribed['sub_title']);
|
|
$this->text('not_redirect_url','跳转连接')->required()->value($notSubscribed['redirect_url']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* The data of the form.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function default()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
}
|