浏览代码

海报转移

lizhen_gitee 4 月之前
父节点
当前提交
4809ff5995
共有 2 个文件被更改,包括 166 次插入142 次删除
  1. 0 142
      application/api/controller/User.php
  2. 166 0
      application/api/controller/Userposter.php

+ 0 - 142
application/api/controller/User.php

@@ -970,123 +970,6 @@ class User extends Api
 
  
 
-    public function testhaibao(){
-        $haibao = $this->haibao($this->auth->id,['introcode'=>$this->auth->introcode]);
-//        dump($haibao);
-        $this->success('success', $haibao);
-    }
-
-    //海报
-    public function haibao($player_id,$data){
-
-        //下载页二维码,没必要保留
-        $params = [
-            'text' => config('site.domain_name').'?code=' . $data['introcode'],
-            'size' => 90,
-            'logo' => false,
-            'label' => false,
-            'padding' => 0,
-        ];
-        $qrCode = \addons\qrcode\library\Service::qrcode($params);
-        $qrcode_path = 'uploads/hbplayer/'.date('Ymd');
-        mk_dir($qrcode_path);
-        $download_qrcode = $qrcode_path.'/download'.$player_id.'.png';
-        $qrCode->writeFile($download_qrcode);
-
-        //海报
-        $haibao = $this->createhaibao($download_qrcode,$player_id,$data);
-
-        return $haibao;
-    }
-
-    /*public function createhaibao($download_qrcode,$player_id,$sub_data){
-
-        //背景图
-        $background = $sub_data['background'] ? $sub_data['background'] : config('site.domain_name').'/assets/img/haibao.png';
-        //海报图片路径
-        $new_path = 'uploads/hbplayer/'.date("Ymd").'/';
-        mk_dir($new_path);
-        $wap_file_name  = $new_path .'wap_player_'. $player_id . '.png';
-
-        //二维码
-        $download_qrcode= config('site.domain_name').'/'.$download_qrcode;
-
-
-        //合成wap图片
-        $image = new \addons\poster\library\Image2();
-        $imgurl = $image->createPosterImage($background,$download_qrcode,$sub_data['introcode'],$wap_file_name);
-
-        return '/'.$wap_file_name;
-    }*/
-
-    public function createhaibao($download_qrcode,$player_id,$sub_data){
-        //二维码
-        $download_qrcode= config('site.domain_name').'/'.$download_qrcode;
-
-        $data = [
-            [
-                "left" => "15px",
-                "top" => "296px",
-                "type" => "img",
-                "width" => "58px",
-                "height" => "58px",
-                "src" => one_domain_image($this->auth->avatar)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
-            ],
-            [
-                "left" => "81px",
-                "top" => "300px",
-                "type" => "nickname",
-                "width" => "80px",
-                "height" => "24px",
-                "size" => "12px",
-                "color" => "#000",
-                "content" => $this->auth->nickname
-            ],
-            [
-                "left" => "81px",
-                "top" => "327px",
-                "type" => "nickname",
-                "width" => "80px",
-                "height" => "24px",
-                "size" => "12px",
-                "color" => "#000",
-                "content" => $this->auth->introcode
-            ],
-            [
-                "left" => "227px",
-                "top" => "283px",
-                "type" => "img",
-                "width" => "80px",
-                "height" => "80px",
-//                "src" => httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
-                "src" => $download_qrcode//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
-            ]
-        ];
-
-        $data = json_encode($data, 320);
-
-        $poster = [
-            'id' => 1,
-            'title' => '测试2',
-            'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
-            'bg_image' => $sub_data['background'] ? cdnurl($sub_data['background']) : '/assets/img/inviteposter.png',
-            'data' => $data,
-            'status' => 'normal',
-            'weigh' => 0,
-            'createtime' => 1653993709,
-            'updatetime' => 1653994259,
-        ];
-
-        $image = new \addons\poster\library\Image();
-        $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
-
-        if (!$imgurl) {
-            $this->error('生成海报出错');
-        }
-//        $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
-        return '/' . $imgurl;
-    }
-
 
 
 
@@ -1750,31 +1633,6 @@ class User extends Api
         $this->success('success', $list);
     }
 
-    //海报背景图
-    public function posterlist() {
-        $list = config('site.intro_images');
-        if (!$list) {
-            $this->success('success', (object)[]);
-        }
-
-        foreach ($list as &$v) {
-            $v = config('img_url') . $this->createposter(config('site.domain_cdnurl') . $v);
-        }
-
-        $this->success('success', $list);
-    }
-    
-    //生成海报
-    public function createposter($image = '') {
-//        $image = input('image', '', 'trim');
-//        if (!$image) {
-//            $this->error('您的网络开小差啦~');
-//        }
-
-        $haibao = $this->haibao($this->auth->id,['introcode'=>$this->auth->introcode, 'background' => $image]);
-        return $haibao;
-//        $this->success('success', $haibao);
-    }
 
 
     //真人认证后修改头像前比对

