Usercenter.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 会员中心
  7. */
  8. class Usercenter extends Api
  9. {
  10. protected $noNeedLogin = [];
  11. protected $noNeedRight = '*';
  12. //我的下级
  13. public function myintro(){
  14. $list = Db::name('user')->field('id,nickname,avatar,jointime')->where('intro_uid',$this->auth->id)->autopage()->order('id desc')->select();
  15. $list = list_domain_image($list,['avatar']);
  16. $this->success(1,$list);
  17. }
  18. //生成我的视频海报
  19. //生成邀请码二维码图片
  20. public function inviteimage($introcode) {
  21. $params['text'] = config('h5_url') . '/#/pages/home/index?introcode=' . $introcode;
  22. $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
  23. // $mimetype = 'image/png';
  24. // $response = Response::create()->header("Content-Type", $mimetype);
  25. // 直接显示二维码
  26. // header('Content-Type: ' . $qrcode_service->getContentType());
  27. // $response->content($qrcode_service->writeString());
  28. $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
  29. if (!is_dir($qrcodePath)) {
  30. @mkdir($qrcodePath);
  31. }
  32. if (is_really_writable($qrcodePath)) {
  33. $filename = md5(implode('', $params)) . '.png';
  34. $filePath = $qrcodePath . $filename;
  35. $qrcode_service->writeFile($filePath);
  36. }
  37. return '/uploads/qrcode/' . $filename;
  38. }
  39. //生成视频分享海报
  40. public function shareposter() {
  41. $inviteimage = $this->inviteimage($this->auth->introcode);
  42. $data = [
  43. [
  44. "left"=> "100px",
  45. "top"=> "424px",
  46. "type"=> "nickname",
  47. "width"=> "166px",
  48. "height"=> "38px",
  49. "size"=> "11px",
  50. "color"=> "#333333",
  51. "content" => '邀请码:'.$this->auth->introcode,
  52. ],
  53. [
  54. "left"=> "90px",
  55. "top"=> "260px",
  56. "type"=> "img",
  57. "width"=> "140px",
  58. "height"=> "140px",
  59. "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
  60. ],
  61. ];
  62. $data = json_encode($data, 320);
  63. $poster = [
  64. 'id' => 1,
  65. 'title' => '测试',
  66. 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
  67. 'bg_image' => '/assets/img/posteruserbg.png',
  68. 'data' => $data,
  69. 'status' => 'normal',
  70. 'weigh' => 0,
  71. 'createtime' => 1653993709,
  72. 'updatetime' => 1653994259,
  73. ];
  74. $image = new \addons\poster\library\Image();
  75. $imgurl = $image->createPosterImage_user($poster, $this->auth->getUser());
  76. if (!$imgurl) {
  77. $this->error('生成海报出错');
  78. }
  79. $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
  80. //echo '<html><body><img src="'.$imgurl.'"></body></html>';
  81. $this->success('', $imgurl);
  82. }
  83. }