Authored by yyq

img link

... ... @@ -498,7 +498,7 @@ const friendLink = {
add: async(ctx, next) => {
let result = {code: 500, message: '非法参数'};
let {type, key, sort, link} = ctx.request.body;
let {type, name, img, sort, link} = ctx.request.body;
type = type || 'text';
... ... @@ -518,12 +518,16 @@ const friendLink = {
}
let linkInfo = {
name: name,
sort: sort || 0,
link: link,
modify_time: Date.parse(new Date()) / 1000
}
linkInfo[type] = key;
if (type === 'img' && img) {
linkInfo.img = img;
}
linkInfo.cid = md5(JSON.stringify(linkInfo));
list.push(linkInfo);
... ... @@ -541,7 +545,7 @@ const friendLink = {
edit: async(ctx, next) => {
let result = {code: 500, message: '非法参数'};
let {type, key, sort, link, cid} = ctx.request.body;
let {type, name, img, sort, link, cid} = ctx.request.body;
type = type || 'text';
... ... @@ -563,11 +567,12 @@ const friendLink = {
_.forEach(list, value => {
if (value.cid === cid) {
Object.assign(value, {
name: name,
sort: sort || 0,
link: link
});
value[type] = key;
img && (value.img = img);
}
});
... ...
... ... @@ -56,9 +56,14 @@
height: 36px;
}
.seo-friendlink-page #table-friendlink img {
max-width: 150px;
}
.seo-friendlink-page #pop{
width:500px;
height: 350px;
height: 394px;
background: #fff;
left: 0;
right: 0;
... ... @@ -67,6 +72,10 @@
margin:auto;
}
.seo-friendlink-page #pop .modal-body {
height: 250px;
}
.seo-friendlink-page #pop .cover-title {
position: absolute;
background: #fff;
... ... @@ -169,9 +178,14 @@
<tbody>
{{#each linkList}}
<tr data-type="{{../type}}" data-key="{{text}}{{img}}" data-cid="{{cid}}" data-link="{{link}}" data-sort="{{sort}}">
<tr data-type="{{../type}}" data-name="{{name}}" data-img="{{img}}" data-cid="{{cid}}" data-link="{{link}}" data-sort="{{sort}}">
<td class="text-center"><input type="checkbox" style="margin-right:5px;">{{id}}</td>
<td>{{text}}</td>
<td>
{{name}}
{{#if img}}
<img src="{{img}}" title="{{name}}" alt="{{name}}">
{{/if}}
</td>
<td>{{link}}</td>
<td>{{sort}}</td>
<td class="text-center">
... ... @@ -226,9 +240,15 @@
</div>
</li>
<li>
<label class="control-label key-label" for="input-key">名称:</label>
<label class="control-label key-label" for="input-name">名称:</label>
<div class="controls">
<input type="text" id="input-name">
</div>
</li>
<li class="img-link hide">
<label class="control-label" for="input-img">图片:</label>
<div class="controls">
<input type="text" id="input-key">
<input type="text" id="input-img" class="full-w">
</div>
</li>
<li>
... ... @@ -266,9 +286,10 @@
this.$base = $('#pop');
this.$popTitle = $('.cover-title', this.$base);
this.$keyLabel = $('.key-label', this.$base);
this.$imgLink = $('.img-link', this.$base);
this.$type = $('#select-type', this.$base);
this.$key = $('#input-key', this.$base);
this.$name = $('#input-name', this.$base);
this.$img = $('#input-img', this.$base);
this.$link = $('#input-link', this.$base);
this.$sort = $('#input-sort', this.$base);
... ... @@ -276,7 +297,11 @@
this.$errTip = $('.err-tip', this.$base);
this.$base.on('change', '#select-type', function() {
that.$keyLabel.text(that.ltList[$(this).val()] || that.ltList.skn);
if ($(this).val() === 'img') {
that.$imgLink.removeClass('hide');
} else {
that.$imgLink.addClass('hide');
}
}).on('click', '.clear-input', function() {
that.clearInput();
}).on('click', '.sure-btn', function() {
... ... @@ -317,26 +342,33 @@
$('input, textarea', this.$base).val('');
},
fillInput(info) {
console.log(info);
if (info) {
this.editInfo = info;
this.$popTitle.text('编辑友链');
this.$type.val(info.type).change().attr('disabled', true);
this.$key.val(info.key);
this.$name.val(info.name);
this.$link.val(info.link);
this.$sort.val(info.sort);
if (info.img) {
this.$img.val(info.img);
}
}
this.$base.show();
},
packReqData() {
var data = {
type: this.$type.val(),
key: $.trim(this.$key.val()),
name: $.trim(this.$name.val()),
link: $.trim(this.$link.val()),
sort: $.trim(this.$sort.val())
};
var i;
if (this.$type.val() === 'img') {
data.img = $.trim(this.$img.val());
}
if (this.editInfo) {
data.cid = this.editInfo.cid;
}
... ...