Qrcode.php 1.4 KB

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