提交 5e12ec28 authored 作者: duanyinglei's avatar duanyinglei

初始化项目

上级 c4078b73
<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action=""> <form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
<div class="form-group" style="display: none;"> <div class="form-group" style="">
<label class="control-label col-xs-12 col-sm-2">{:__('Table')}:</label> <label class="control-label col-xs-12 col-sm-2">{:__('Table')}:</label>
<div class="col-xs-12 col-sm-8" id="selectable"> <div class="col-xs-12 col-sm-8" id="selectable">
{:Form::select('row[table]', $tableList, $table, [])} {:Form::select('row[table]', $tableList, $table, [])}
......
...@@ -16,18 +16,29 @@ class Material extends Api ...@@ -16,18 +16,29 @@ class Material extends Api
/** /**
* 首页 * 首页
*
*
* *
*/ */
public function index() public function index()
{ {
$png = $this->imageEdit("http://taote.com/uploads/20210713/f46f8fb6a5a46f119fa00c4ffd9c89a1.jpg","http://taote.com/uploads/qrcode/106324.png"); $list = Db::table("fa_ex_fb")->where("id","between",[14501,15005])->select();
$image = $this->imageAddText("./uploads/material.png","来自某某某站长的分享",50,100,14,"./uploads/material.png"); foreach($list as $k=>$v){
$png = $this->qcode($v["name5"],$v["name3"]);
}
// $png = $this->imageEdit("http://taote.com/uploads/20210713/f46f8fb6a5a46f119fa00c4ffd9c89a1.jpg","http://taote.com/uploads/qrcode/106324.png");
// $image = $this->imageAddText("./uploads/material.png","来自某某某站长的分享",50,100,14,"./uploads/material.png");
} }
/**生成二维码*/ /**生成二维码*/
public function qcode($popularize_url,$popularize_id){ public function qcode($popularize_url,$popularize_id){
QRcode::png($popularize_url,"./uploads/qrcodes/".$popularize_id.".png"); QRcode::png($popularize_url,"./uploads/qrcode/".$popularize_id.".png");
} }
/**添加图片**/ /**添加图片**/
public function imageEdit($url,$qrcode){ public function imageEdit($url,$qrcode){
$dst_path = $url; $dst_path = $url;
...@@ -83,7 +94,7 @@ class Material extends Api ...@@ -83,7 +94,7 @@ class Material extends Api
/*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符,其表达了从给定字符串得来的图像 /*imagecreatefromstring()--从字符串中的图像流新建一个图像,返回一个图像标示符,其表达了从给定字符串得来的图像
图像格式将自动监测,只要php支持jpeg,png,gif,wbmp,gd2.*/ 图像格式将自动监测,只要php支持jpeg,png,gif,wbmp,gd2.*/
$font = './uploads/fonts.ttf'; $font = __METHOD__.'./uploads/fonts.ttf';
$black = imagecolorallocate($dst, 255,255,0); $black = imagecolorallocate($dst, 255,255,0);
imagefttext($dst, 20, 0, 150, 120, $black, $font, $text); imagefttext($dst, 20, 0, 150, 120, $black, $font, $text);
/*imagefttext($img,$size,$angle,$x,$y,$color,$fontfile,$text) /*imagefttext($img,$size,$angle,$x,$y,$color,$fontfile,$text)
......
...@@ -18,11 +18,11 @@ return [ ...@@ -18,11 +18,11 @@ return [
// 服务器地址 // 服务器地址
'hostname' => Env::get('database.hostname', '127.0.0.1'), 'hostname' => Env::get('database.hostname', '127.0.0.1'),
// 数据库名 // 数据库名
'database' => Env::get('database.database', 'yinong'), 'database' => Env::get('database.database', 'taote'),
// 用户名 // 用户名
'username' => Env::get('database.username', 'root'), 'username' => Env::get('database.username', 'taote'),
// 密码 // 密码
'password' => Env::get('database.password', 'root'), 'password' => Env::get('database.password', 'R6azbxHLxhyFDBMA'),
// 端口 // 端口
'hostport' => Env::get('database.hostport', ''), 'hostport' => Env::get('database.hostport', ''),
// 连接dsn // 连接dsn
......
...@@ -6,15 +6,15 @@ use app\common\controller\Frontend; ...@@ -6,15 +6,15 @@ use app\common\controller\Frontend;
use app\common\model\User; use app\common\model\User;
use app\common\model\Ex; use app\common\model\Ex;
use app\common\model\Material; use app\common\model\Material;
include ROOT_PATH."extend/phpqrcode/qrlib.php"; //include ROOT_PATH."extend/phpqrcode/qrlib.php";
use QRcode; //use QRcode;
class Index extends Frontend class Index extends Frontend
{ {
protected $noNeedLogin = '*'; protected $noNeedLogin = '*';
protected $noNeedRight = '*'; protected $noNeedRight = '*';
protected $layout = ''; protected $layout = '';
private $watermark_on = '1';
public function index() public function index()
{ {
...@@ -34,6 +34,7 @@ class Index extends Frontend ...@@ -34,6 +34,7 @@ class Index extends Frontend
// print_r($data);exit; // print_r($data);exit;
$data['popularize_id'] = $info["popularize_id"]; $data['popularize_id'] = $info["popularize_id"];
$this->view->assign('data', $data); $this->view->assign('data', $data);
$this->view->assign('username', $info->nickname);
return $this->view->fetch(); return $this->view->fetch();
} }
...@@ -45,12 +46,18 @@ class Index extends Frontend ...@@ -45,12 +46,18 @@ class Index extends Frontend
return $this->view->fetch(); return $this->view->fetch();
} }
public function imageExid (){ public function imageExid (){
$info = User::get($this->auth->id);
$url = $_GET["url"]; $url = $_GET["url"];
$id = $_GET["id"];
$info = User::get($this->auth->id); $info = User::get($this->auth->id);
$png = $this->imageEdit($url,"http://".$_SERVER["HTTP_HOST"]."/uploads/qrcode/".$info->popularize_id.".png"); $echo_png = "./uploads/material/".$info->popularize_id."_".$id."_".$info->id.".png";
$image = $this->imageAddText($url,1,"来自".$info->nickname."站长的分享",$echo_png);
$png = $this->imageEdit($image,"http://".$_SERVER["HTTP_HOST"]."/uploads/qrcode/".$info->popularize_id.".png", $echo_png);
return "http://".$_SERVER["HTTP_HOST"].$echo_png;
} }
/**添加图片**/ /**添加图片ss**/
public function imageEdit($url,$qrcode){ public function imageEdit($url,$qrcode, $echo_png ){
$dst_path = $url; $dst_path = $url;
$src_path = $qrcode ; $src_path = $qrcode ;
//创建图片的实例 //创建图片的实例
...@@ -59,34 +66,62 @@ class Index extends Frontend ...@@ -59,34 +66,62 @@ class Index extends Frontend
//获取水印图片的宽高 //获取水印图片的宽高
list($src_w, $src_h) = getimagesize($src_path); list($src_w, $src_h) = getimagesize($src_path);
//将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果 //将水印图片复制到目标图片上,最后个参数50是设置透明度,这里实现半透明效果
imagecopymerge($dst, $src, 460, 940, 0, 0, 200, 200, 100); imagecopymerge($dst, $src, 480, 970, 0, 0, $src_w, $src_h, 100);
// $st = imagecopymerge($dst, $src, 0, 0, 0, 0, $src_w, $src_h, 50);
// $font = './uploads/fonts.ttf';//字体
// $black = imagecolorallocate($dst, 0, 0, 0);//字体颜色
// imagefttext($dst, 13, 0, 20, 20, $black, $font, '快乐编程');
//如果水印图片本身带透明色,则使用imagecopy方法 //如果水印图片本身带透明色,则使用imagecopy方法
//imagecopy($dst, $src, 10, 10, 0, 0, $src_w, $src_h); //imagecopy($dst, $src, 10, 10, 0, 0, $src_w, $src_h);
//输出图片 //输出图片
$dst_type = 3; $dst_type = 3;
list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path); list($dst_w, $dst_h, $dst_type) = getimagesize($dst_path);
switch ($dst_type) { switch ($dst_type) {
case 1://GIF case 1://GIF
header('Content-Type: image/gif'); header('Content-Type: image/png');
imagegif($dst); imagepng($dst,$echo_png);
// imagegif($dst);
break; break;
case 2://JPG case 2://JPG
header('Content-Type: image/jpeg'); header('Content-Type: image/png');
imagejpeg($dst); imagepng($dst,$echo_png);
// imagejpeg($dst);
break; break;
case 3://PNG case 3://PNG
header('Content-Type: image/png'); header('Content-Type: image/png');
imagepng($dst,"./uploads/material.png"); imagepng($dst,$echo_png);
break; break;
default: default:
break; break;
} }
imagedestroy($dst); imagedestroy($dst);
imagedestroy($src); imagedestroy($src);
}
/**
* 给图片加文字
* $bg_path 背景图地址
* $text 要添加的文字
* $x 文字在背景图片上位置的左边距,单位:px (例:436)
* $y 文字在背景图片上位置的上边距,单位:px (例:1009)
* $font_size 字体大小,单位:px (例:20)
* $echo_path 生成的新图片存放路径
**/
public function imageAddText( $img,$pos=1,$text,$echo_png )
{
header("Content-type: image/png");
$src = $img;
$srcImageInfo=getimagesize($src);
$srcImageWidth=$srcImageInfo[0];
$srcImageHeight=$srcImageInfo[1];
$srcImage=imagecreatefrompng($src);
$img=imagecreatetruecolor($srcImageWidth,$srcImageHeight);
$red=imagecolorallocate($img,255,255,255);//红色
$waterText = $text;
$font = './uploads/fonts.ttf';
imagecopy($img,$srcImage,0, 0, 0, 0, $srcImageWidth, $srcImageHeight);
imagettftext($img, 22, 0, 220, 160, $red, $font, $waterText);
imagepng($img,$echo_png);//,'tt.png'
return $echo_png;
} }
} }
...@@ -12,7 +12,7 @@ class Material extends Api ...@@ -12,7 +12,7 @@ class Material extends Api
protected $noNeedRight = ['*']; protected $noNeedRight = ['*'];
/** /**
* 首页 * 首页sss
* *
*/ */
public function index() public function index()
......
...@@ -100,25 +100,26 @@ ...@@ -100,25 +100,26 @@
<script src="__CDN__/template/mobile/js/mui.js"></script> <script src="__CDN__/template/mobile/js/mui.js"></script>
<script src="__CDN__/template/mobile/js/rem.js"></script> <script src="__CDN__/template/mobile/js/rem.js"></script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
mui.init() mui.init()
var image_url = ""
function show(id){ function show(id){
var imageId = "image"+id; var imageId = "image"+id;
console.log(imageId) console.log(imageId)
var s=document.getElementById(imageId).src; var s=document.getElementById(imageId).src;
var xmlhttp; $.ajax({
function loadXMLDoc() { url:"{:url('index/imageExid')}?url="+s+"&id="+id,
xmlhttp = new XMLHttpRequest(); type:"get",
xmlhttp.onreadystatechange=state_Change; success:function(json){
xmlhttp.open("GET","{:url('index/imageExid')}?url="+s,true); state_Change(json)
xmlhttp.send(); }
} });
loadXMLDoc()
} }
function state_Change(){ function state_Change(url){
console.log(url)
setTimeout(function () { setTimeout(function () {
document.getElementById("imageId").src="__CDN__/uploads/material.png" document.getElementById("imageId").src=url
document.getElementsByClassName('mui-backdrop')[0].style.display='block' document.getElementsByClassName('mui-backdrop')[0].style.display='block'
},100) },100)
} }
......
...@@ -141,7 +141,7 @@ ...@@ -141,7 +141,7 @@
</header> --> </header> -->
<div class="mui-content"> <div class="mui-content">
<div class="mui-card"> <div class="mui-card">
<div class="mui-cardhd">本月数据(截止前一天)</div> <div class="mui-cardhd">本月数据(截止前一天)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{$username}</div>
<div class="mui-card-content"> <div class="mui-card-content">
<ul class="card-contentul"> <ul class="card-contentul">
<li class="ddlileft"> <li class="ddlileft">
......
...@@ -29,7 +29,8 @@ ...@@ -29,7 +29,8 @@
"ext-json": "*", "ext-json": "*",
"ext-curl": "*", "ext-curl": "*",
"ext-pdo": "*", "ext-pdo": "*",
"txthinking/mailer": "^2.0" "txthinking/mailer": "^2.0",
"ext-gd": "*"
}, },
"config": { "config": {
"preferred-install": "dist" "preferred-install": "dist"
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论