上传图片 添加加载中动画
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// 多语言配置
|
// 多语言配置
|
||||||
// var baseUrl = 'https://server.orzar.shop/'
|
var baseUrllang = 'https://server.orzar.shop/';
|
||||||
var baseUrllang = "https://usedcar.server.hnxinyouhe.com/";
|
// var baseUrllang = "https://usedcar.server.hnxinyouhe.com/";
|
||||||
var langConfig = {
|
var langConfig = {
|
||||||
'zh': {
|
'zh': {
|
||||||
'baseUrl':baseUrllang,
|
'baseUrl':baseUrllang,
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@ var ajax = null,queue = [];
|
|||||||
var isAjaxLock=false;
|
var isAjaxLock=false;
|
||||||
var Utils={}
|
var Utils={}
|
||||||
var userinfowifi='';
|
var userinfowifi='';
|
||||||
// var baseUrl = "https://server.orzar.shop/";
|
var baseUrl = "https://server.orzar.shop/";
|
||||||
var baseUrl = "https://usedcar.server.hnxinyouhe.com/";
|
// var baseUrl = "https://usedcar.server.hnxinyouhe.com/";
|
||||||
// var baseUrl = "http://192.168.50.6:8787/";
|
// var baseUrl = "http://192.168.50.6:8787/";
|
||||||
if(sessionStorage.wifiuserinfo){
|
if(sessionStorage.wifiuserinfo){
|
||||||
userinfowifi=JSON.parse(sessionStorage.wifiuserinfo)
|
userinfowifi=JSON.parse(sessionStorage.wifiuserinfo)
|
||||||
|
|||||||
@@ -51,6 +51,33 @@ layui.$(function () {
|
|||||||
toggleSearchFormShow();
|
toggleSearchFormShow();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 公共:上传loading 显示/隐藏(兼容 iframe,优先使用顶层 layer)
|
||||||
|
var uploadLoadingIndex = null;
|
||||||
|
var uploadLoadingLayerRef = null;
|
||||||
|
function showUploadLoading(){
|
||||||
|
try{
|
||||||
|
if(uploadLoadingIndex === null){
|
||||||
|
var layerRef = (typeof top !== 'undefined' && top.layui && top.layui.layer) ? top.layui.layer
|
||||||
|
: (typeof parent !== 'undefined' && parent.layui && parent.layui.layer) ? parent.layui.layer
|
||||||
|
: (typeof layui !== 'undefined' && layui.layer) ? layui.layer
|
||||||
|
: null;
|
||||||
|
if(layerRef){
|
||||||
|
uploadLoadingLayerRef = layerRef;
|
||||||
|
uploadLoadingIndex = layerRef.load(2, {shade: [0.2, '#000']});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
function hideUploadLoading(){
|
||||||
|
try{
|
||||||
|
if(uploadLoadingIndex !== null && uploadLoadingLayerRef){
|
||||||
|
uploadLoadingLayerRef.close(uploadLoadingIndex);
|
||||||
|
uploadLoadingIndex = null;
|
||||||
|
uploadLoadingLayerRef = null;
|
||||||
|
}
|
||||||
|
}catch(e){}
|
||||||
|
}
|
||||||
|
|
||||||
function brandpresetfn(form,istrue){
|
function brandpresetfn(form,istrue){
|
||||||
self.brandpreset({
|
self.brandpreset({
|
||||||
type:'get',
|
type:'get',
|
||||||
@@ -487,6 +514,8 @@ function uploadimage(upload,baseUrl){
|
|||||||
acceptMime: 'image/*',
|
acceptMime: 'image/*',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
before: function(obj) {
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
// 预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
|
// 预读本地文件,如果是多文件,则会遍历。(不支持ie8/9)
|
||||||
obj.preview(function(index, file, result) {
|
obj.preview(function(index, file, result) {
|
||||||
// 生成唯一的图片ID
|
// 生成唯一的图片ID
|
||||||
@@ -513,12 +542,19 @@ function uploadimage(upload,baseUrl){
|
|||||||
// 通过data-index属性找到对应的元素
|
// 通过data-index属性找到对应的元素
|
||||||
$('.upload-itemm[data-index="' + index + '"]').find('input[name="pic[]"]').val(
|
$('.upload-itemm[data-index="' + index + '"]').find('input[name="pic[]"]').val(
|
||||||
res.data.image_name);
|
res.data.image_name);
|
||||||
|
hideUploadLoading();
|
||||||
} else {
|
} else {
|
||||||
layer.msg('上传失败');
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
allDone: function(obj){
|
||||||
|
// 多文件上传结束后兜底隐藏
|
||||||
|
if (typeof hideUploadLoading === 'function') hideUploadLoading();
|
||||||
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
layer.msg('上传失败');
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -157,8 +157,8 @@
|
|||||||
$(this).addClass('icon-check');
|
$(this).addClass('icon-check');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// var baseUrl = "https://server.orzar.shop/";
|
var baseUrl = "https://server.orzar.shop/";
|
||||||
var baseUrl = "https://usedcar.server.hnxinyouhe.com/";
|
// var baseUrl = "https://usedcar.server.hnxinyouhe.com/";
|
||||||
// 进行登录操作
|
// 进行登录操作
|
||||||
form.on('submit(login)', function (data) {
|
form.on('submit(login)', function (data) {
|
||||||
data = data.field;
|
data = data.field;
|
||||||
|
|||||||
@@ -365,11 +365,20 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
$item.find('img').attr('src',res.data.image_url);
|
$item.find('img').attr('src',res.data.image_url);
|
||||||
$item.find('input').val(res.data.image_name);
|
$item.find('input').val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -436,13 +436,22 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
// var $preview = $item.find('.preview-box');
|
// var $preview = $item.find('.preview-box');
|
||||||
// $preview.html('<img src="'+res.data.src+'" style="max-width:100px;">');
|
// $preview.html('<img src="'+res.data.src+'" style="max-width:100px;">');
|
||||||
$item.find('img').attr('src',res.data.image_url);
|
$item.find('img').attr('src',res.data.image_url);
|
||||||
$item.find('input').val(res.data.image_name);
|
$item.find('input').val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -255,11 +255,20 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
$item.find('img').attr('src',res.data.image_url);
|
$item.find('img').attr('src',res.data.image_url);
|
||||||
$item.find('input').val(res.data.image_name);
|
$item.find('input').val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -360,11 +360,20 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
$item.find('img').attr('src',res.data.image_url);
|
$item.find('img').attr('src',res.data.image_url);
|
||||||
$item.find('input').val(res.data.image_name);
|
$item.find('input').val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,11 +76,20 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
$(".img-3").attr('src',res.data.image_url);
|
$(".img-3").attr('src',res.data.image_url);
|
||||||
$("#avatarinput").val(res.data.image_name);
|
$("#avatarinput").val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//监听提交
|
//监听提交
|
||||||
|
|||||||
@@ -120,11 +120,20 @@
|
|||||||
url:baseUrl+ 'console/upload/image',
|
url:baseUrl+ 'console/upload/image',
|
||||||
accept: 'images',
|
accept: 'images',
|
||||||
field: 'image',
|
field: 'image',
|
||||||
|
before: function(obj) {
|
||||||
|
// 显示上传loading
|
||||||
|
showUploadLoading();
|
||||||
|
},
|
||||||
done: function(res){
|
done: function(res){
|
||||||
|
hideUploadLoading();
|
||||||
if(res.code == 0){
|
if(res.code == 0){
|
||||||
$(".img-3").attr('src',res.data.image_url);
|
$(".img-3").attr('src',res.data.image_url);
|
||||||
$("#avatarinput").val(res.data.image_name);
|
$("#avatarinput").val(res.data.image_name);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
layer.msg('上传失败');
|
||||||
|
hideUploadLoading();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user