|
@@ -16,6 +16,9 @@ use App\Models\Product\City as ProductCity;
|
|
use App\Models\ProductPhoto;
|
|
use App\Models\ProductPhoto;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
use App\Models\WeiBan\Tags as WeiBanTags;
|
|
use App\Models\WeiBan\Tags as WeiBanTags;
|
|
|
|
+use Intervention\Image\Facades\Image;
|
|
|
|
+use Intervention\Image\Gd\Font;
|
|
|
|
+use App\Facades\Servers\WechatMini\Mini;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 产品管理
|
|
* 产品管理
|
|
@@ -107,6 +110,79 @@ class Product extends Auth{
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取小程序海报
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ public function get_poster(Model $Model){
|
|
|
|
+ // 接收参数
|
|
|
|
+ $id = request('id',0);
|
|
|
|
+ // 查询用户
|
|
|
|
+ $oldData = $Model->where(['id'=>$id])->first();
|
|
|
|
+ // 错误告知
|
|
|
|
+ if( !$oldData ) return $this->error('查无数据');
|
|
|
|
+ // 获取分享海报图片
|
|
|
|
+ $result = $this->getShareImage('id='.$id,$oldData);
|
|
|
|
+ // 错误提示
|
|
|
|
+ if( isset($result['error']) ) return $this->error($result['error']);
|
|
|
|
+ // 分配数据
|
|
|
|
+ $this->assign('image',$result);
|
|
|
|
+ $this->assign('oldData',$oldData);
|
|
|
|
+ $this->assign('crumbs','海报');
|
|
|
|
+ // 加载模板
|
|
|
|
+ return $this->fetch();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取分享海报图片
|
|
|
|
+ * @param int $scene 场景值
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ private function getShareImage($scene,$oldData){
|
|
|
|
+ // 尝试执行
|
|
|
|
+ try {
|
|
|
|
+ // 加载图片
|
|
|
|
+ $image = Image::make(public_path('uploads/images/poster/').'product.png');
|
|
|
|
+ // 产品缩略图
|
|
|
|
+ $thumb = Image::make(path_compat($oldData['thumb']))->resize(1000,1000);
|
|
|
|
+ // 设置文字样式(字体、大小、颜色等)
|
|
|
|
+ $fontPath = public_path().'/fonts/msyh14.ttf';// 指定字体文件路径
|
|
|
|
+ // 生成小程序二维码
|
|
|
|
+ $qrcode = Mini::getUnlimit($scene,['page'=>'pages/product/index','width'=>280,'is_hyaline'=>true]);
|
|
|
|
+ // 错误提示
|
|
|
|
+ if( isset($qrcode['error']) ) return $qrcode;
|
|
|
|
+ // 加载图片
|
|
|
|
+ $qrcode = Image::make($qrcode)->resize(250,250);
|
|
|
|
+ // 插入图片
|
|
|
|
+ $image->insert($thumb,'top-center',0,130);
|
|
|
|
+ // 插入图片
|
|
|
|
+ $image->insert($qrcode,'bottom-left',120,120);
|
|
|
|
+ // 给图片写入文字
|
|
|
|
+ $image->text('¥'.$oldData['price'], 360,1280,function (Font $font) use ($fontPath) {
|
|
|
|
+ $font->file($fontPath); // 字体文件地址
|
|
|
|
+ $font->size(88); // 字体大小
|
|
|
|
+ $font->color('#333333');
|
|
|
|
+ $font->align('left');
|
|
|
|
+ });
|
|
|
|
+ // 给图片写入文字
|
|
|
|
+ $image->text($oldData['name'], 120,1380,function (Font $font) use ($fontPath) {
|
|
|
|
+ $font->file($fontPath); // 字体文件地址
|
|
|
|
+ $font->size(48); // 字体大小
|
|
|
|
+ $font->color('#333333');
|
|
|
|
+ $font->align('left');
|
|
|
|
+ });
|
|
|
|
+ // 转码成字符串
|
|
|
|
+ $image = $image->encode('jpg', 90)->__toString();
|
|
|
|
+ // 转base64
|
|
|
|
+ $base64 = 'data:image/jpg;base64,' . base64_encode($image);
|
|
|
|
+ // 返回结果
|
|
|
|
+ return $base64;
|
|
|
|
+ } catch (\Throwable $th) {
|
|
|
|
+ // 错误提示
|
|
|
|
+ return ['error'=>$th->getMessage()];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 添加
|
|
* 添加
|
|
*
|
|
*
|
|
@@ -125,6 +201,7 @@ class Product extends Auth{
|
|
$data['producer_id'] = request('producer_id',0);
|
|
$data['producer_id'] = request('producer_id',0);
|
|
$data['business_id'] = request('business_id',0);
|
|
$data['business_id'] = request('business_id',0);
|
|
$data['quota'] = request('quota',0);
|
|
$data['quota'] = request('quota',0);
|
|
|
|
+ $data['min_quota'] = request('min_quota',0);
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['puton_time'] = request('puton_time','');
|
|
$data['puton_time'] = request('puton_time','');
|
|
@@ -326,6 +403,7 @@ class Product extends Auth{
|
|
$data['price'] = request('price',0);
|
|
$data['price'] = request('price',0);
|
|
$data['market_price'] = request('market_price',0);
|
|
$data['market_price'] = request('market_price',0);
|
|
$data['quota'] = request('quota',0);
|
|
$data['quota'] = request('quota',0);
|
|
|
|
+ $data['min_quota'] = request('min_quota',0);
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['puton_time'] = request('puton_time','');
|
|
$data['puton_time'] = request('puton_time','');
|
|
@@ -562,6 +640,7 @@ class Product extends Auth{
|
|
$data['producer_id'] = request('producer_id',0);
|
|
$data['producer_id'] = request('producer_id',0);
|
|
$data['business_id'] = request('business_id',0);
|
|
$data['business_id'] = request('business_id',0);
|
|
$data['quota'] = request('quota',0);
|
|
$data['quota'] = request('quota',0);
|
|
|
|
+ $data['min_quota'] = request('min_quota',0);
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_start'] = request('quota_start','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['quota_end'] = request('quota_end','');
|
|
$data['stock'] = request('stock',0);
|
|
$data['stock'] = request('stock',0);
|