| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use fast\Random;
 
- use \think\Log;
 
- use Redis;
 
- use app\common\library\Sms as Smslib;
 
- /**
 
-  * 首页接口
 
-  */
 
- class Index extends Api
 
- {
 
-     protected $noNeedLogin = ['index','contactus','tcpTest','getAppShare','getWebsiteInfo','getUserCharmRankList','getPartyHotList','searchUsers','getInviteCode','getEdition','getInviteImg','getWebsiteInfoForMini','getBankList','getSwitch','getBootAnimation'];
 
-     protected $noNeedRight = ['*'];
 
-     public function index(){
 
-         echo 'apisuccess';
 
-         exit;
 
-     }
 
-     /**
 
-      * 获取邀请图片
 
-      */
 
-     public function getInviteImg() {
 
-         $plat = $this->request->request("plat",1); //平台:1=小程序,2=app
 
-         if(!in_array($plat,[1,2])) $this->error("参数错误");
 
-         // 获取用户的邀请码
 
-         $invitecode = \app\common\model\User::where(["id"=>$this->auth->id])->value("invite_no");
 
-         // 文字图片合成
 
-         $bigImgPath = $this->httpurlLocal('/assets/img/inviteimg.jpeg');
 
-         $img = imagecreatefromstring(file_get_contents($bigImgPath));
 
-         //字体文件
 
-         $font = realpath('./assets/fonts/lato/lato-black.ttf');
 
-         //字体颜色(RGB)
 
-         $black = imagecolorallocate($img, 217, 76, 41);
 
-         //字体大小
 
-         $fontSize = 30;
 
-         //旋转角度
 
-         $circleSize = 0;
 
-         //左边距
 
-         $left = 275;
 
-         //上边距
 
-         $top = 540;
 
-         imagefttext($img, $fontSize, $circleSize, $left, $top, $black, $font, $invitecode);
 
-         $filename = date("YmdH").".jpeg";
 
-         $path = "/uploads/qrcode/".$filename;
 
-         $file = $_SERVER['DOCUMENT_ROOT'] . $path;//打开文件准备写入
 
-         list($bgWidth, $bgHight, $bgType) = getimagesize($bigImgPath);
 
-         switch ($bgType) {
 
-             case 1://gif
 
-                 header('Content-Type:image/gif');
 
-                 imagegif($img,$file);
 
-                 break;
 
-             case 2://jpg
 
-                 header('Content-Type:image/jpg');
 
-                 imagejpeg($img,$file);
 
-                 break;
 
-             case 3://jpg
 
-                 header('Content-Type:image/png');
 
-                 imagepng($img,$file);
 
-                 break;
 
-             default:
 
-                 break;
 
-         }
 
-         //销毁照片
 
-         imagedestroy($img);
 
-         // 图片和二维码合成
 
-         $qrcode = $plat == 1 ? config("site.miniqrcode"):config("site.qrcode");
 
-         $background = $file;
 
-         $target = $this->httpurl($qrcode);
 
-         $background_iamge = imagecreatefromstring(file_get_contents($background));
 
-         $target_image = imagecreatefromstring(file_get_contents($target));
 
-         list($target_width, $target_height, $target_type) = getimagesize($target);
 
-         imagecopymerge($background_iamge , $target_image , 250, 700, 0, 0, $target_width, $target_height, 100);
 
-         list($background_width, $background_height, $background_type) = getimagesize($background);
 
-         switch ($background_type) {
 
-             case 1://gif
 
-                 header('Content-Type:image/gif');
 
-                 imagegif($background_iamge,$file);
 
-                 break;
 
-             case 2://jpg
 
-                 header('Content-Type:image/jpg');
 
-                 imagejpeg($background_iamge,$file);
 
-                 break;
 
-             case 3://jpg
 
-                 header('Content-Type:image/png');
 
-                 imagepng($background_iamge,$file);
 
-                 break;
 
-             default:
 
-                 break;
 
-         }
 
-         $savepath = $this->httpurlLocal($path);
 
-         $this->success("获取成功!",$savepath);
 
-     }
 
-     /**
 
-      * 评论时间转换
 
-      * @param null $time
 
-      * @return false|string
 
-      */
 
-     private function get_last_time($time = NULL) {
 
-         $text = '';
 
-         $time = $time === NULL || $time > time() ? time() : intval($time);
 
-         $t = time() - $time; //时间差 (秒)
 
-         $y = date('Y', $time)-date('Y', time());//是否跨年
 
-         switch($t){
 
-             case $t == 0:
 
-                 $text = '刚刚';
 
-                 break;
 
-             case $t < 60:
 
-                 $text = $t . '秒前'; // 一分钟内
 
-                 break;
 
-             case $t < 60 * 60:
 
-                 $text = floor($t / 60) . '分钟前'; //一小时内
 
-                 break;
 
-             case $t < 60 * 60 * 24:
 
-                 $text = floor($t / (60 * 60)) . '小时前'; // 一天内
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 3:
 
-                 $text = floor($time/(60*60*24)) ==1 ?'昨天 ' . date('H:i', $time) : '前天 ' . date('H:i', $time) ; //昨天和前天
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 30:
 
-                 $text = date('m月d日 H:i', $time); //一个月内
 
-                 break;
 
-             case $t < 60 * 60 * 24 * 365&&$y==0:
 
-                 $text = date('m月d日', $time); //一年内
 
-                 break;
 
-             default:
 
-                 $text = date('Y年m月d日', $time); //一年以前
 
-                 break;
 
-         }
 
-         return $text;
 
-     }
 
- }
 
 
  |