From a9b3401c70b9b325e9e6c23260c3175d2404fdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=B9=E5=90=89=E6=AC=A2?= Date: Tue, 17 Apr 2018 14:28:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E4=BA=A7=E8=AF=84=E4=BC=B0=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E6=8F=90=E4=BA=A4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fangija-zsyf/js/axiosPlugin.js | 9 ++++++--- fangija-zsyf/views/house/add.html | 25 ++++++++++++++++++++++--- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/fangija-zsyf/js/axiosPlugin.js b/fangija-zsyf/js/axiosPlugin.js index 114b348..6088dd2 100644 --- a/fangija-zsyf/js/axiosPlugin.js +++ b/fangija-zsyf/js/axiosPlugin.js @@ -1,6 +1,6 @@ axios.defaults.baseURL = BASE_PATH; axios.defaults.headers.post['Content-Type'] = 'application/json'; -axios.defaults.timeout = 10000; +axios.defaults.timeout = 15000; // 添加请求拦截器 axios.interceptors.request.use(function (config) { @@ -15,14 +15,17 @@ axios.interceptors.request.use(function (config) { axios.interceptors.response.use(function (response) { return response; }, function (error) { - if(error=="Error: Network Error"){ + if (error.toString().indexOf('timeout') > -1) { + plus.nativeUI.alert("请求超时"); + plus.nativeUI.closeWaiting(); + }else if(error=="Error: Network Error"){ if(plus.webview.getWebviewById('error.html')==null){ clicked('error.html',true,false,{},{},function(){ window.location.reload(); }) }else{ $(".loadingBg").hide(); - plus.nativeUI.closeWaiting(); + plus.nativeUI.closeWaiting(); plus.webview.getWebviewById("error.html").show(); } } diff --git a/fangija-zsyf/views/house/add.html b/fangija-zsyf/views/house/add.html index 13cb2fa..f412cfa 100644 --- a/fangija-zsyf/views/house/add.html +++ b/fangija-zsyf/views/house/add.html @@ -1267,7 +1267,23 @@ function onPlusReady(){ $("#input_city").val("上海"); $(".nowCity").text("上海"); } + getRequestId(); } + +// 生成请求ID,防止重复提交 +var requestId = ""; +function getRequestId() { + axios.get("/rest/index/id") + .then(function (response) { + if(response.data.status){ + requestId = response.data.data; + } + }) + .catch(function (error) { + console.log(error); + }); +} + /* 弹出城市选择页面 */ $(document).on("click",".open-about01", function () { $.popup(".popup-about01"); @@ -1828,7 +1844,7 @@ function checkIsLogin(){ function addEvaluation(){ var data={}; if(type==0){ - data={cityDisplay: $("#input_city").val(), + data={id:requestId,cityDisplay: $("#input_city").val(), region:$("input[name=region]").val(), district:$("#input_address").val(), address:$("input[name=address]").val(), @@ -1844,7 +1860,7 @@ function addEvaluation(){ lastRentDate:$("#input_time03").val(), houseStatus:0} }else{ - data={cityDisplay: $("#input_city").val(), + data={id:requestId,cityDisplay: $("#input_city").val(), region:$("input[name=region]").val(), district:$("#input_address").val(), address:$("input[name=address]").val(), @@ -1863,7 +1879,9 @@ function addEvaluation(){ var id = response.data.data.id; plus.webview.getWebviewById('views/house/houseManageList.html').reload(); plus.webview.getWebviewById('views/user/userInfo.html').reload(); - clicked('/views/evaluate/evaluateReport.html',true,false,{},{hid:id}) + clicked('/views/evaluate/evaluateReport.html',true,false,{},{hid:id},function(){ + getRequestId(); + }) }else{ $("#evaluation_btn").removeAttr("disabled"); $.toast(response.data.message); @@ -1874,6 +1892,7 @@ function addEvaluation(){ }); } + /* 信息输入弹窗 */ $(document).on('click','.open-modal', function () { $.modal({