...
|
...
|
@@ -13,15 +13,21 @@ var diaLog = require('./dialog'); |
|
|
|
|
|
var $uploadImgList = $('.upload-img-list'),
|
|
|
headerNavHammer,
|
|
|
formHammer,
|
|
|
imgTpl,
|
|
|
imgTemplate,
|
|
|
$likeBtn = $('.suggest-item .like-btn'),
|
|
|
$disLikeBtn = $('.suggest-item .dislike-btn');
|
|
|
$disLikeBtn = $('.suggest-item .dislike-btn'),
|
|
|
$imgAdd = $('.img-add'),
|
|
|
imgStr = '';
|
|
|
|
|
|
require('./jquery.uploadifive');
|
|
|
|
|
|
imgTpl = '{{# imgList}}' +
|
|
|
'<li><img src="{{imgUrl}}" /></li>' +
|
|
|
'<li>' +
|
|
|
'<img src="{{imgUrl}}" />' +
|
|
|
'<span class="upload-img-remove"></span>' +
|
|
|
'</li>' +
|
|
|
'{{/ imgList}}';
|
|
|
|
|
|
imgTemplate = Handlebars.compile(imgTpl);
|
...
|
...
|
@@ -34,13 +40,16 @@ $('#upload-img').uploadifive({ |
|
|
fileSizeLimit: 1024,
|
|
|
height: '100%',
|
|
|
width: '100%',
|
|
|
queueSizeLimit: 1,
|
|
|
|
|
|
onAddQueueItem: function(files) {
|
|
|
|
|
|
//TODO
|
|
|
},
|
|
|
onUploadComplete: function(file, data) {
|
|
|
imgStr = JSON.parse(data).imgList[0].imgRelUrl;
|
|
|
$uploadImgList.html(imgTemplate(JSON.parse(data)));
|
|
|
$imgAdd.hide();
|
|
|
}
|
|
|
});
|
|
|
|
...
|
...
|
@@ -56,7 +65,8 @@ headerNavHammer.on('tap', function(e) { |
|
|
method: 'post',
|
|
|
url: '/home/savesuggest',
|
|
|
data: {
|
|
|
content: suggestText
|
|
|
content: suggestText,
|
|
|
image: imgStr
|
|
|
}
|
|
|
}).then(function(data) {
|
|
|
if (data.code === 200) {
|
...
|
...
|
@@ -72,6 +82,19 @@ headerNavHammer.on('tap', function(e) { |
|
|
}
|
|
|
});
|
|
|
|
|
|
formHammer = new Hammer(document.getElementById('img-form'));
|
|
|
|
|
|
formHammer.on('tap', function(e) {
|
|
|
if ($(e.target).hasClass('upload-img-remove')) {
|
|
|
$uploadImgList.html('');
|
|
|
imgStr = '';
|
|
|
setTimeout(function() {
|
|
|
$imgAdd.show();
|
|
|
}, 50);
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
// 点赞与取消点赞
|
|
|
// suggestContentHammer = new Hammer(document.getElementById('suggest-content'));
|
|
|
|
...
|
...
|
|