正在显示
4 个修改的文件
包含
83 行增加
和
9 行删除
@@ -14,11 +14,12 @@ class Base extends Api | @@ -14,11 +14,12 @@ class Base extends Api | ||
14 | protected $AppID; | 14 | protected $AppID; |
15 | protected $AppSecret; | 15 | protected $AppSecret; |
16 | protected $qiniuUrl; | 16 | protected $qiniuUrl; |
17 | - | 17 | + public $url_h5;//前端h5的首页地址 分销需要加参数 |
18 | public function __construct(Request $request = null) | 18 | public function __construct(Request $request = null) |
19 | { | 19 | { |
20 | parent::__construct($request); | 20 | parent::__construct($request); |
21 | $this->qiniuUrl = 'https://coupon.xp.yn.cn'; | 21 | $this->qiniuUrl = 'https://coupon.xp.yn.cn'; |
22 | + $this->url_h5 = 'https://coupon.xp.yn.cn'; | ||
22 | $this->AppID = config("site.appid");//微信小程序AppID | 23 | $this->AppID = config("site.appid");//微信小程序AppID |
23 | $this->AppSecret = config("site.appsecret");//微信小程序密钥 | 24 | $this->AppSecret = config("site.appsecret");//微信小程序密钥 |
24 | } | 25 | } |
@@ -23,7 +23,7 @@ class Client extends Api | @@ -23,7 +23,7 @@ class Client extends Api | ||
23 | $this->postParam = $postParam; | 23 | $this->postParam = $postParam; |
24 | 24 | ||
25 | $res=$this->request->header(); | 25 | $res=$this->request->header(); |
26 | - print_r($res); | 26 | + |
27 | parent::_initialize(); | 27 | parent::_initialize(); |
28 | $this->auth->id ;//测试用 | 28 | $this->auth->id ;//测试用 |
29 | $postParam = $this->request->param(); | 29 | $postParam = $this->request->param(); |
@@ -38,7 +38,7 @@ class Client extends Api | @@ -38,7 +38,7 @@ class Client extends Api | ||
38 | } | 38 | } |
39 | $this->store = $store; | 39 | $this->store = $store; |
40 | if (empty($this->auth->id)) { | 40 | if (empty($this->auth->id)) { |
41 | - print_r([$this->auth->id]); | 41 | + |
42 | return; | 42 | return; |
43 | } | 43 | } |
44 | 44 | ||
@@ -229,4 +229,40 @@ class Client extends Api | @@ -229,4 +229,40 @@ class Client extends Api | ||
229 | $this->success("查询成功",$receive); | 229 | $this->success("查询成功",$receive); |
230 | } | 230 | } |
231 | 231 | ||
232 | + | ||
233 | + /* | ||
234 | + 7.生成二维码 及 规则 | ||
235 | + 二维码 没有则创新 /index.php/api/v1/index/synthesis?store_id=1&activity_id=2 | ||
236 | + 参数 用户id 门店id 活动id | ||
237 | + code activiy_id | ||
238 | + 请求需要加 header token | ||
239 | + | ||
240 | + 有前端自行合成分销图片 | ||
241 | + */ | ||
242 | + public function synthesis(){ | ||
243 | + //参数 | ||
244 | + $param = request()->param(); | ||
245 | + $user_id = $this->auth->id; | ||
246 | + $user_id=2; | ||
247 | + //验证 | ||
248 | + if(empty($user_id)){return $this->error('用户信息错误');} | ||
249 | + if(empty($param['code'])){return $this->error('请确认门店');} | ||
250 | + if(empty($param['activity_id'])){return $this->error('请确认活动');} | ||
251 | + $w['user_id'] = $user_id; | ||
252 | + $w['code'] = $param['code']; | ||
253 | + $w['activity_id'] = $param['activity_id']; | ||
254 | + $r = Db::name('user_synthesis')->where($w)->find(); | ||
255 | + //有 则 返回 无 则新增 | ||
256 | + if(empty($r)){ | ||
257 | + $url = (new \app\api\controller\v1\Base())->url_h5.'?'.http_build_query($param); | ||
258 | + $res = (new \app\api\controller\v1\Index())->build($url); | ||
259 | + $w['create_at'] = time(); | ||
260 | + $w['url'] = $res; | ||
261 | + Db::name('user_synthesis')->insert($w); | ||
262 | + }else{ | ||
263 | + $res = $r['url']; | ||
264 | + } | ||
265 | + return $this->success('',request()->domain() . $res); | ||
266 | + } | ||
267 | + | ||
232 | } | 268 | } |
@@ -14,7 +14,7 @@ use think\Config; | @@ -14,7 +14,7 @@ use think\Config; | ||
14 | use think\Db; | 14 | use think\Db; |
15 | use think\Response; | 15 | use think\Response; |
16 | use think\Validate; | 16 | use think\Validate; |
17 | - | 17 | +use app\server\Synthesis; |
18 | /** | 18 | /** |
19 | * 首页公共 | 19 | * 首页公共 |
20 | */ | 20 | */ |
@@ -265,13 +265,10 @@ class Index extends Api | @@ -265,13 +265,10 @@ class Index extends Api | ||
265 | $code_path="/uploads/qrcode/".$code_name; | 265 | $code_path="/uploads/qrcode/".$code_name; |
266 | } | 266 | } |
267 | 267 | ||
268 | - return $this->success("", $code_path); | 268 | + return $code_path; |
269 | 269 | ||
270 | } | 270 | } |
271 | - //图片合成 分销图片 | ||
272 | - public function synthesis(){ | ||
273 | - | ||
274 | - } | 271 | + |
275 | 272 | ||
276 | /** | 273 | /** |
277 | * 名字加* | 274 | * 名字加* |
application/server/Synthesis.php
0 → 100644
1 | +<?php | ||
2 | + | ||
3 | +namespace app\server; | ||
4 | +use Kkokk\Poster\PosterManager; | ||
5 | +use Kkokk\Poster\Exception\Exception; | ||
6 | + | ||
7 | +class Synthesis{ | ||
8 | + | ||
9 | + | ||
10 | + /** | ||
11 | + * 图片合成 | ||
12 | + * $qrcode 二维码 | ||
13 | + */ | ||
14 | + static public function buildImDst($qrcode){ | ||
15 | + $saveHBPath = '';// # 设置保存路径和文件名 | ||
16 | + $poster = PosterManager::Poster($saveHBPath); | ||
17 | + $BGPath = '';//背景图路径 | ||
18 | + $poster->buildImDst($BGPath); | ||
19 | + //根据背景图的大小调整 | ||
20 | + $dst_x=408; | ||
21 | + $dst_y=731; | ||
22 | + $src_x=0; | ||
23 | + $src_y=0; | ||
24 | + $size=4; | ||
25 | + $margin=1; | ||
26 | + $result = $poster->buildImage('http://localhost/'.$qrcode,$dst_x,$dst_y,$src_x,$src_y)->getPoster(); # 合成二维码 | ||
27 | + return $result; | ||
28 | + } | ||
29 | + | ||
30 | + /**创建二维码 186x186 */ | ||
31 | + static public function qrcode($url){ | ||
32 | + try{ | ||
33 | + $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/'; | ||
34 | + $res = PosterManager::Poster()->Qr($url,$qrcodePath,'H',6); | ||
35 | + }catch(\Exception $e){ | ||
36 | + abort(404,$e->getMessage()); | ||
37 | + } | ||
38 | + | ||
39 | + } | ||
40 | +} |
-
请 注册 或 登录 后发表评论