Qrcode.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\api\controller\plus\agent;
  3. use app\api\controller\Controller;
  4. use app\api\model\plus\agent\Setting;
  5. use app\api\model\plus\agent\User as AgentUserModel;
  6. use app\common\service\qrcode\PosterService;
  7. /**
  8. * 推广二维码
  9. */
  10. class Qrcode extends Controller
  11. {
  12. // 当前用户
  13. private $user;
  14. // 分销商
  15. private $agent;
  16. // 分销设置
  17. private $setting;
  18. /**
  19. * 构造方法
  20. */
  21. public function initialize()
  22. {
  23. // 用户信息
  24. $this->user = $this->getUser();
  25. // 分销商用户信息
  26. $this->agent = AgentUserModel::detail($this->user['user_id']);
  27. // 分销商设置
  28. $this->setting = Setting::getAll();
  29. }
  30. /**
  31. * 获取推广二维码
  32. */
  33. public function poster($source)
  34. {
  35. $Qrcode = new PosterService($this->agent, $source);
  36. return $this->renderSuccess('', [
  37. // 二维码图片地址
  38. 'qrcode' => $Qrcode->getImage(),
  39. ]);
  40. }
  41. }