SmmAddAccount.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace App\Distributor\Forms;
  3. use App\Distributor\Repositories\DistProductCategory;
  4. use App\Distributor\Repositories\RpcAlbum;
  5. use App\Libraries\CommonHelper;
  6. use App\Models\DistProduct;
  7. use App\Models\DistProductImage;
  8. use Dcat\Admin\Widgets\Form;
  9. class SmmAddAccount extends Form
  10. {
  11. public function handle(array $input)
  12. {
  13. // 处理表单提交逻辑
  14. $mediaName = $input['media_name'];
  15. if ($mediaName) {
  16. //跳转到媒体受权页面
  17. $url = CommonHelper::albumUrl($mediaName);
  18. // 返回 JS 代码触发新窗口打开
  19. return $this->response()->script(
  20. "window.open('{$url}', '_blank')"
  21. );
  22. } else {
  23. return $this
  24. ->response()
  25. ->error('媒体名称不能为空');
  26. }
  27. }
  28. /**
  29. * Build a form here.
  30. */
  31. public function form()
  32. {
  33. // 设置隐藏表单,传递用户id
  34. $this->select('media_name')
  35. ->options(config('dictionary.media_list'))
  36. ->required();
  37. }
  38. /**
  39. * The data of the form.
  40. *
  41. * @return array
  42. */
  43. public function default()
  44. {
  45. return [];
  46. }
  47. }