|
@@ -19,6 +19,7 @@ use Dcat\Admin\FormStep\Form as StepForm;
|
|
|
use Dcat\Admin\Traits\HasUploadedFile;
|
|
|
use Dcat\Admin\Widgets\Alert;
|
|
|
use App\Console\Commands\TimerSsmPost;
|
|
|
+use phpseclib3\Crypt\EC\BaseCurves\Montgomery;
|
|
|
|
|
|
class SmmPostController extends AdminDistController
|
|
|
{
|
|
@@ -109,6 +110,9 @@ class SmmPostController extends AdminDistController
|
|
|
return $this->upload();
|
|
|
}
|
|
|
if (isset($post['ALL_STEPS']) && $post['ALL_STEPS'] == '1') {
|
|
|
+ if ($post['account_ids'] == [] || count($post['account_ids']) == 0 || $post['account_ids'] == '' || empty($post['account_ids'][0])) {
|
|
|
+ return Admin::json()->error('请选择社媒帐号');
|
|
|
+ }
|
|
|
$post_type = $post['post_type'];
|
|
|
if ($post_type == 0) {
|
|
|
$image_video_url = $post['image_url'];
|
|
@@ -118,13 +122,16 @@ class SmmPostController extends AdminDistController
|
|
|
$post['message'] = $post['video_message'];
|
|
|
}
|
|
|
if ($this->checkStoragePath($image_video_url) === false) {
|
|
|
- return '发送失败,请检查上传文件是否存在';
|
|
|
+ return Admin::json()->error('请检查上传文件是否存在');
|
|
|
}
|
|
|
if ($post['send_type'] == 0) {
|
|
|
$send_time = Carbon::now();
|
|
|
} else {
|
|
|
- //转换时间格式
|
|
|
- $send_time = Carbon::createFromFormat('Y-m-d H:i:s', $post['send_time']);
|
|
|
+ // 從北京時間字符串創建 Carbon 對象
|
|
|
+ $sendTime = Carbon::createFromFormat('Y-m-d H:i:s', $post['send_time'], 'Asia/Shanghai');
|
|
|
+ // 轉換為 UTC 時間
|
|
|
+ $send_time = $sendTime->setTimezone('UTC');
|
|
|
+ // $send_time = Carbon::createFromFormat('Y-m-d H:i:s', $post['send_time'])->setTimezone('UTC');
|
|
|
}
|
|
|
//保存数据
|
|
|
SmmPost::create($post,$send_time,$image_video_url);
|
|
@@ -183,6 +190,66 @@ class SmmPostController extends AdminDistController
|
|
|
//JS 验证参数不能为空
|
|
|
if ($index == 0) {
|
|
|
$step->leaving(<<<JS
|
|
|
+
|
|
|
+// 全局缓存对象,存储被移除的YouTube选项 {selectName: jQueryObject}
|
|
|
+function toggleYouTube(flag) {
|
|
|
+ var \$this = \$(this);
|
|
|
+
|
|
|
+ // 定义选择器
|
|
|
+ var youtubeSelector = 'option:contains("(YouTube)")';
|
|
|
+ var \$helper1 = \$('select[name="account_ids[]_helper1"]');
|
|
|
+ var \$helper2 = \$('select[name="account_ids[]_helper2"]');
|
|
|
+ var \$mainSelect = \$('select[name="account_ids[]"]');
|
|
|
+
|
|
|
+ // 初始化数据存储
|
|
|
+ if (!\$this.data('youtubeOptions')) {
|
|
|
+ \$this.data('youtubeOptions', {
|
|
|
+ helper1: \$helper1.find(youtubeSelector).clone(true),
|
|
|
+ helper2: \$helper2.find(youtubeSelector).clone(true),
|
|
|
+ main: \$mainSelect.find(youtubeSelector).clone(true),
|
|
|
+ positions: { // 记录原始位置
|
|
|
+ helper1: \$helper1.find(youtubeSelector).index(),
|
|
|
+ helper2: \$helper2.find(youtubeSelector).index(),
|
|
|
+ main: \$mainSelect.find(youtubeSelector).index()
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 通用移除函数
|
|
|
+ function removeYouTubeOptions(\$container) {
|
|
|
+ \$container.find(youtubeSelector).each(function() {
|
|
|
+ \$(this).detach(); // 使用 detach 保留事件和数据的引用
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // 移除所有 YouTube 选项
|
|
|
+ removeYouTubeOptions(\$helper1);
|
|
|
+ removeYouTubeOptions(\$helper2);
|
|
|
+ removeYouTubeOptions(\$mainSelect);
|
|
|
+
|
|
|
+ // 还原逻辑
|
|
|
+ if (flag === false) {
|
|
|
+ var saved = \$this.data('youtubeOptions');
|
|
|
+
|
|
|
+ // 精确还原到原始位置
|
|
|
+ saved.helper1.insertAfter(
|
|
|
+ \$helper1.find('option').eq(saved.positions.helper1 - 1)
|
|
|
+ );
|
|
|
+
|
|
|
+ saved.helper2.insertAfter(
|
|
|
+ \$helper2.find('option').eq(saved.positions.helper2 - 1)
|
|
|
+ );
|
|
|
+
|
|
|
+ saved.main.insertAfter(
|
|
|
+ \$mainSelect.find('option').eq(saved.positions.main - 1)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ //把选择账号全部向左移
|
|
|
+ $(".removeall ").click();
|
|
|
+ //隐藏youtube 分类
|
|
|
+ $('#select_hide_youtube_category').toggle(false);
|
|
|
+}
|
|
|
+
|
|
|
function validateForm(formArray) {
|
|
|
lang = '{$lang}';
|
|
|
// 仅获取radio类型的post_type值
|
|
@@ -206,6 +273,8 @@ function validateForm(formArray) {
|
|
|
return '帖子留言和图片不能为空';
|
|
|
}
|
|
|
}
|
|
|
+ //隐藏youtube的帐号
|
|
|
+ toggleYouTube(true);
|
|
|
} else if (postType === '1') {
|
|
|
const videoMessage = formArray.find(item => item.name === 'video_message')?.value;
|
|
|
const videoUrl = formArray.find(item => item.name === 'video_url')?.value;
|
|
@@ -216,6 +285,7 @@ function validateForm(formArray) {
|
|
|
return '帖子留言和视频不能为空';
|
|
|
}
|
|
|
}
|
|
|
+ toggleYouTube(false);
|
|
|
}
|
|
|
|
|
|
// 验证send_type规则(仅处理radio类型的send_type)
|
|
@@ -253,6 +323,7 @@ if (!accountIds || accountIds.length === 0) {
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
JS);
|
|
|
}
|
|
|
|