Qrcode.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\controller\user\dealer;
  3. use app\api\controller\Controller;
  4. use app\api\model\dealer\Setting;
  5. use app\api\model\dealer\User as DealerUserModel;
  6. use app\common\service\qrcode\Poster;
  7. /**
  8. * 推广二维码
  9. * Class Order
  10. * @package app\api\controller\user\dealer
  11. */
  12. class Qrcode extends Controller
  13. {
  14. /* @var \app\api\model\User $user */
  15. private $user;
  16. private $dealer;
  17. private $setting;
  18. /**
  19. * 构造方法
  20. * @throws \app\common\exception\BaseException
  21. * @throws \think\exception\DbException
  22. */
  23. public function _initialize()
  24. {
  25. parent::_initialize();
  26. // 用户信息
  27. $this->user = $this->getUser();
  28. // 分销商用户信息
  29. $this->dealer = DealerUserModel::detail($this->user['user_id']);
  30. // 分销商设置
  31. $this->setting = Setting::getAll();
  32. }
  33. /**
  34. * 获取推广二维码
  35. * @return array
  36. * @throws \app\common\exception\BaseException
  37. * @throws \think\exception\DbException
  38. * @throws \Exception
  39. */
  40. public function poster()
  41. {
  42. $Qrcode = new Poster($this->dealer);
  43. return $this->renderSuccess([
  44. // 二维码图片地址
  45. 'qrcode' => $Qrcode->getImage(),
  46. // 页面文字
  47. 'words' => $this->setting['words']['values'],
  48. ]);
  49. }
  50. }