Authored by 郝肖肖

Merge branch 'feature/extWord' of git.yoho.cn:OPENTECH/yoho-node-ci into feature/extWord

No preview for this file type
.vscode/
.DS_Store
node_modules/
db/**
... ...
... ... @@ -206,11 +206,50 @@ const tdk = {
}
};
// 词根
const rootWords = {
index: async(ctx, next) => {
let resData = {};
await ctx.render('action/seo_root_words', Object.assign(resData, {
title: '词根管理'
}));
},
add: async(ctx, next) => {
let resData = {};
await ctx.render('action/seo_root_add', Object.assign(resData, {
title: '添加词根'
}));
},
doAdd: async(ctx, next) => {
},
delete: async(ctx, next) => {
},
edit: async(ctx, next) => {
}
}
r.get('/', tdk.index);
r.get('/tdk', tdk.index);
r.post('/tdk/add', tdk.add);
r.post('/tdk/edit', tdk.edit);
r.post('/tdk/delete', tdk.delete);
// 词根管理
r.get('/rootwords', rootWords.index);
r.get('/rootwords/add', rootWords.add);
r.post('/rootwords/doadd', rootWords.doAdd);
r.post('/rootwords/edit', rootWords.edit);
r.post('/rootwords/delete', rootWords.delete);
module.exports = r;
... ...
<style>
</style>
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="/seo/tdk">{{title}}</a></li>
<li>{{typeName}}</li>
</ul>
<h4>{{title}}</h4>
</div>
</div>
<!-- media -->
</div>
<!-- pageheader -->
<div class="contentpanel seo-root-page" style="padding-bottom:0;">
<div class="panel panel-default">
<div class="panel-body">
<form action="/seo/rootwords/doadd" type="post">
<div class="form-group">
<label for="exampleInputEmail1">词根</label>
<input type="text" class="form-control" >
</div>
<div class="form-group">
<label for="exampleInputEmail1">品牌</label>
<ul id="brandTab" class="nav nav-tabs">
<li class="active"><a href="#home" data-toggle="tab">0~9</a></li>
<li><a href="#a" data-toggle="tab">a</a></li>
<li><a href="#b" data-toggle="tab">b</a></li>
</ul>
<div id="brandTabContent" class="tab-content">
<div class="tab-pane fade in active" id="home">
<a>0addidas</a>
<a>1addidas</a>
<a>2addidas</a>
</div>
<div class="tab-pane fade" id="a">
<a>addidas</a>
<a>ALTAMONT</a>
<a>Anthony</a>
</div>
<div class="tab-pane fade" id="b">
<a>baddidas</a>
<a>baddidas</a>
<a>baddidas</a>
</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">品类</label>
<div class="row">
<div class="col-md-3">
<select id="msort" class="form-control">
<option value="1" class="form-control">上衣</option>
</select>
</div>
<div class="col-md-3">
<select id="msort" class="form-control">
<option value="1">T恤</option>
</select>
</div>
<div class="col-md-3">
<select class="form-control">
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<label for="exampleInputEmail1">过滤词</label>
<input type="text" class="form-control" >
</div>
<button type="submit" class="btn btn-default">提交</button>
</form>
</div>
</div>
</div>
... ...
<style>
.seo-tdk-page ul {
padding: 0;
}
.seo-tdk-page li {
list-style: none;
}
.seo-tdk-page .query-form {
font-size: 0;
}
.seo-tdk-page .query-form .btn-group {
margin-bottom: 0;
}
.seo-tdk-page .query-form .dropdown-toggle {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
.seo-tdk-page .query-form .query-submit-btn {
height: 39px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.seo-tdk-page .query-key {
width: 300px;
height: 39px;
font-size: 14px;
vertical-align: middle;
outline: none;
}
.seo-tdk-page .text-limit {
max-width: 78px;
display: inline-block;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.seo-tdk-page .pagination {
margin: 0;
}
.seo-tdk-page #table-tdk th,
.seo-tdk-page #table-tdk td {
height: 36px;
}
.seo-tdk-page #pop{
width:500px;
height: 434px;
background: #fff;
left: 0;
right: 0;
top: 0;
bottom: 0;
margin:auto;
}
.seo-tdk-page #pop .cover-title {
position: absolute;
background: #fff;
margin-top: -34px;
}
.seo-tdk-page #pop .control-label {
width: 60px;
text-align: right;
}
.seo-tdk-page #pop li {
padding: 6px 0;
}
.seo-tdk-page #pop select,
.seo-tdk-page #pop input {
height: 30px;
width: 200px;
}
.seo-tdk-page #pop textarea {
height: 70px;
vertical-align: text-top;
border-color: #ccc;
resize: none;
}
.seo-tdk-page #pop .full-w {
width: 390px;
}
.seo-tdk-page #pop .controls {
display: inline-block;
}
.seo-tdk-page #pop .err-tip {
color: #a94442;
}
</style>
<div class="pageheader">
<div class="media">
<div class="pageicon pull-left">
<i class="fa fa-th-list"></i>
</div>
<div class="media-body">
<ul class="breadcrumb">
<li><a href=""><i class="glyphicon glyphicon-home"></i></a></li>
<li><a href="/seo/tdk">{{title}}</a></li>
<li>{{typeName}}</li>
</ul>
<h4>{{title}}</h4>
</div>
</div>
<!-- media -->
</div>
<!-- pageheader -->
<div class="contentpanel seo-tdk-page" style="padding-bottom:0;">
<div class="panel panel-default">
<div class="panel-body">
<label style="margin-right:20px;"><input type="checkbox" id="check-all" style="margin-right:5px;">全选</label>
<a data-toggle="modal" href="/seo/rootwords/add" class="btn btn-default" style="margin-right:10px;">增加</a>
<button class="btn btn-default delete-all" type="submit">删除</button>
<div class="input-append pull-right">
<form id="query-form" action="/seo/tdk" class="query-form" method="get">
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown">
{{typeName}}
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
{{# typeList}}
<li><a href="?type={{type}}">{{name}}</a></li>
{{/ typeList}}
</ul>
</div>
<input type="hidden" name="type" value="{{type}}">
<input class="span2 query-key" type="text" name="query" value="{{query}}">
<button class="btn query-submit-btn" type="submit">搜索</button>
</form>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<table id="table-tdk" class="table table-striped table-bordered responsive">
<thead>
<tr>
<th class="text-center" width="60">ID</th>
<th class="text-center" width="160">类型</th>
<th class="text-center">标题</th>
<th class="text-center">关键词</th>
<th class="text-center">描述</th>
<th class="text-center" width="120">操作</th>
</tr>
</thead>
<tbody>
{{#each tdkList}}
<tr data-type="{{../type}}" data-key="{{key}}" data-title="{{title}}" data-keywords="{{keywords}}" data-description="{{description}}">
<td class="text-center"><input type="checkbox" style="margin-right:5px;">{{id}}</td>
<td class="text-center" title="{{typeName}}({{typeLt}}:{{key}})">{{typeName}}({{typeLt}}:<span class="text-limit">{{key}}</span>)</td>
<td>{{title}}</td>
<td>{{keywords}}</td>
<td>{{description}}</td>
<td class="text-center">
<a href="#pop" class="edit-tdk-btn" data-toggle="modal">编辑</a>
<a href="javascript:;" class="del-tdk-btn">删除</a>
</td>
</tr>
{{/each}}
{{#unless tdkList}}
<tr>
<td class="text-center" colspan="6">暂无数据</td>
</tr>
{{/unless}}
</tbody>
</table>
{{# pager}}
<div class="text-right">
{{#if pages}}
<ul class="pagination">
{{# prePage}}
<li><a href="{{url}}">上一页</a></li>
{{/ prePage}}
{{# pages}}
<li class="{{#unless url}}disabled {{/unless}}{{#if cur}}active{{/if}}"><a {{#if url}}href="{{url}}"{{^}}href="javascript:;"{{/if}}>{{num}}</a></li>
{{/ pages}}
{{# nextPage}}
<li><a href="{{url}}">下一页</a></li>
{{/ nextPage}}
</ul>
{{/if}}
</div>
{{/ pager}}
</div>
</div>
<div id="pop" class="modal fade in" style="display: none;">
<div class="modal-header">
<a class="close clear-input" data-dismiss="modal">×</a>
<h4>添加TDK</h4>
<h4 class="cover-title"></h4>
</div>
<div class="modal-body">
<ul>
<li>
<label class="control-label" for="select-type">类型:</label>
<div class="controls">
<select id="select-type">
{{# typeList}}
<option value="{{type}}">{{name}}</option>
{{/ typeList}}
</select>
</div>
</li>
<li>
<label class="control-label key-label" for="input-key">SKN:</label>
<div class="controls">
<input type="text" id="input-key">
</div>
</li>
<li>
<label class="control-label" for="input-title">标题:</label>
<div class="controls">
<input type="text" id="input-title" class="full-w">
</div>
</li>
<li>
<label class="control-label" for="input-keywords">关键词:</label>
<div class="controls">
<input type="text" id="input-keywords" class="full-w">
</div>
</li>
<li>
<label class="control-label" for="input-description">描述:</label>
<div class="controls">
<textarea id="input-description" class="full-w"></textarea>
</div>
</li>
</ul>
</div>
<div class="modal-footer">
<span class="err-tip"></span>
<a class="btn clear-input close-pop-btn" data-dismiss="modal">关闭</a>
<a class="btn btn-primary sure-btn">确定</a>
</div>
</div>
</div>
<script>
var pop = {
ltList: {
skn: 'SKN:',
article: 'ID:',
shop: 'ShopId:',
url: 'URL:'
},
init: function() {
var that = this;
this.$base = $('#pop');
this.$popTitle = $('.cover-title', this.$base);
this.$keyLabel = $('.key-label', this.$base);
this.$type = $('#select-type', this.$base);
this.$key = $('#input-key', this.$base);
this.$title = $('#input-title', this.$base);
this.$keywords = $('#input-keywords', this.$base);
this.$description = $('#input-description', this.$base);
this.$closeBtn = $('.close-pop-btn', this.$base);
this.$errTip = $('.err-tip', this.$base);
this.$base.on('change', '#select-type', function() {
that.$keyLabel.text(that.ltList[$(this).val()] || that.ltList.skn);
}).on('click', '.clear-input', function() {
that.clearInput();
}).on('click', '.sure-btn', function() {
var data;
if (that.saving) {
return;
}
data = that.packReqData();
if (!data) {
that.$errTip.text('请填写完整tdk信息');
return;
}
that.saving = true;
$.ajax({
url: that.editInfo ? '/seo/tdk/edit' : '/seo/tdk/add',
type: 'POST',
data: data,
}).done(function(res) {
if (res.code === 200) {
history.go(0);
}
}).always(function() {
that.saving = false;
});
});
},
clearInput: function() {
this.editInfo = false;
this.$popTitle.empty();
this.$errTip.empty();
this.$type.val('skn').change();
this.$type.removeAttr('disabled')
this.$key.removeAttr('readonly');
$('input, textarea', this.$base).val('');
},
fillInput(info) {
if (info) {
this.editInfo = info;
this.$popTitle.text('编辑TDK');
this.$type.val(info.type).change().attr('disabled', true);
this.$key.attr('readonly', 'readonly').val(info.key);
this.$title.val(info.title);
this.$keywords.val(info.keywords);
this.$description.val(info.description);
}
this.$base.show();
},
packReqData() {
var data = {
type: this.$type.val(),
key: $.trim(this.$key.val()),
title: $.trim(this.$title.val()),
keywords: $.trim(this.$keywords.val()),
description: $.trim(this.$description.val())
};
var i;
if (this.editInfo) {
data.type = this.editInfo.type;
data.key = this.editInfo.key;
}
for (i in data) {
if (data.hasOwnProperty(i) && !data[i]) {
return false;
}
}
return data;
},
close() {
this.$closeBtn.trigger('click');
}
};
$(function(){
var $checkboxs = $('#table-tdk :checkbox');
var deling;
pop.init();
function delTdk(data) {
deling = true;
$.ajax({
url: '/seo/tdk/delete',
type: 'POST',
data: {list: data},
}).done(function(res) {
if (res.code === 200) {
history.go(0);
}
}).always(function() {
deling = false;
});
};
$('#check-all').click(function() {
if ($(this).attr('checked') === 'checked') {
$checkboxs.attr('checked', 'checked');
} else {
$checkboxs.removeAttr('checked');
}
});
$('.delete-all').click(function() {
var arr = [];
$('#table-tdk :checkbox:checked').each(function(){
arr.push($(this).closest('tr').data());
});
arr.length ? delTdk(arr) : false;
});
$('#table-tdk').on('click', '.edit-tdk-btn', function(e) {
pop.fillInput($(e.target).closest('tr').data());
}).on('click', '.del-tdk-btn', function(e) {
var data = $(e.target).closest('tr').data();
delTdk([data]);
});
});
</script>
... ...
... ... @@ -14,9 +14,22 @@ const defaults = {
},
redis: {
connect: {
host: 'web.redis.yohoops.org',
port: '6379',
//password: ''
// host: '127.0.0.1',
host: 'web.redis.yohoops.org',
},
port: '6379',
retry_strategy(options) {
if (options.error && options.error.code === 'ECONNREFUSED') {
console.log('redis连接不成功');
}
if (options.total_retry_time > 1000 * 60 * 60 * 6) {
console.log('redis连接超时');
return;
}
if (options.attempt > 10) {
return 1000 * 60 * 60 * 0.5;
}
return Math.min(options.attempt * 100, 1000);
}
},
mysql: {
... ...
const redis = require('redis');
const bluebird = require('bluebird');
const config = require('../config/config');
let client;
const client = redis.createClient(config.redis.connect);
try {
client = redis.createClient(config.redis.connect);
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);
bluebird.promisifyAll(redis.RedisClient.prototype);
bluebird.promisifyAll(redis.Multi.prototype);
client.on('error', function() {
console.log('redis error');
client = '';
});
} catch (e) {
client = '';
}
module.exports = {
... ...
No preview for this file type