251 lines
10 KiB
HTML
251 lines
10 KiB
HTML
<!DOCTYPE html>
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
|
||
<link href="/jscss/style.css" rel="stylesheet" type="text/css" />
|
||
<script type="text/javascript" charset="utf-8" src="/jscss/theme.js"></script>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
|
||
<!-- 交叉生成区域 -->
|
||
<div style="border:1px solid #eee;padding:15px;border-radius:6px;margin:10px 0;">
|
||
<div style="margin-bottom:10px;">
|
||
<label class="imp">所属栏目</label>
|
||
<ciy-select id="cross_cateid_select" style="width:200px;"></ciy-select>
|
||
</div>
|
||
<div style="display:flex;gap:10px;">
|
||
<div style="flex:1;">
|
||
<label>前缀词(非必填)</label><br>
|
||
<textarea name="cross_dim1" style="width:100%;height:140px;padding:10px;" placeholder="一行一个 2025款 新款 防水"></textarea>
|
||
</div>
|
||
<div style="flex:1;">
|
||
<label class="imp">核心词(必填)</label><br>
|
||
<textarea name="cross_dim2" style="width:100%;height:140px;padding:10px;" placeholder="一行一个 手机 电脑 平板"></textarea>
|
||
</div>
|
||
<div style="flex:1;">
|
||
<label>扩展词(非必填)</label><br>
|
||
<textarea name="cross_dim3" style="width:100%;height:140px;padding:10px;" placeholder="一行一个 包邮 官方正品"></textarea>
|
||
</div>
|
||
</div>
|
||
<div style="margin-top:12px;text-align:right;margin-top:12px;">
|
||
<button class="btn lg" onclick="GenerateKeywords()">交叉生成预览</button>
|
||
<button class="btn lg" onclick="BatchAdd()" style="margin-left:8px;">批量添加</button>
|
||
<button class="btn lg" onclick="AIFunction('联想')" style="margin-left:8px;">AI联想</button>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- 可编辑预览区域 -->
|
||
<div id="editBox" style="display:none;border:1px solid #eee;padding:15px;border-radius:6px;margin:10px 0;">
|
||
<h4>预览交叉生成关键词</h4>
|
||
<textarea id="editKeywordText" style="width:100px;width:100%;height:260px;padding:10px;margin:10px 0;resize:vertical;"></textarea>
|
||
<div style="text-align:right;">
|
||
<button class="btn lg" onclick="AIFunction('修改')">AI修改</button>
|
||
<button class="btn lg" onclick="saveEditKeywords()">确认保存入库</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div id="AI_editBox" style="display:none;border:1px solid #eee;padding:15px;border-radius:6px;margin:10px 0;">
|
||
<h4>预览AI联想生成关键词</h4>
|
||
<textarea id="AI_editKeywordText" style="width:100px;width:100%;height:260px;padding:10px;margin:10px 0;resize:vertical;"></textarea>
|
||
<div style="text-align:right;">
|
||
<button class="btn lg" onclick="saveEditKeywords()">确认保存入库</button>
|
||
</div>
|
||
</div>
|
||
<div class="table" style="display:none !important; height:0; overflow:hidden;">
|
||
<div class="loading">Loading...</div>
|
||
<div class="list"></div>
|
||
<div class="page"></div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script type="text/javascript" src="/jscss/ciy.js"></script>
|
||
<script type="text/javascript" src="/jscss/ciycmp.js"></script>
|
||
<script type="text/javascript" src="/jscss/ciytable.js"></script>
|
||
<script type="text/javascript" src="../common.js"></script>
|
||
|
||
<script type="text/javascript">
|
||
'use strict';
|
||
var table = null;
|
||
var currentCateid = 0;
|
||
|
||
ciyfn.pageload(function () {
|
||
table = new ciyclass.table({
|
||
dom: '.table',
|
||
url: 'list',
|
||
fn_done: function (json) {
|
||
if (json && json.www_list_cate) {
|
||
ciycmp({
|
||
dom: document.getElementById('cross_cateid_select'),
|
||
value: 0,
|
||
range: json.www_list_cate
|
||
});
|
||
}
|
||
}
|
||
});
|
||
table.callpage(1);
|
||
});
|
||
|
||
// 生成预览
|
||
function GenerateKeywords() {
|
||
var cateid = $5('[id=cross_cateid_select]').val();
|
||
var dim1 = $5('[name=cross_dim1]').val().trim();
|
||
var dim2 = $5('[name=cross_dim2]').val().trim();
|
||
var dim3 = $5('[name=cross_dim3]').val().trim();
|
||
|
||
if (!cateid) {
|
||
ciyfn.toast('请选择所属栏目');
|
||
return;
|
||
}
|
||
if (!dim2) {
|
||
ciyfn.toast('请填写核心词');
|
||
return;
|
||
}
|
||
|
||
currentCateid = cateid;
|
||
|
||
ciyfn.callfunc('GenerateKeywords', {
|
||
cateid: cateid,
|
||
dim1: dim1,
|
||
dim2: dim2,
|
||
dim3: dim3
|
||
}, function (res) {
|
||
if (res.code === 1) {
|
||
// 数组转换行文本,给用户编辑
|
||
let str = res.list.join("\n");
|
||
$5('[id=editKeywordText]').val(str);
|
||
$5('[id=editBox]').show();
|
||
ciyfn.toast('已生成,可手动修改后保存');
|
||
} else {
|
||
ciyfn.toast(res.errmsg);
|
||
}
|
||
});
|
||
}
|
||
|
||
// 保存编辑后的关键词入库
|
||
function saveEditKeywords(){
|
||
let text = '';
|
||
var aiBox = document.getElementById('AI_editBox');
|
||
var editBox = document.getElementById('editBox');
|
||
var currentCateid = $5('[id=cross_cateid_select]').val().trim();
|
||
if(aiBox.style.display !== 'none'){
|
||
text = document.getElementById('AI_editKeywordText').value.trim();
|
||
console.log("AI:"+text);
|
||
|
||
} else {
|
||
text = document.getElementById('editKeywordText').value.trim();
|
||
console.log("normal:"+text);
|
||
}
|
||
|
||
if(!text){
|
||
ciyfn.toast('没有需要保存的关键词');
|
||
return;
|
||
}
|
||
ciyfn.callfunc('ConfirmSaveKeywords',{
|
||
cateid: currentCateid,
|
||
text: text
|
||
},function(res){
|
||
if(res.code === 1){
|
||
ciyfn.toast(res.msg);
|
||
editBox.style.display = 'none';
|
||
aiBox.style.display = 'none';
|
||
document.getElementById('editKeywordText').value = '';
|
||
document.getElementById('AI_editKeywordText').value = '';
|
||
}else{
|
||
ciyfn.toast(res.errmsg);
|
||
}
|
||
});
|
||
}
|
||
|
||
//批量添加不变
|
||
function BatchAdd() {
|
||
var cateid = $5('[id=cross_cateid_select]').val();
|
||
var names = $5('[name=cross_dim2]').val().trim();
|
||
|
||
if (!cateid) {
|
||
ciyfn.toast('请选择所属栏目');
|
||
return;
|
||
}
|
||
if (!names) {
|
||
ciyfn.toast('请输入关键词');
|
||
return;
|
||
}
|
||
|
||
ciyfn.callfunc('BatchAdd', {
|
||
cateid: cateid,
|
||
names: names
|
||
}, function (res) {
|
||
if (res.code === 1) {
|
||
ciyfn.toast(res.msg);
|
||
} else {
|
||
ciyfn.toast(res.errmsg);
|
||
}
|
||
});
|
||
}
|
||
|
||
//AI相关功能
|
||
function AIFunction(param) {
|
||
let text = '';
|
||
if(param === '修改'){
|
||
text = $5('[id=editKeywordText]').val().trim();
|
||
if (!text) {
|
||
ciyfn.toast('请先生成关键词再使用AI修改');
|
||
return;
|
||
}
|
||
ciyfn.toast('AI正在处理中...', 9999);
|
||
ciyfn.callfunc('AIFunction', {
|
||
content: text,
|
||
param: param
|
||
}, function (res) {
|
||
if (res.code === 1) {
|
||
$5('[id=editKeywordText]').val(res.data);
|
||
$5('[id=editBox]').show();
|
||
$5('[id=AI_editBox]').hide();
|
||
ciyfn.toast('AI ' + param + ' 完成');
|
||
} else {
|
||
ciyfn.toast('AI ' + param + ' 失败:' + res.errmsg);
|
||
}
|
||
});
|
||
}else{
|
||
var cateid = $5('[id=cross_cateid_select]').val();
|
||
var dim1 = $5('[name=cross_dim1]').val().trim();
|
||
var dim2 = $5('[name=cross_dim2]').val().trim();
|
||
var dim3 = $5('[name=cross_dim3]').val().trim();
|
||
if(!cateid){
|
||
ciyfn.toast('请选择所属栏目');
|
||
return;
|
||
}
|
||
|
||
if (!dim2) {
|
||
ciyfn.toast('请填写核心词');
|
||
return;
|
||
}
|
||
|
||
ciyfn.toast('AI联想中...', 9999);
|
||
ciyfn.callfunc('AIFunction', {
|
||
cateid: cateid,
|
||
dim1: dim1,
|
||
dim2: dim2,
|
||
dim3: dim3,
|
||
param: param
|
||
}, function (res) {
|
||
if (res.code === 1) {
|
||
$5('[id=AI_editKeywordText]').val(res.data);
|
||
$5('[id=AI_editBox]').show();
|
||
$5('[id=editBox]').hide();
|
||
ciyfn.toast('AI ' + param + ' 完成');
|
||
} else {
|
||
ciyfn.toast('AI ' + param + ' 失败:' + res.errmsg);
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
}
|
||
</script>
|
||
</body>
|
||
</html> |