Authored by yyq

seo hot manage

... ... @@ -133,5 +133,49 @@ r.get('/list', async(ctx) => {
};
});
r.post('/save', async (ctx) => {
let mysql = new Mysql();
let id = ctx.request.body.id || 0;
let keyword = ctx.request.body.keywords;
let brand = ctx.request.body.brand || 0;
let msort = ctx.request.body.msort || 0;
let misort = ctx.request.body.misort || 0;
let sort = ctx.request.body.sort || 0;
let describe = ctx.request.body.describe || '';
let goods_img = ctx.request.body.goodsImg || '';
let is_hot = ctx.request.body.isHot || 0;
let addTime = Date.parse(new Date())/1000;
if (id) {
return mysql.query(`UPDATE seo_keywords SET \`describe\` = '${describe}', goods_img = '${goods_img}' WHERE id = ${id}`).then(d => {
return ctx.body = {
code: 200,
message: 'success',
data: d
};
});
}
let result = {code: 400, message: ''};
if (!keyword) {
result.message = '关键词必填';
return ctx.response.body = result;
}
let select = await mysql.query(`select id from seo_keywords where keyword='${keyword}' limit 1`);
if (_.get(select, '[0].id', 0) > 0) {
result.message = '关键词已经存在';
return ctx.response.body = result;
}
await mysql.query(`insert into seo_keywords (keyword, brand_id, msort, misort, sort_id, add_time, \`describe\`, goods_img, is_hot) values ('${keyword}', ${brand}, ${msort}, ${misort}, ${sort}, ${addTime}, '${describe}', '${goods_img}', ${is_hot})`);
result.code = 200;
return ctx.response.body = result;
})
module.exports = r;
... ...
... ... @@ -5,39 +5,28 @@ import HotApi from '../../services/seo/hot-keywords'
const { TextArea } = Input;
const columns = [{
title: '序号',
dataIndex: 'id',
key: 'id',
}, {
title: '关键词',
dataIndex: 'keyword',
key: 'keyword',
}, {
title: '大品类',
dataIndex: 'msortName',
key: 'msortName',
}, {
title: '小品类',
dataIndex: 'sortName',
key: 'sortName',
}, {
title: '商品数',
dataIndex: 'yoho_goods_num',
key: 'yoho_goods_num',
}, {
title: '是否推送',
dataIndex: 'is_push',
key: 'is_push',
}, {
title: '添加时间',
dataIndex: 'add_time',
key: 'add_time',
}];
const titleObj = {
id: '序号',
keyword: '关键词',
msortName: '大品类',
sortName: '小品类',
yoho_goods_num: '商品数',
is_push: '是否推送',
add_time: '添加时间'
};
const columns = [];
Object.keys(titleObj).forEach(key => {
columns.push({
title: titleObj[key],
dataIndex: key,
key: key,
});
});
let globalSort = [];
function ActionButton(props) {
function editClick() {
props.keyword.callbackFn('edit', props.keyword);
... ... @@ -47,6 +36,8 @@ function ActionButton(props) {
}
return (
<span>
<a href="javascript:;" onClick={editClick}>编辑</a>
<Divider type="vertical" />
<a href="javascript:;" onClick={deleteClick}>删除</a>
</span>
);
... ... @@ -206,6 +197,15 @@ class OptionModal extends React.Component {
let title = '';
if (record.sort_id || record.msort || record.misort) {
let arr = [];
record.msortName && arr.push(record.msortName);
record.misortName && arr.push(record.misortName);
record.sortName && arr.push(record.sortName);
record.sortShowName = arr.join('/');
}
if (record && record.type === 'delete') {
return (
<Modal title={this.modalTitle} visible={true} onOk={this.handleOk} onCancel={this.hideOptionModal}>
... ... @@ -219,11 +219,11 @@ class OptionModal extends React.Component {
<Modal title={this.modalTitle} visible={true} onOk={this.handleOk} onCancel={this.hideOptionModal}>
<div style={{ paddingBottom: 10 }}>
<span>关键词:</span>
<Input onChange={this.handleKeywordChange} />
<Input onChange={this.handleKeywordChange} defaultValue={record.keyword} readOnly={record.id > 0}/>
</div>
<div style={{ paddingBottom: 10 }}>
<span>描述:</span>
<TextArea rows={4} onChange={this.handleDescChange} />
<TextArea rows={4} onChange={this.handleDescChange} defaultValue={record.describe}/>
</div>
<div style={{ paddingBottom: 10 }}>
<span>封面图:</span>
... ... @@ -241,12 +241,13 @@ class OptionModal extends React.Component {
</div>
<div style={{ paddingBottom: 10 }}>
<span>品类:</span>
<Cascader
{record.sortShowName ? <Input defaultValue={record.sortShowName} readOnly={record.id > 0}/> : <Cascader
options={this.state.sorts}
loadData={this.loadSortData}
onChange={this.handleSortChange}
style={{ width: '100%' }}
placeholder="" />
placeholder="" />}
</div>
</Modal>
)
... ... @@ -367,7 +368,6 @@ class HotKeywords extends React.Component {
<div style={{ paddingBottom: 10 }}>
<Button type="primary" onClick={this.deleteTableRow} disabled={!hasSelected} loading={loading}>删除</Button>
<Button type="primary" style={{ marginLeft: 10 }} onClick={this.addTableRow}>添加</Button>
<Button type="primary" style={{ marginLeft: 10 }} onClick={this.sendToBaidu}>推送百度</Button>
{this.optionModal(showModal)}
</div>
... ...
... ... @@ -21,7 +21,11 @@ export default class extends Service {
isHot: 1
};
return this.post('/keywords/add', params);
if (info.id) {
params.id = info.id;
}
return this.post('/hot-keywords/save', params);
}
getSubSorts(sortId) {
return this.post('/seo/rootwords/getsubsorts', {sortId})
... ...