|
@@ -117,22 +117,43 @@ class Product extends Auth{
|
|
public function get_poster(Model $Model){
|
|
public function get_poster(Model $Model){
|
|
// 接收参数
|
|
// 接收参数
|
|
$id = request('id',0);
|
|
$id = request('id',0);
|
|
- // 查询用户
|
|
|
|
|
|
+ // // 查询用户
|
|
$oldData = $Model->where(['id'=>$id])->first();
|
|
$oldData = $Model->where(['id'=>$id])->first();
|
|
- // 错误告知
|
|
|
|
|
|
+ // // 错误告知
|
|
if( !$oldData ) return $this->error('查无数据');
|
|
if( !$oldData ) return $this->error('查无数据');
|
|
|
|
+ // url有效期
|
|
|
|
+ $urlLink = $this->getUrlLink($id);
|
|
// 获取分享海报图片
|
|
// 获取分享海报图片
|
|
$result = $this->getShareImage('id='.$id,$oldData);
|
|
$result = $this->getShareImage('id='.$id,$oldData);
|
|
// 错误提示
|
|
// 错误提示
|
|
if( isset($result['error']) ) return $this->error($result['error']);
|
|
if( isset($result['error']) ) return $this->error($result['error']);
|
|
// 分配数据
|
|
// 分配数据
|
|
$this->assign('image',$result);
|
|
$this->assign('image',$result);
|
|
|
|
+ $this->assign('urlLink',$urlLink);
|
|
$this->assign('oldData',$oldData);
|
|
$this->assign('oldData',$oldData);
|
|
$this->assign('crumbs','海报');
|
|
$this->assign('crumbs','海报');
|
|
// 加载模板
|
|
// 加载模板
|
|
return $this->fetch();
|
|
return $this->fetch();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取小程序链接
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ private function getUrlLink($id){
|
|
|
|
+ // 结果数据
|
|
|
|
+ $link = cache('admin:product:urllink:product_id'.$id);
|
|
|
|
+ // 不存在数据
|
|
|
|
+ if ( is_null($link) ) {
|
|
|
|
+ // 从数据库获取数据
|
|
|
|
+ $link = Mini::getUrlLink('pages/product/index','product_id='.$id);
|
|
|
|
+ // 存起来
|
|
|
|
+ cache(['admin:product:urllink:product_id'.$id=>$link],$link ? now()->addDays(23) : now()->addMinutes(3));
|
|
|
|
+ }
|
|
|
|
+ // 返回结果
|
|
|
|
+ return $link;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 获取分享海报图片
|
|
* 获取分享海报图片
|
|
* @param int $scene 场景值
|
|
* @param int $scene 场景值
|