commit
6dcd77de8e
@ -0,0 +1,118 @@ |
||||
<?php |
||||
|
||||
namespace app\common\service\qrcode; |
||||
|
||||
use app\common\model\User as UserModel; |
||||
use cores\exception\BaseException; |
||||
use Exception; |
||||
use Grafika\Grafika; |
||||
use think\db\exception\DataNotFoundException; |
||||
use think\db\exception\DbException; |
||||
use think\db\exception\ModelNotFoundException; |
||||
use function base_url; |
||||
|
||||
class InviteUser extends BaseQRcode |
||||
{ |
||||
// 当前客户端 (默认H5) |
||||
private string $channel; |
||||
|
||||
// 用户信息 |
||||
private UserModel $userInfo; |
||||
|
||||
/** |
||||
* 构造方法 |
||||
* Goods constructor. |
||||
* @param UserModel $userInfo |
||||
* @param string $channel 二维码渠道(小程序码、h5码) |
||||
*/ |
||||
public function __construct(UserModel $userInfo, string $channel = 'H5') |
||||
{ |
||||
parent::__construct(); |
||||
// 用户信息 |
||||
$this->userInfo = $userInfo; |
||||
// 当前客户端 |
||||
$this->channel = $channel; |
||||
} |
||||
|
||||
/** |
||||
* 拼接海报图 |
||||
* @return string |
||||
* @throws BaseException |
||||
* @throws DataNotFoundException |
||||
* @throws DbException |
||||
* @throws ModelNotFoundException |
||||
* @throws Exception |
||||
*/ |
||||
public function getImage(): string |
||||
{ |
||||
// 判断海报图文件存在则直接返回url |
||||
if (file_exists($this->getPosterPath())) { |
||||
return $this->getPosterUrl(); |
||||
} |
||||
// 商城ID |
||||
$storeId = $this->userInfo['store_id']; |
||||
// 商品海报背景图 |
||||
$backdrop = __DIR__ . '/resource/invite_user.png'; |
||||
// 小程序码参数 |
||||
$scene = "refereeId:" . ($this->userInfo['user_id'] ?: ''); |
||||
// 下载小程序码 |
||||
$page = 'pages/login/index'; |
||||
$qrcode = $this->getQrcode($storeId, $scene, $page, $this->channel); |
||||
// 拼接海报图 |
||||
return $this->savePoster($backdrop, $qrcode); |
||||
} |
||||
|
||||
/** |
||||
* 拼接海报图 |
||||
* @param string $backdrop 背景图路径 |
||||
* @param string $qrcode 二维码图路径 |
||||
* @return string |
||||
* @throws Exception |
||||
*/ |
||||
private function savePoster(string $backdrop, string $qrcode): string |
||||
{ |
||||
// 实例化图像编辑器 |
||||
$editor = Grafika::createEditor(['Gd']); |
||||
// 打开海报背景图 |
||||
$editor->open($backdropImage, $backdrop); |
||||
// 打开小程序码 |
||||
$editor->open($qrcodeImage, $qrcode); |
||||
// 重设小程序码宽高 |
||||
$editor->resizeExact($qrcodeImage, 140, 140); |
||||
// 小程序码添加到背景图 |
||||
$editor->blend($backdropImage, $qrcodeImage, 'normal', 1.0, 'top-left', 520, 700); |
||||
// 保存图片 |
||||
$editor->save($backdropImage, $this->getPosterPath()); |
||||
return $this->getPosterUrl(); |
||||
} |
||||
|
||||
/** |
||||
* 海报图文件路径 |
||||
* @return string |
||||
*/ |
||||
private function getPosterPath(): string |
||||
{ |
||||
// 保存路径 |
||||
$tempPath = web_path() . "temp/{$this->userInfo['store_id']}/"; |
||||
!is_dir($tempPath) && mkdir($tempPath, 0755, true); |
||||
return $tempPath . $this->getPosterName(); |
||||
} |
||||
|
||||
/** |
||||
* 海报图文件名称 |
||||
* @return string |
||||
*/ |
||||
private function getPosterName(): string |
||||
{ |
||||
return 'invite_' . md5("{$this->userInfo['user_id']}_$this->channel") . '.png'; |
||||
} |
||||
|
||||
/** |
||||
* 海报图url |
||||
* @return string |
||||
*/ |
||||
private function getPosterUrl(): string |
||||
{ |
||||
return base_url() . 'temp/' . $this->userInfo['store_id'] . '/' . $this->getPosterName() . '?t=' . time(); |
||||
} |
||||
} |
After Width: | Height: | Size: 362 KiB |
@ -0,0 +1,76 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace app\store\controller\content; |
||||
|
||||
use think\response\Json; |
||||
use app\store\controller\Controller; |
||||
use app\store\model\Banner as BannerModel; |
||||
|
||||
/** |
||||
* Banner管理 |
||||
* Class Carousel |
||||
* @package app\store\controller\content |
||||
*/ |
||||
class Banner extends Controller |
||||
{ |
||||
/** |
||||
* 获取列表记录 |
||||
* @return Json |
||||
* @throws \think\db\exception\DbException |
||||
*/ |
||||
public function list(): Json |
||||
{ |
||||
$model = new BannerModel; |
||||
$list = $model->getList(); |
||||
return $this->renderSuccess(compact('list')); |
||||
} |
||||
|
||||
/** |
||||
* 添加Banner |
||||
* @return Json |
||||
*/ |
||||
public function add(): Json |
||||
{ |
||||
// 新增记录 |
||||
$model = new BannerModel; |
||||
|
||||
if ($model->add($this->postForm())) { |
||||
return $this->renderSuccess('添加成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '添加失败'); |
||||
} |
||||
|
||||
/** |
||||
* 更新Banner |
||||
* @param int $bannerId |
||||
* @return Json |
||||
*/ |
||||
public function edit(int $bannerId): Json |
||||
{ |
||||
// Banner详情 |
||||
$model = BannerModel::detail($bannerId); |
||||
// 更新记录 |
||||
if ($model->edit($this->postForm())) { |
||||
return $this->renderSuccess('更新成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '更新失败'); |
||||
} |
||||
|
||||
/** |
||||
* 删除Banner |
||||
* @param int $bannerId |
||||
* @return Json |
||||
*/ |
||||
public function delete(int $bannerId): Json |
||||
{ |
||||
// Banner详情 |
||||
$model = BannerModel::detail($bannerId); |
||||
// 删除记录 |
||||
if ($model->setDelete()) { |
||||
return $this->renderSuccess('删除成功'); |
||||
} |
||||
return $this->renderError($model->getError() ?: '删除失败'); |
||||
} |
||||
} |
@ -0,0 +1,75 @@ |
||||
<?php |
||||
// +---------------------------------------------------------------------- |
||||
// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ] |
||||
// +---------------------------------------------------------------------- |
||||
// | Copyright (c) 2017~2023 https://www.yiovo.com All rights reserved. |
||||
// +---------------------------------------------------------------------- |
||||
// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行 |
||||
// +---------------------------------------------------------------------- |
||||
// | Author: 萤火科技 <admin@yiovo.com> |
||||
// +---------------------------------------------------------------------- |
||||
declare(strict_types=1); |
||||
|
||||
namespace app\store\model; |
||||
|
||||
use app\common\model\Banner as BannerModel; |
||||
|
||||
/** |
||||
* 模型类:帮助中心 |
||||
* Class Help |
||||
* @package app\store\model |
||||
*/ |
||||
class Banner extends BannerModel |
||||
{ |
||||
/** |
||||
* 获取列表记录 |
||||
* @return \think\Paginator |
||||
* @throws \think\db\exception\DbException |
||||
*/ |
||||
public function getList(): \think\Paginator |
||||
{ |
||||
$data = $this->order(['sort' => 'asc', 'create_time' => 'desc'])->paginate(); |
||||
return self::preload($data, ['image']); |
||||
} |
||||
|
||||
/** |
||||
* 详情 |
||||
* @param mixed $bannerId |
||||
* @param array $with |
||||
* @return static|array|null |
||||
*/ |
||||
public static function detail($bannerId, array $with = []) |
||||
{ |
||||
return self::get($bannerId, $with); |
||||
} |
||||
|
||||
/** |
||||
* 新增记录 |
||||
* @param array $data |
||||
* @return bool|false |
||||
*/ |
||||
public function add(array $data): bool |
||||
{ |
||||
$data['store_id'] = self::$storeId; |
||||
return $this->save($data); |
||||
} |
||||
|
||||
/** |
||||
* 更新记录 |
||||
* @param array $data |
||||
* @return bool |
||||
*/ |
||||
public function edit(array $data): bool |
||||
{ |
||||
return $this->save($data) !== false; |
||||
} |
||||
|
||||
/** |
||||
* 删除记录 |
||||
* @return bool |
||||
*/ |
||||
public function setDelete(): bool |
||||
{ |
||||
return $this->delete(); |
||||
} |
||||
} |
@ -1 +1 @@ |
||||
<!DOCTYPE html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>商家管理中心</title><style>#loading-mask{position:fixed;left:0;top:0;height:100%;width:100%;background:#fff;user-select:none;z-index:9999;overflow:hidden}.loading-wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-100%)}.loading-dot{animation:antRotate 1.2s infinite linear;transform:rotate(45deg);position:relative;display:inline-block;font-size:64px;width:64px;height:64px;box-sizing:border-box}.loading-dot i{width:22px;height:22px;position:absolute;display:block;background-color:#1890ff;border-radius:100%;transform:scale(.75);transform-origin:50% 50%;opacity:.3;animation:antSpinMove 1s infinite linear alternate}.loading-dot i:nth-child(1){top:0;left:0}.loading-dot i:nth-child(2){top:0;right:0;-webkit-animation-delay:.4s;animation-delay:.4s}.loading-dot i:nth-child(3){right:0;bottom:0;-webkit-animation-delay:.8s;animation-delay:.8s}.loading-dot i:nth-child(4){bottom:0;left:0;-webkit-animation-delay:1.2s;animation-delay:1.2s}@keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@-webkit-keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@keyframes antSpinMove{to{opacity:1}}@-webkit-keyframes antSpinMove{to{opacity:1}}</style><link href="css/bargain.aaf513d0.css" rel="prefetch"><link href="css/bargain~client~collector~content~dealer~eorder~goods~groupon~live~manage~market~order~page~server~se~a0a5d3c7.8e8dd5a1.css" rel="prefetch"><link href="css/client.a6cbdfac.css" rel="prefetch"><link href="css/collector.306c5f1f.css" rel="prefetch"><link href="css/content.949483f8.css" rel="prefetch"><link href="css/dealer.33c053df.css" rel="prefetch"><link href="css/eorder.af369ba5.css" rel="prefetch"><link href="css/goods.df12bc83.css" rel="prefetch"><link href="css/groupon.d7e493ca.css" rel="prefetch"><link href="css/index.65686232.css" rel="prefetch"><link href="css/market.438e7dd1.css" rel="prefetch"><link href="css/order.34562fba.css" rel="prefetch"><link href="css/page.5cf12993.css" rel="prefetch"><link href="css/passport.27257d2f.css" rel="prefetch"><link href="css/server.1583280e.css" rel="prefetch"><link href="css/setting.be935862.css" rel="prefetch"><link href="css/sharp.0237f2d1.css" rel="prefetch"><link href="css/statistics.6d805d57.css" rel="prefetch"><link href="css/store.93c41389.css" rel="prefetch"><link href="css/user.806b728e.css" rel="prefetch"><link href="js/bargain.027c2e96.js" rel="prefetch"><link href="js/bargain~client~collector~content~dealer~eorder~goods~groupon~live~manage~market~order~page~server~se~a0a5d3c7.6e8a1919.js" rel="prefetch"><link href="js/client.f9b450e7.js" rel="prefetch"><link href="js/collector.95239533.js" rel="prefetch"><link href="js/content.c8100b63.js" rel="prefetch"><link href="js/dealer.46441193.js" rel="prefetch"><link href="js/dealer~page~store.c1e7aeb9.js" rel="prefetch"><link href="js/eorder.6901a2af.js" rel="prefetch"><link href="js/exception.4f918b59.js" rel="prefetch"><link href="js/goods.69355d87.js" rel="prefetch"><link href="js/groupon.ca1a1258.js" rel="prefetch"><link href="js/index.bb016803.js" rel="prefetch"><link href="js/index~statistics.5ed2ab05.js" rel="prefetch"><link href="js/lang-zh-CN.8c571402.js" rel="prefetch"><link href="js/live.ab3fb0ef.js" rel="prefetch"><link href="js/manage.80527b44.js" rel="prefetch"><link href="js/market.8a48277d.js" rel="prefetch"><link href="js/order.8721f729.js" rel="prefetch"><link href="js/page.e2ad1a4a.js" rel="prefetch"><link href="js/passport.54223076.js" rel="prefetch"><link href="js/server.d3274e64.js" rel="prefetch"><link href="js/setting.8281d8f9.js" rel="prefetch"><link href="js/sharp.bd4c7d3f.js" rel="prefetch"><link href="js/statistics.5cc66089.js" rel="prefetch"><link href="js/store.9bd38dea.js" rel="prefetch"><link href="js/user.7b8d38e7.js" rel="prefetch"><link href="css/app.0bf46b1d.css" rel="preload" as="style"><link href="css/chunk-vendors.35626c22.css" rel="preload" as="style"><link href="js/app.12748f9b.js" rel="preload" as="script"><link href="js/chunk-vendors.87848c69.js" rel="preload" as="script"><link href="css/chunk-vendors.35626c22.css" rel="stylesheet"><link href="css/app.0bf46b1d.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but vue-antd-pro doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"><div id="loading-mask"><div class="loading-wrapper"><span class="loading-dot loading-dot-spin"><i></i><i></i><i></i><i></i></span></div></div></div><script src="config.js"></script><script src="js/chunk-vendors.87848c69.js"></script><script src="js/app.12748f9b.js"></script></body></html> |
||||
<!DOCTYPE html><html lang="zh-cmn-Hans"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>商家管理中心</title><style>#loading-mask{position:fixed;left:0;top:0;height:100%;width:100%;background:#fff;user-select:none;z-index:9999;overflow:hidden}.loading-wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-100%)}.loading-dot{animation:antRotate 1.2s infinite linear;transform:rotate(45deg);position:relative;display:inline-block;font-size:64px;width:64px;height:64px;box-sizing:border-box}.loading-dot i{width:22px;height:22px;position:absolute;display:block;background-color:#1890ff;border-radius:100%;transform:scale(.75);transform-origin:50% 50%;opacity:.3;animation:antSpinMove 1s infinite linear alternate}.loading-dot i:nth-child(1){top:0;left:0}.loading-dot i:nth-child(2){top:0;right:0;-webkit-animation-delay:.4s;animation-delay:.4s}.loading-dot i:nth-child(3){right:0;bottom:0;-webkit-animation-delay:.8s;animation-delay:.8s}.loading-dot i:nth-child(4){bottom:0;left:0;-webkit-animation-delay:1.2s;animation-delay:1.2s}@keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@-webkit-keyframes antRotate{to{-webkit-transform:rotate(405deg);transform:rotate(405deg)}}@keyframes antSpinMove{to{opacity:1}}@-webkit-keyframes antSpinMove{to{opacity:1}}</style><link href="css/bargain.aaf513d0.css" rel="prefetch"><link href="css/bargain~client~collector~content~dealer~eorder~goods~groupon~live~manage~market~order~page~server~se~a0a5d3c7.8e8dd5a1.css" rel="prefetch"><link href="css/client.a6cbdfac.css" rel="prefetch"><link href="css/collector.306c5f1f.css" rel="prefetch"><link href="css/content.949483f8.css" rel="prefetch"><link href="css/dealer.33c053df.css" rel="prefetch"><link href="css/eorder.af369ba5.css" rel="prefetch"><link href="css/goods.df12bc83.css" rel="prefetch"><link href="css/groupon.d7e493ca.css" rel="prefetch"><link href="css/index.65686232.css" rel="prefetch"><link href="css/market.438e7dd1.css" rel="prefetch"><link href="css/order.34562fba.css" rel="prefetch"><link href="css/page.5cf12993.css" rel="prefetch"><link href="css/passport.27257d2f.css" rel="prefetch"><link href="css/server.1583280e.css" rel="prefetch"><link href="css/setting.be935862.css" rel="prefetch"><link href="css/sharp.0237f2d1.css" rel="prefetch"><link href="css/statistics.6d805d57.css" rel="prefetch"><link href="css/store.93c41389.css" rel="prefetch"><link href="css/user.806b728e.css" rel="prefetch"><link href="js/bargain.027c2e96.js" rel="prefetch"><link href="js/bargain~client~collector~content~dealer~eorder~goods~groupon~live~manage~market~order~page~server~se~a0a5d3c7.6e8a1919.js" rel="prefetch"><link href="js/client.f9b450e7.js" rel="prefetch"><link href="js/collector.95239533.js" rel="prefetch"><link href="js/content.1d9035ce.js" rel="prefetch"><link href="js/dealer.46441193.js" rel="prefetch"><link href="js/dealer~page~store.c1e7aeb9.js" rel="prefetch"><link href="js/eorder.6901a2af.js" rel="prefetch"><link href="js/exception.4f918b59.js" rel="prefetch"><link href="js/goods.69355d87.js" rel="prefetch"><link href="js/groupon.ca1a1258.js" rel="prefetch"><link href="js/index.bb016803.js" rel="prefetch"><link href="js/index~statistics.5ed2ab05.js" rel="prefetch"><link href="js/lang-zh-CN.8c571402.js" rel="prefetch"><link href="js/live.ab3fb0ef.js" rel="prefetch"><link href="js/manage.80527b44.js" rel="prefetch"><link href="js/market.8a48277d.js" rel="prefetch"><link href="js/order.8721f729.js" rel="prefetch"><link href="js/page.e2ad1a4a.js" rel="prefetch"><link href="js/passport.54223076.js" rel="prefetch"><link href="js/server.d3274e64.js" rel="prefetch"><link href="js/setting.8281d8f9.js" rel="prefetch"><link href="js/sharp.bd4c7d3f.js" rel="prefetch"><link href="js/statistics.5cc66089.js" rel="prefetch"><link href="js/store.9bd38dea.js" rel="prefetch"><link href="js/user.7b8d38e7.js" rel="prefetch"><link href="css/app.fab9b2e3.css" rel="preload" as="style"><link href="css/chunk-vendors.35626c22.css" rel="preload" as="style"><link href="js/app.efeaecac.js" rel="preload" as="script"><link href="js/chunk-vendors.87848c69.js" rel="preload" as="script"><link href="css/chunk-vendors.35626c22.css" rel="stylesheet"><link href="css/app.fab9b2e3.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but vue-antd-pro doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"><div id="loading-mask"><div class="loading-wrapper"><span class="loading-dot loading-dot-spin"><i></i><i></i><i></i><i></i></span></div></div></div><script src="config.js"></script><script src="js/chunk-vendors.87848c69.js"></script><script src="js/app.efeaecac.js"></script></body></html> |
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue