Usercenter.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. //生成邀请码二维码图片
  14. public function inviteimage($introcode) {
  15. $params['text'] = config('h5_url') . '/#/pages/home/index?introcode=' . $introcode;
  16. $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
  17. // $mimetype = 'image/png';
  18. // $response = Response::create()->header("Content-Type", $mimetype);
  19. // 直接显示二维码
  20. // header('Content-Type: ' . $qrcode_service->getContentType());
  21. // $response->content($qrcode_service->writeString());
  22. $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
  23. if (!is_dir($qrcodePath)) {
  24. @mkdir($qrcodePath);
  25. }
  26. if (is_really_writable($qrcodePath)) {
  27. $filename = md5(implode('', $params)) . '.png';
  28. $filePath = $qrcodePath . $filename;
  29. $qrcode_service->writeFile($filePath);
  30. }
  31. return '/uploads/qrcode/' . $filename;
  32. }
  33. //生成视频分享海报
  34. public function shareposter() {
  35. $inviteimage = $this->inviteimage($this->auth->introcode);
  36. $data = [
  37. [
  38. "left"=> "100px",
  39. "top"=> "424px",
  40. "type"=> "nickname",
  41. "width"=> "166px",
  42. "height"=> "38px",
  43. "size"=> "11px",
  44. "color"=> "#333333",
  45. "content" => '邀请码:'.$this->auth->introcode,
  46. ],
  47. [
  48. "left"=> "90px",
  49. "top"=> "260px",
  50. "type"=> "img",
  51. "width"=> "140px",
  52. "height"=> "140px",
  53. "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
  54. ],
  55. ];
  56. $data = json_encode($data, 320);
  57. $poster = [
  58. 'id' => 1,
  59. 'title' => '测试',
  60. 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
  61. 'bg_image' => '/assets/img/posteruserbg.png',
  62. 'data' => $data,
  63. 'status' => 'normal',
  64. 'weigh' => 0,
  65. 'createtime' => 1653993709,
  66. 'updatetime' => 1653994259,
  67. ];
  68. $image = new \addons\poster\library\Image();
  69. $imgurl = $image->createPosterImage_user($poster, $this->auth->getUser());
  70. if (!$imgurl) {
  71. $this->error('生成海报出错');
  72. }
  73. $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
  74. //echo '<html><body><img src="'.$imgurl.'"></body></html>';
  75. $this->success('', $imgurl);
  76. }
  77. }