作者 chencheng

0529-121

... ... @@ -14,11 +14,12 @@ class Base extends Api
protected $AppID;
protected $AppSecret;
protected $qiniuUrl;
public $url_h5;//前端h5的首页地址 分销需要加参数
public function __construct(Request $request = null)
{
parent::__construct($request);
$this->qiniuUrl = 'https://coupon.xp.yn.cn';
$this->url_h5 = 'https://coupon.xp.yn.cn';
$this->AppID = config("site.appid");//微信小程序AppID
$this->AppSecret = config("site.appsecret");//微信小程序密钥
}
... ...
... ... @@ -23,7 +23,7 @@ class Client extends Api
$this->postParam = $postParam;
$res=$this->request->header();
print_r($res);
parent::_initialize();
$this->auth->id ;//测试用
$postParam = $this->request->param();
... ... @@ -38,7 +38,7 @@ class Client extends Api
}
$this->store = $store;
if (empty($this->auth->id)) {
print_r([$this->auth->id]);
return;
}
... ... @@ -229,4 +229,40 @@ class Client extends Api
$this->success("查询成功",$receive);
}
/*
7.生成二维码 及 规则
二维码 没有则创新 /index.php/api/v1/index/synthesis?store_id=1&activity_id=2
参数 用户id 门店id 活动id
code activiy_id
请求需要加 header token
有前端自行合成分销图片
*/
public function synthesis(){
//参数
$param = request()->param();
$user_id = $this->auth->id;
$user_id=2;
//验证
if(empty($user_id)){return $this->error('用户信息错误');}
if(empty($param['code'])){return $this->error('请确认门店');}
if(empty($param['activity_id'])){return $this->error('请确认活动');}
$w['user_id'] = $user_id;
$w['code'] = $param['code'];
$w['activity_id'] = $param['activity_id'];
$r = Db::name('user_synthesis')->where($w)->find();
//有 则 返回 无 则新增
if(empty($r)){
$url = (new \app\api\controller\v1\Base())->url_h5.'?'.http_build_query($param);
$res = (new \app\api\controller\v1\Index())->build($url);
$w['create_at'] = time();
$w['url'] = $res;
Db::name('user_synthesis')->insert($w);
}else{
$res = $r['url'];
}
return $this->success('',request()->domain() . $res);
}
}
... ...
... ... @@ -14,7 +14,7 @@ use think\Config;
use think\Db;
use think\Response;
use think\Validate;
use app\server\Synthesis;
/**
* 首页公共
*/
... ... @@ -265,13 +265,10 @@ class Index extends Api
$code_path="/uploads/qrcode/".$code_name;
}
return $this->success("", $code_path);
return $code_path;
}
//图片合成 分销图片
public function synthesis(){
}
/**
* 名字加*
... ...
<?php
namespace app\server;
use Kkokk\Poster\PosterManager;
use Kkokk\Poster\Exception\Exception;
class Synthesis{
/**
* 图片合成
* $qrcode 二维码
*/
static public function buildImDst($qrcode){
$saveHBPath = '';// # 设置保存路径和文件名
$poster = PosterManager::Poster($saveHBPath);
$BGPath = '';//背景图路径
$poster->buildImDst($BGPath);
//根据背景图的大小调整
$dst_x=408;
$dst_y=731;
$src_x=0;
$src_y=0;
$size=4;
$margin=1;
$result = $poster->buildImage('http://localhost/'.$qrcode,$dst_x,$dst_y,$src_x,$src_y)->getPoster(); # 合成二维码
return $result;
}
/**创建二维码 186x186 */
static public function qrcode($url){
try{
$qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
$res = PosterManager::Poster()->Qr($url,$qrcodePath,'H',6);
}catch(\Exception $e){
abort(404,$e->getMessage());
}
}
}
\ No newline at end of file
... ...