Authored by lore-w

上传图片可删除

... ... @@ -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'));
... ...
... ... @@ -158,6 +158,7 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
.img-form {
padding: 0 pxToRem(30px);
float: left;
.upload-img-list {
float: left;
... ... @@ -166,9 +167,11 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
display: block;
width: pxToRem(130px);
height: pxToRem(130px);
overflow: hidden;
float: left;
margin-right: pxToRem(30px);
background: image_url('loading.gif') center center no-repeat;
@include background-size(50px);
position: relative;
> img {
display: block;
... ... @@ -176,6 +179,21 @@ $suggest: sprite-map("me/suggest/*.png",$spacing: 5px);
height: 100%;
overflow: hidden;
}
> span {
$width: pxToRem(image_width(sprite-file($suggest, sub_del)));
$height: pxToRem(image_height(sprite-file($suggest, sub_del)));
display: block;
@include rem-sprite($suggest, sub_del);
width: $width;
height: $height;
position: absolute;
top: -($height/2);
right: -($width/2);
}
}
}
... ...
... ... @@ -10,6 +10,7 @@
<ul class="fav-product-list">
{{# hasFavProduct}}
<li data-id="{{fav_id}}">
<a href="{{link}}">
<div class="fav-img-box">
<img src="{{imgUrl}}" alt=""/>
</div>
... ... @@ -21,7 +22,6 @@
{{/ discountPrice}}
<span class="fav-price {{# discountPrice}}price-underline{{/ discountPrice}}">{{price}}</span>
</div>
{{# savePrice}}
<div class="save-price save-price-number">
比收藏时降价了<span>{{.}}</span>
... ... @@ -39,13 +39,14 @@
{{/ savePrice}}
</div>
</a>
</li>
{{/ hasFavProduct}}
</ul>
{{^ hasFavProduct}}
<span class="fav-null">您暂无收藏任何商品</span>
<a class="go-shopping" href="#">随便逛逛</a>
<a class="go-shopping" href="{{productUrl}}">随便逛逛</a>
{{/ hasFavProduct}}
</div>
<div class="fav-type">
... ... @@ -89,7 +90,7 @@
{{^ hasFavBrand}}
<span class="fav-null">您暂无收藏任何品牌</span>
<a class="go-shopping" href="#">随便逛逛</a>
<a class="go-shopping" href="{{brandUrl}}">随便逛逛</a>
{{/ hasFavBrand}}
</div>
</div>
... ...
... ... @@ -31,7 +31,7 @@
</div>
{{/ suggestContent}}
</div>
<a class="create-new-suggest" href="#">
<a class="create-new-suggest" href="./suggestSub">
反馈问题<span>(功能意见,界面意见)</span>
</a>
{{/ suggest}}
... ...
... ... @@ -3,10 +3,10 @@
{{# suggestSub}}
<div class="suggest-sub-form">
<textarea name="" id="suggest-textarea" placeholder="请输入意见反馈,我们会以消息形式回复您的建议或意见,改进产品体验,谢谢!"></textarea>
<div class="img-form">
<div id="img-form" class="img-form">
<ul class="upload-img-list"></ul>
<span class="img-add">
<input id="upload-img" type="file" multiple />
<input id="upload-img" type="file" />
</span>
</div>
</div>
... ...