diff --git a/assets/js/tablei18n.js b/assets/js/tablei18n.js index 77b473a..5eb2079 100755 --- a/assets/js/tablei18n.js +++ b/assets/js/tablei18n.js @@ -1,6 +1,6 @@ // 多语言配置 -// var baseUrl = 'https://server.orzar.shop/' -var baseUrllang = "https://usedcar.server.hnxinyouhe.com/"; +var baseUrllang = 'https://server.orzar.shop/'; +// var baseUrllang = "https://usedcar.server.hnxinyouhe.com/"; var langConfig = { 'zh': { 'baseUrl':baseUrllang, diff --git a/assets/main.js b/assets/main.js index 97df907..9787f0f 100755 --- a/assets/main.js +++ b/assets/main.js @@ -3,8 +3,8 @@ var ajax = null,queue = []; var isAjaxLock=false; var Utils={} var userinfowifi=''; -// var baseUrl = "https://server.orzar.shop/"; -var baseUrl = "https://usedcar.server.hnxinyouhe.com/"; +var baseUrl = "https://server.orzar.shop/"; +// var baseUrl = "https://usedcar.server.hnxinyouhe.com/"; // var baseUrl = "http://192.168.50.6:8787/"; if(sessionStorage.wifiuserinfo){ userinfowifi=JSON.parse(sessionStorage.wifiuserinfo) diff --git a/assets/public.js b/assets/public.js index 3b459f9..56401d1 100755 --- a/assets/public.js +++ b/assets/public.js @@ -51,6 +51,33 @@ layui.$(function () { 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){ self.brandpreset({ type:'get', @@ -487,6 +514,8 @@ function uploadimage(upload,baseUrl){ acceptMime: 'image/*', field: 'image', before: function(obj) { + // 显示上传loading + showUploadLoading(); // 预读本地文件,如果是多文件,则会遍历。(不支持ie8/9) obj.preview(function(index, file, result) { // 生成唯一的图片ID @@ -513,12 +542,19 @@ function uploadimage(upload,baseUrl){ // 通过data-index属性找到对应的元素 $('.upload-itemm[data-index="' + index + '"]').find('input[name="pic[]"]').val( res.data.image_name); + hideUploadLoading(); } else { layer.msg('上传失败'); + hideUploadLoading(); } }, + allDone: function(obj){ + // 多文件上传结束后兜底隐藏 + if (typeof hideUploadLoading === 'function') hideUploadLoading(); + }, error: function() { layer.msg('上传失败'); + hideUploadLoading(); } }); diff --git a/index.html b/index.html index 4b0f02d..f64ce31 100644 --- a/index.html +++ b/index.html @@ -157,8 +157,8 @@ $(this).addClass('icon-check'); } }); - // var baseUrl = "https://server.orzar.shop/"; - var baseUrl = "https://usedcar.server.hnxinyouhe.com/"; + var baseUrl = "https://server.orzar.shop/"; + // var baseUrl = "https://usedcar.server.hnxinyouhe.com/"; // 进行登录操作 form.on('submit(login)', function (data) { data = data.field; diff --git a/page/table/carlistadd.html b/page/table/carlistadd.html index 623cafb..0afa8e2 100755 --- a/page/table/carlistadd.html +++ b/page/table/carlistadd.html @@ -365,11 +365,20 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ $item.find('img').attr('src',res.data.image_url); $item.find('input').val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); }); diff --git a/page/table/carlistedit.html b/page/table/carlistedit.html index 278c344..e81e80d 100755 --- a/page/table/carlistedit.html +++ b/page/table/carlistedit.html @@ -436,13 +436,22 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ // var $preview = $item.find('.preview-box'); // $preview.html(''); $item.find('img').attr('src',res.data.image_url); $item.find('input').val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); }); diff --git a/page/table/newcarlistadd.html b/page/table/newcarlistadd.html index bad3921..30e4860 100755 --- a/page/table/newcarlistadd.html +++ b/page/table/newcarlistadd.html @@ -255,11 +255,20 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ $item.find('img').attr('src',res.data.image_url); $item.find('input').val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); }); diff --git a/page/table/newcarlistedit.html b/page/table/newcarlistedit.html index 1128cc1..baaba84 100755 --- a/page/table/newcarlistedit.html +++ b/page/table/newcarlistedit.html @@ -360,11 +360,20 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ $item.find('img').attr('src',res.data.image_url); $item.find('input').val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); }); diff --git a/page/table/typeadd.html b/page/table/typeadd.html index 88dfb23..64e842b 100755 --- a/page/table/typeadd.html +++ b/page/table/typeadd.html @@ -76,11 +76,20 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ $(".img-3").attr('src',res.data.image_url); $("#avatarinput").val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); //监听提交 diff --git a/page/table/typeedit.html b/page/table/typeedit.html index fdf0990..2a8a67b 100755 --- a/page/table/typeedit.html +++ b/page/table/typeedit.html @@ -120,11 +120,20 @@ url:baseUrl+ 'console/upload/image', accept: 'images', field: 'image', + before: function(obj) { + // 显示上传loading + showUploadLoading(); + }, done: function(res){ + hideUploadLoading(); if(res.code == 0){ $(".img-3").attr('src',res.data.image_url); $("#avatarinput").val(res.data.image_name); } + }, + error: function() { + layer.msg('上传失败'); + hideUploadLoading(); } }); });