4 changed files with 112 additions and 1 deletions
-
9app/Admin/Controllers/v3/SystemConfigController.php
-
100app/Admin/Forms/v3/OfficialSubscribeInfoForm.php
-
2app/Admin/routes.php
-
2app/Libs/Redis/RedisKey.php
@ -0,0 +1,100 @@ |
|||||
|
<?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::PROGRAM_SHARE_CARD, $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','顶部标题')->value($subscribed['head_title']); |
||||
|
$this->image('logo','公众号logo连接')->autoUpload()->saveFullUrl() |
||||
|
->customFormat(function() use($subscribed){ |
||||
|
return [$subscribed['logo']]; |
||||
|
}); |
||||
|
$this->text('title','公众号名称或标题')->value($subscribed['title']); |
||||
|
$this->text('sub_title','副标题,提示语')->value($subscribed['sub_title']); |
||||
|
$this->text('redirect_url','跳转连接')->value($subscribed['redirect_url']); |
||||
|
}); |
||||
|
|
||||
|
$this->column(6,function(Form $form) use($notSubscribed){ |
||||
|
$this->display( 'setting', ' ')->value('未关注公众号提示信息设置'); |
||||
|
$this->text('not_head_title','顶部标题')->value($notSubscribed['head_title']); |
||||
|
$this->image('not_logo','公众号logo连接')->autoUpload()->saveFullUrl() |
||||
|
->customFormat(function() use($notSubscribed){ |
||||
|
return [$notSubscribed['logo']]; |
||||
|
}); |
||||
|
$this->text('not_title','公众号名称或标题')->value($notSubscribed['title']); |
||||
|
$this->text('not_sub_title','副标题,提示语')->value($notSubscribed['sub_title']); |
||||
|
$this->text('not_redirect_url','跳转连接')->value($notSubscribed['redirect_url']); |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* The data of the form. |
||||
|
* |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function default() |
||||
|
{ |
||||
|
return []; |
||||
|
} |
||||
|
|
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue