UserCert.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /**
  3. *
  4. * @author: wuhaotian<442384644@qq.com>
  5. * @day: 2019/12/07
  6. */
  7. namespace app\admin\controller\user;
  8. use app\admin\controller\AuthController;
  9. use app\models\user\Cert;
  10. use crmeb\services\JsonService;
  11. use crmeb\services\UtilService;
  12. use crmeb\services\FormBuilder as Form;
  13. use think\facade\Route as Url;
  14. /**
  15. * Class UserGroup
  16. * @package app\admin\controller\user
  17. */
  18. class UserCert extends AuthController
  19. {
  20. /**
  21. * 会员分组页面
  22. * @return string
  23. */
  24. public function index()
  25. {
  26. return $this->fetch();
  27. }
  28. /**
  29. * 分组列表
  30. */
  31. public function groupList()
  32. {
  33. $where = UtilService::getMore([
  34. ['page', 1],
  35. ['limit', 20],
  36. ['status', ''],
  37. ]);
  38. return JsonService::successlayui(Cert::getList($where));
  39. }
  40. /**
  41. * 添加/修改分组页面
  42. * @param int $id
  43. * @return string
  44. */
  45. public function check($id = 0)
  46. {
  47. $f = array();
  48. $f[] = Form::radio('status', '状态', '1')->setOptions([['value' => '1', 'label' => '通过'], ['value' => '2', 'label' => '不通过']]);
  49. $f[] = Form::select('level', '级别', '1')->setOptions([['value' => '1', 'label' => '低级'], ['value' => '2', 'label' => '中级'], ['value' => '3', 'label' => '高级'], ['value' => '4', 'label' => '特级']]);
  50. $form = Form::make_post_form('确认证书', $f, Url::buildUrl('save_check', array('id' => $id)));
  51. $this->assign(compact('form'));
  52. return $this->fetch('public/form-builder');
  53. }
  54. /**
  55. * 添加/修改
  56. * @param int $id
  57. */
  58. public function save_check($id)
  59. {
  60. list($status, $level) = UtilService::postMore([
  61. ['status', 0],
  62. ['level', 1]
  63. ], $this->request, true);
  64. $res = Cert::check_cert($id, $status, $level);
  65. if ($res) {
  66. return JsonService::success('已确认');
  67. } else {
  68. return JsonService::fail(Cert::getErrorInfo());
  69. }
  70. }
  71. }