Qrcode.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. protected $user;
  14. // 分销商
  15. protected $agent;
  16. // 分销设置
  17. protected $setting;
  18. /**
  19. * 构造方法
  20. */
  21. public function initialize()
  22. {
  23. parent::initialize();
  24. // 用户信息
  25. $this->user = $this->getUser();
  26. // 分销商用户信息
  27. $this->agent = AgentUserModel::detail($this->user['user_id']);
  28. // 分销商设置
  29. $this->setting = Setting::getAll();
  30. }
  31. /**
  32. * 获取推广二维码
  33. */
  34. public function poster($source)
  35. {
  36. $Qrcode = new PosterService($this->agent, $source);
  37. return $this->renderSuccess('', [
  38. // 二维码图片地址
  39. 'qrcode' => $Qrcode->getImage(),
  40. ]);
  41. }
  42. }