前端分流页功能
This commit is contained in:
@@ -9,6 +9,7 @@ use app\common\controller\Backend;
|
||||
use app\common\library\CountryIso;
|
||||
use app\common\service\SplitAutoReplyService;
|
||||
use app\common\service\SplitLinkCodeService;
|
||||
use app\common\service\SplitPixelConfigService;
|
||||
use app\common\service\SplitPlatformDomainService;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
@@ -224,8 +225,8 @@ class Link extends Backend
|
||||
$this->success('', null, [
|
||||
'platform_domains' => $platformDomains,
|
||||
'my_domains' => $myDomains,
|
||||
'domain_index_url' => (string) url('domain/index'),
|
||||
'domain_add_url' => (string) url('domain/add'),
|
||||
'domain_index_url' => (string) url('domain', '', false, false),
|
||||
'domain_add_url' => (string) url('domain/add', '', false, false),
|
||||
'config_index_url' => (string) url('general/config/index'),
|
||||
]);
|
||||
}
|
||||
@@ -284,6 +285,58 @@ class Link extends Backend
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 像素配置:读取 / 保存
|
||||
*
|
||||
* @param string|null $ids 链接 ID
|
||||
* @return Json
|
||||
* @throws DbException
|
||||
*/
|
||||
public function pixel($ids = null): Json
|
||||
{
|
||||
$row = $this->model->get($ids);
|
||||
if (!$row) {
|
||||
$this->error(__('No Results were found'));
|
||||
}
|
||||
|
||||
$adminIds = $this->getDataLimitAdminIds();
|
||||
if (is_array($adminIds) && !in_array((int) $row[$this->dataLimitField], $adminIds, true)) {
|
||||
$this->error(__('You have no permission'));
|
||||
}
|
||||
|
||||
if ($this->request->isPost()) {
|
||||
$payload = $this->request->post('pixel_config/a', []);
|
||||
if ($payload === []) {
|
||||
$raw = (string) $this->request->post('pixel_config', '');
|
||||
$decoded = json_decode($raw, true);
|
||||
$payload = is_array($decoded) ? $decoded : [];
|
||||
}
|
||||
$existing = SplitPixelConfigService::parseStorage((string) $row->getAttr('pixel_config'));
|
||||
try {
|
||||
$merged = SplitPixelConfigService::mergeForSave($payload, $existing);
|
||||
$row->save([
|
||||
'pixel_config' => SplitPixelConfigService::encodeStorage($merged),
|
||||
]);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
$this->error($e->getMessage());
|
||||
} catch (PDOException|Exception $e) {
|
||||
$this->error($e->getMessage());
|
||||
}
|
||||
$this->success(__('Pixel config saved'));
|
||||
}
|
||||
|
||||
$config = SplitPixelConfigService::parseStorage((string) $row->getAttr('pixel_config'));
|
||||
$masked = SplitPixelConfigService::maskForAdmin($config);
|
||||
|
||||
$this->success('', null, [
|
||||
'id' => (int) $row['id'],
|
||||
'link_code' => (string) $row['link_code'],
|
||||
'facebook' => $masked[SplitPixelConfigService::PLATFORM_FACEBOOK],
|
||||
'tiktok' => $masked[SplitPixelConfigService::PLATFORM_TIKTOK],
|
||||
'event_options' => SplitPixelConfigService::EVENT_OPTIONS,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑(分流链接码不可修改)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user