+ 166 - 0
application/api/controller/Userposter.php

@@ -0,0 +1,166 @@
+<?php
+
+namespace app\api\controller;
+
+use app\common\controller\Api;
+use think\Db;
+/**
+ * 用户海报
+ */
+class Demo extends Api
+{
+
+
+    // 无需登录的接口,*表示全部
+    protected $noNeedLogin = [''];
+    // 无需鉴权的接口,*表示全部
+    protected $noNeedRight = ['*'];
+
+
+    public function testhaibao(){
+        $haibao = $this->haibao($this->auth->id,['introcode'=>$this->auth->introcode]);
+//        dump($haibao);
+        $this->success('success', $haibao);
+    }
+
+    //海报
+    public function haibao($player_id,$data){
+
+        //下载页二维码,没必要保留
+        $params = [
+            'text' => config('site.domain_name').'?code=' . $data['introcode'],
+            'size' => 90,
+            'logo' => false,
+            'label' => false,
+            'padding' => 0,
+        ];
+        $qrCode = \addons\qrcode\library\Service::qrcode($params);
+        $qrcode_path = 'uploads/hbplayer/'.date('Ymd');
+        mk_dir($qrcode_path);
+        $download_qrcode = $qrcode_path.'/download'.$player_id.'.png';
+        $qrCode->writeFile($download_qrcode);
+
+        //海报
+        $haibao = $this->createhaibao($download_qrcode,$player_id,$data);
+
+        return $haibao;
+    }
+
+    /*public function createhaibao($download_qrcode,$player_id,$sub_data){
+
+        //背景图
+        $background = $sub_data['background'] ? $sub_data['background'] : config('site.domain_name').'/assets/img/haibao.png';
+        //海报图片路径
+        $new_path = 'uploads/hbplayer/'.date("Ymd").'/';
+        mk_dir($new_path);
+        $wap_file_name  = $new_path .'wap_player_'. $player_id . '.png';
+
+        //二维码
+        $download_qrcode= config('site.domain_name').'/'.$download_qrcode;
+
+
+        //合成wap图片
+        $image = new \addons\poster\library\Image2();
+        $imgurl = $image->createPosterImage($background,$download_qrcode,$sub_data['introcode'],$wap_file_name);
+
+        return '/'.$wap_file_name;
+    }*/
+
+    public function createhaibao($download_qrcode,$player_id,$sub_data){
+        //二维码
+        $download_qrcode= config('site.domain_name').'/'.$download_qrcode;
+
+        $data = [
+            [
+                "left" => "15px",
+                "top" => "296px",
+                "type" => "img",
+                "width" => "58px",
+                "height" => "58px",
+                "src" => one_domain_image($this->auth->avatar)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
+            ],
+            [
+                "left" => "81px",
+                "top" => "300px",
+                "type" => "nickname",
+                "width" => "80px",
+                "height" => "24px",
+                "size" => "12px",
+                "color" => "#000",
+                "content" => $this->auth->nickname
+            ],
+            [
+                "left" => "81px",
+                "top" => "327px",
+                "type" => "nickname",
+                "width" => "80px",
+                "height" => "24px",
+                "size" => "12px",
+                "color" => "#000",
+                "content" => $this->auth->introcode
+            ],
+            [
+                "left" => "227px",
+                "top" => "283px",
+                "type" => "img",
+                "width" => "80px",
+                "height" => "80px",
+//                "src" => httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
+                "src" => $download_qrcode//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
+            ]
+        ];
+
+        $data = json_encode($data, 320);
+
+        $poster = [
+            'id' => 1,
+            'title' => '测试2',
+            'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
+            'bg_image' => $sub_data['background'] ? cdnurl($sub_data['background']) : '/assets/img/inviteposter.png',
+            'data' => $data,
+            'status' => 'normal',
+            'weigh' => 0,
+            'createtime' => 1653993709,
+            'updatetime' => 1653994259,
+        ];
+
+        $image = new \addons\poster\library\Image();
+        $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
+
+        if (!$imgurl) {
+            $this->error('生成海报出错');
+        }
+//        $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
+        return '/' . $imgurl;
+    }
+
+    //海报背景图
+    public function posterlist() {
+        $list = config('site.intro_images');
+        if (!$list) {
+            $this->success('success', (object)[]);
+        }
+
+        foreach ($list as &$v) {
+            $v = config('img_url') . $this->createposter(config('site.domain_cdnurl') . $v);
+        }
+
+        $this->success('success', $list);
+    }
+
+    //生成海报
+    public function createposter($image = '') {
+//        $image = input('image', '', 'trim');
+//        if (!$image) {
+//            $this->error('您的网络开小差啦~');
+//        }
+
+        $haibao = $this->haibao($this->auth->id,['introcode'=>$this->auth->introcode, 'background' => $image]);
+        return $haibao;
+//        $this->success('success', $haibao);
+    }
+
+
+
+
+}