...
|
...
|
@@ -163,15 +163,14 @@ $goodsTable.on('click', '.btn-del', function(e) { |
|
|
resetImg($p);
|
|
|
});
|
|
|
|
|
|
$file.each(function(e) {
|
|
|
var $this = $('#upload-img-' + e),
|
|
|
$par = $this.closest('.problem-description');
|
|
|
// $file.each(function(e) {
|
|
|
// var $this = $('#upload-img-' + e);
|
|
|
|
|
|
if (!window.location.origin) {
|
|
|
window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
|
|
}
|
|
|
// if (!window.location.origin) {
|
|
|
// window.location.origin = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
|
|
|
// }
|
|
|
|
|
|
fileChangeEvent($this)//
|
|
|
fileChangeEvent();//
|
|
|
|
|
|
// $this.qupload({
|
|
|
// button_image_url: '',
|
...
|
...
|
@@ -203,20 +202,17 @@ $file.each(function(e) { |
|
|
// });
|
|
|
// }
|
|
|
// });
|
|
|
});
|
|
|
// });
|
|
|
|
|
|
function fileChangeEvent($file) {
|
|
|
console.log('111111111111111');
|
|
|
function fileChangeEvent() {
|
|
|
|
|
|
// 图片上传
|
|
|
$goodsTable.on('change', 'input[type=file]', function() {
|
|
|
|
|
|
var $f = $(this);
|
|
|
var $p = $f.siblings('.up-image-list');
|
|
|
var $p = $f.parent().siblings('.up-image-list');
|
|
|
|
|
|
var $lis = $p.find('li:not(.selected)');
|
|
|
var $li = $($lis[0]);
|
|
|
console.log('===========================');
|
|
|
var $unSelectLi = $p.find('li:not(.selected)');
|
|
|
|
|
|
if ($f.val()) {
|
|
|
$.ajaxFileUpload({
|
...
|
...
|
@@ -228,25 +224,35 @@ function fileChangeEvent($file) { |
|
|
},
|
|
|
dataType: 'json',
|
|
|
success: function(data /* , status */) {
|
|
|
var url, relaUrl;
|
|
|
|
|
|
if (data && data.code === 200 && data.data && data.data.images && data.data.images[0]) {
|
|
|
url = data.data.images[0];
|
|
|
relaUrl = data.data.imagesList[0];
|
|
|
var resData = data.data,
|
|
|
len = resData.images.length > $unSelectLi.length ?
|
|
|
$unSelectLi.length : resData.images.length;
|
|
|
|
|
|
if (data && data.code === 200 && data.data && data.data.images) {
|
|
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
var url, relaUrl,
|
|
|
$li = $($unSelectLi[i]);
|
|
|
|
|
|
url = resData.images[i] +
|
|
|
'?imageMogr2/thumbnail/130x130/extent/130x130/background/d2hpdGU=/position/center/quality/90';
|
|
|
relaUrl = resData.imagesList[i];
|
|
|
$li.find('img').attr('src', url).attr('source-url', url);
|
|
|
$li.find('input[name=imgs]').val(relaUrl);
|
|
|
$li.addClass('selected');
|
|
|
}
|
|
|
|
|
|
|
|
|
} else if (data && data.message) {
|
|
|
alert(data.message);
|
|
|
}
|
|
|
},
|
|
|
error: function() { /** data, status, e **/
|
|
|
error: function(error) { /** data, status, e **/
|
|
|
alert('上传失败,请稍后再试!');
|
|
|
},
|
|
|
complete: function() {
|
|
|
$f.clone().replaceAll($f);
|
|
|
// fileChangeEvent($f);
|
|
|
}
|
|
|
});
|
|
|
}
|
...
|
...
|
|