|
@@ -108,42 +108,7 @@ class Package extends Apic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function showposter(){
|
|
|
- $id = input('id',1);
|
|
|
- $this->getMiniCode($id,$this->auth->company_id);
|
|
|
- }
|
|
|
-
|
|
|
- private function getMiniCode($id,$companyid)
|
|
|
- {
|
|
|
- $package = Db::name('package')->where('id',$id)->find();
|
|
|
-
|
|
|
- $httpStr = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'];
|
|
|
- if (empty($package['mini_code'])) {
|
|
|
- $client = new Client();
|
|
|
- $tk = getAccessToken();
|
|
|
- $miniCodeConfig = config('param.mini_code');
|
|
|
- //$miniCodeConfig['env_version'] = 'trial'; //强制体验版
|
|
|
- $miniCodeConfig['scene'] = 'id='.$id.'&shopId='.$companyid;
|
|
|
- $res2 = $client->request('POST', 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$tk, [
|
|
|
- 'json' => $miniCodeConfig,
|
|
|
- ]);
|
|
|
- $fileName = md5($id);
|
|
|
- $fileUrl = '/uploads/package/'.$fileName.'.png';
|
|
|
- $code = $res2->getBody()->getContents();
|
|
|
- file_put_contents(ROOT_PATH.'/public'.$fileUrl,$code);
|
|
|
-
|
|
|
- $companyRes = Db::name('package')->where('id',$id)->update(['mini_code'=>$fileUrl]);
|
|
|
- if ($companyRes === false) {
|
|
|
- $this->error('生成套餐小程序码失败');
|
|
|
- }
|
|
|
- $miniCode = $httpStr.$fileUrl;
|
|
|
- } else {
|
|
|
- $miniCode = $httpStr.$package['mini_code'];
|
|
|
- }
|
|
|
-
|
|
|
- $this->success('success',$miniCode);
|
|
|
|
|
|
- }
|
|
|
|
|
|
//上下架
|
|
|
public function changestatus(){
|
|
@@ -295,6 +260,160 @@ class Package extends Apic
|
|
|
$this->success('删除成功');
|
|
|
}
|
|
|
|
|
|
+ public function showposter(){
|
|
|
+ $id = input('id',1);
|
|
|
+ $minicode = $this->getMiniCode($id,$this->auth->company_id);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //仅返回套餐二维码
|
|
|
+ private function getMiniCode($id,$companyid)
|
|
|
+ {
|
|
|
+ $package = Db::name('package')->where('id',$id)->find();
|
|
|
+
|
|
|
+ $httpStr = $_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'];
|
|
|
+ if (empty($package['mini_code'])) {
|
|
|
+ $client = new Client();
|
|
|
+ $tk = getAccessToken();
|
|
|
+ $miniCodeConfig = config('param.mini_code');
|
|
|
+ //$miniCodeConfig['env_version'] = 'trial'; //强制体验版
|
|
|
+ $miniCodeConfig['scene'] = 'id='.$id.'&shopId='.$companyid;
|
|
|
+ $res2 = $client->request('POST', 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token='.$tk, [
|
|
|
+ 'json' => $miniCodeConfig,
|
|
|
+ ]);
|
|
|
+ $fileName = md5($id);
|
|
|
+ $fileUrl = '/uploads/package/'.$fileName.'.png';
|
|
|
+ $code = $res2->getBody()->getContents();
|
|
|
+ file_put_contents(ROOT_PATH.'/public'.$fileUrl,$code);
|
|
|
+
|
|
|
+ $companyRes = Db::name('package')->where('id',$id)->update(['mini_code'=>$fileUrl]);
|
|
|
+ if ($companyRes === false) {
|
|
|
+ $this->error('生成套餐小程序码失败');
|
|
|
+ }
|
|
|
+ $miniCode = $httpStr.$fileUrl;
|
|
|
+ } else {
|
|
|
+ $miniCode = $httpStr.$package['mini_code'];
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->success('success',$miniCode);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成我的视频海报
|
|
|
+ //生成邀请码二维码图片
|
|
|
+ public function inviteimage($introcode = '') {
|
|
|
+ $params['text'] = config('h5_url') . '/#/pages/index/detail/detail?id=5&introcode=' . $introcode;
|
|
|
+ $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
|
|
|
+// $mimetype = 'image/png';
|
|
|
+// $response = Response::create()->header("Content-Type", $mimetype);
|
|
|
+
|
|
|
+ // 直接显示二维码
|
|
|
+// header('Content-Type: ' . $qrcode_service->getContentType());
|
|
|
+// $response->content($qrcode_service->writeString());
|
|
|
+ $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
|
|
|
+ if (!is_dir($qrcodePath)) {
|
|
|
+ @mkdir($qrcodePath);
|
|
|
+ }
|
|
|
+ if (is_really_writable($qrcodePath)) {
|
|
|
+ $filename = md5(implode('', $params)) . '.png';
|
|
|
+ $filePath = $qrcodePath . $filename;
|
|
|
+ $qrcode_service->writeFile($filePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ return '/uploads/qrcode/' . $filename;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //生成视频分享海报
|
|
|
+ public function shareposter() {
|
|
|
+ $id = input('video_id', 0, 'intval'); //id
|
|
|
+ if (!$id) {
|
|
|
+ $this->error('参数缺失');
|
|
|
+ }
|
|
|
+ $info = Db::name('video')->where('id',$id)->find();
|
|
|
+ if (!$info) {
|
|
|
+ $this->error('视频不存在');
|
|
|
+ }
|
|
|
+
|
|
|
+ $inviteimage = $this->inviteimage($this->auth->introcode);
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ [
|
|
|
+ "left"=> "10px",
|
|
|
+ "top"=> "250px",
|
|
|
+ "type"=> "img",
|
|
|
+ "width"=> "45px",
|
|
|
+ "height"=> "45px",
|
|
|
+ "src"=> one_domain_image($this->auth->avatar)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "left"=> "10px",
|
|
|
+ "top"=> "205px",
|
|
|
+ "type"=> "nickname",
|
|
|
+ "width"=> "166px",
|
|
|
+ "height"=> "38px",
|
|
|
+ "size"=> "11px",
|
|
|
+ "color"=> "#333333",
|
|
|
+ "content" => (iconv_strlen($info['name'], 'utf-8') <= 12 ? $info['name'] : mb_substr($info['name'], 0, 12) )
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "left"=> "60px",
|
|
|
+ "top"=> "270px",
|
|
|
+ "type"=> "nickname",
|
|
|
+ "width"=> "166px",
|
|
|
+ "height"=> "38px",
|
|
|
+ "size"=> "10px",
|
|
|
+ "color"=> "#666666",
|
|
|
+ "content" => (iconv_strlen($this->auth->nickname, 'utf-8') <= 8 ? $this->auth->nickname : mb_substr($this->auth->nickname, 0, 8))
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "left"=> "200px",
|
|
|
+ "top"=> "190px",
|
|
|
+ "type"=> "img",
|
|
|
+ "width"=> "110px",
|
|
|
+ "height"=> "110px",
|
|
|
+ "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ "left"=> "205px",
|
|
|
+ "top"=> "300px",
|
|
|
+ "type"=> "nickname",
|
|
|
+ "width"=> "166px",
|
|
|
+ "height"=> "38px",
|
|
|
+ "size"=> "9px",
|
|
|
+ "color"=> "#666666",
|
|
|
+ "content" => '长按扫码查看详情',
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ $data = json_encode($data, 320);
|
|
|
+
|
|
|
+ $poster = [
|
|
|
+ 'id' => 1,
|
|
|
+ 'title' => '测试',
|
|
|
+ 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
|
|
|
+ 'bg_image' => '/assets/img/posterbg.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;
|
|
|
+
|
|
|
+ //echo '<html><body><img src="'.$imgurl.'"></body></html>';exit;
|
|
|
+
|
|
|
+ $this->success('', $imgurl);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
}
|