Authored by yyq

upload

... ... @@ -332,8 +332,6 @@ const getRefundGoodsData = (orderCode, uid) => {
refund: _setDefaultStatus('退货') || {}
};
console.log(resData);
if (result.data) {
Object.assign(resData.returns.refund, _setRefundGoodList(result.data), {
orderCode: orderCode
... ...
... ... @@ -12,13 +12,6 @@
<span class="red">*</span>上传凭证:
</div>
<div class="left right-content">
<div class="img-wrap">
<div class="img-opt">
<span>查看</span>
<span>删除</span>
</div>
<div class="img-view"></div>
</div>
<div class="img-upload">
<span class="iconfont">&#xe61f;</span>
</div>
... ...
... ... @@ -4,7 +4,9 @@
* @date: 2016/7/15
*/
var $ = require('yoho-jquery'),
lazyload = require('yoho-jquery-lazyload');
lazyload = require('yoho-jquery-lazyload'),
handlebars = require('yoho-handlebars'),
upload = require('../plugins/upload');
var $refundTable = $('.refund-goods'),
$check = $('.check'),
... ... @@ -20,6 +22,15 @@ var orderCode = $('#order-code').val() || 0,
dom: $typeInfo.eq(0)
};
var tpl = '<div class="img-wrap">' +
'<div class="img-opt">' +
'<span>查看</span>' +
'<span>删除</span>' +
'</div>' +
'<div class="img-view"><img src="{{data}}"></div>' +
'</div>',
imgFn = handlebars.compile(tpl);
var checked;
require('../plugins/check');
... ... @@ -128,8 +139,20 @@ $refundTable.on('change', '.refund-reason', function() {
$specialDom.slideUp();
}
$specialDom.siblings('.check').data({reason: val});
}).on('click', '.img-upload', function() {
var $this = $(this);
upload.up({
callback: function(result) {
if (result && result.code === 200) {
$this.before(imgFn(result));
}
}
});
});
$refundType.on('click', '.type-item', function() {
var $this = $(this),
index;
... ...
var $ = require('yoho-jquery'),
handlebars = require('yoho-handlebars');
var tpl = '<div style="width: 0px; height: 0px; overflow: hidden;">' +
'<iframe id="yoho-upload-result" name="ajaxUpload" style="display:none"></iframe>' +
'<form id="yoho-upload" method="post" enctype="multipart/form-data" ' +
'action="/api/uploadImg" target="ajaxUpload">' +
'<input type="file" name="filename" class="file-name" />' +
'<input type="hidden" name="bucket" value="goodsimg" />' +
'</form>' +
'</div>';
var uploadFn = handlebars.compile(tpl || '');
var $result,
$upload,
$filename;
var num,
inter,
callback;
$('body').append(uploadFn({}));
$result = $('#yoho-upload-result');
$upload = $('#yoho-upload');
$filename = $upload.find('.file-name');
function up(opt) {
$filename.click();
if (opt) {
callback = opt.callback;
} else {
callback = '';
}
}
function getResponse(cb) {
num = 0;
inter = setInterval(function() {
var res = $result[0].contentDocument.body.innerText || '';
if (res) {
$result[0].contentDocument.body.innerText = '';
if (cb) {
return cb($.parseJSON(res));
}
}
if (num > 20 || res) {
clearInterval(inter);
}
num++;
}, 500);
}
$filename.change(function() {
$upload.submit();
getResponse(callback);
});
exports.up = up;
... ...
.refund-wrap {
.returns-status {
margin-bottom: 40px;
}
.refund-goods {
margin-bottom: 40px;
... ... @@ -79,6 +83,13 @@
line-height: 1.5;
text-align: left;
}
.refund-reason {
width: 120px;
height: 28px;
padding: 0 5px;
border: 1px solid #eee;
}
}
}
... ...