Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
shirne committed Jul 27, 2024
1 parent dbe01fd commit ac31372
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/application/api/controller/member/AgentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public function poster($page = 'pages/index/index')

try {
$userModel = MemberModel::where('id', $this->user['id'])->find();
$url = $userModel->getSharePoster($platform, $page);
$url = $userModel->getSharePoster($platform . '-' . $this->request->tokenData['appid'], $page);
} catch (\Exception $e) {
$this->error($e->getMessage());
}
Expand Down
15 changes: 10 additions & 5 deletions src/application/common/model/MemberModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,12 @@ public function getSharePoster($platform, $page, $force = false)
$this->setError('会员没有推广码');
return false;
}
$parts = explode('-', $platform);
$appid = '';
if (count($parts) > 2) {
$platform = $parts[0] . '-' . $parts[1];
$appid = $parts[2];
}
$sharepath = './uploads/share/' . ($this['id'] % 100) . '/' . $this['agentcode'] . '-' . $platform . '.jpg';

$config = $this->get_poster_config();
Expand All @@ -581,9 +587,9 @@ public function getSharePoster($platform, $page, $force = false)
}
}
if (in_array($platform, ['wechat-miniprogram', 'wechat-minigame'])) {
$created = $this->create_appcode_img($config, $sharepath, $page);
$created = $this->create_appcode_img($config, $appid, $sharepath, $page);
} else {
$created = $this->create_share_img($config, $sharepath, $page);
$created = $this->create_share_img($config, $appid, $sharepath, $page);
}
if (!$created) return $created;
return media(ltrim($sharepath, '.'));
Expand Down Expand Up @@ -615,7 +621,7 @@ private function get_poster_config()
return $config;
}

private function create_share_img($config, $sharepath, $page)
private function create_share_img($config, $appid, $sharepath, $page)
{
if (strpos($page, $this['agentcode']) === false) {
$this->setError('分享链接错误');
Expand Down Expand Up @@ -647,9 +653,8 @@ private function create_share_img($config, $sharepath, $page)
$poster->save($sharepath);
return true;
}
private function create_appcode_img($config, $sharepath, $page)
private function create_appcode_img($config, $appid, $sharepath, $page)
{
$appid = request()->tokenData['appid'];
$wechat = WechatModel::where('appid', $appid)->find();
if (empty($wechat)) {
$this->setError('分享图生成失败(wechat)');
Expand Down
2 changes: 1 addition & 1 deletion src/application/task/controller/UtilController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function poster($key)
if (empty($account)) {
exit('NA');
}
$poster = $userModel->getSharePoster($account['type'] . '-' . $account['account_type'], str_replace('[code]', $userModel['agentcode'], $account['share_poster_url']));
$poster = $userModel->getSharePoster($account['type'] . '-' . $account['account_type'] . '-' . $account['id'], str_replace('[code]', $userModel['agentcode'], $account['share_poster_url']));
if (empty($poster)) {
exit('NP');
}
Expand Down

0 comments on commit ac31372

Please sign in to comment.