StorePopimg.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * Created by PhpStorm
  4. * Author: 向往那片天空
  5. * Date: 2020/6/12
  6. * Time: 15:26
  7. * 微信/QQ: 250023777
  8. * 格言: 抓住中心,宁精勿杂,宁专勿多
  9. */
  10. namespace app\admin\controller\store;
  11. use app\admin\controller\AuthController;
  12. use app\Request;
  13. use crmeb\services\FormBuilder as Form;
  14. use crmeb\services\JsonService;
  15. use crmeb\services\UtilService;
  16. use think\facade\Db;
  17. use think\facade\Route as Url;
  18. class StorePopimg extends AuthController
  19. {
  20. public function index()
  21. {
  22. $data = Db::name('store_popimg')->where('id', 1)->find();
  23. $field = [
  24. Form::input('url', '跳转链接', $data['url']),
  25. Form::frameImageOne('img', '弹窗图片', Url::buildUrl('admin/widget.images/index', array('fodder' => 'img')), $data['img'])->icon('image')->width('100%')->height('500px'),
  26. Form::radio('is_show', '是否显示', $data['is_show'])->options([['label' => '是', 'value' => 1], ['label' => '否', 'value' => 0]]),
  27. ];
  28. $form = Form::make_post_form('设置首页弹窗图片', $field, Url::buildUrl('update', array('id' => 1)), 2);
  29. $this->assign(compact('form'));
  30. return $this->fetch('public/form-builder');
  31. }
  32. public function update(Request $request, $id)
  33. {
  34. $data = UtilService::postMore([
  35. 'url',
  36. 'is_show',
  37. ['img', []]
  38. ], $request);
  39. if (!$data['url']) return JsonService::fail('请输入跳转添加地址');
  40. if ($data['img'][0] == "") return JsonService::fail('请上传弹窗图片');
  41. $data['img'] = $data['img'][0];
  42. Db::name('store_popimg')->where('id', 1)->update($data);
  43. return JsonService::successful('修改成功!');
  44. }
  45. }