diff --git a/details.html b/details.html index cf74faa..28e8c54 100644 --- a/details.html +++ b/details.html @@ -477,7 +477,7 @@

微信公众号

let tempData = JSON.parse(xmlhttp.responseText).Response; document.getElementById("title").innerHTML = `${tempData.name}

${ - tempData.create.split("T")[0] + tempData&&tempData.create&&tempData.create.split("T")[0] } / V${ tempData.version } 0){ renderTpl('searchTpl', { data: dataList }, '#itemlist') diff --git a/utils/_Get.js b/utils/_Get.js index 95de794..a9efebe 100644 --- a/utils/_Get.js +++ b/utils/_Get.js @@ -1,4 +1,7 @@ -function _Get(url, callback, isAllData) { +// get方法 默认返回Body +function _Get(url, callback, type) { + type = type || 'body' + var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); @@ -9,13 +12,24 @@ function _Get(url, callback, isAllData) { ); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState === 4 && xmlhttp.status === 200) { - if (isAllData) { + if (type === 'isAllData') {// get方法返回所有接口数据 var result = JSON.parse(xmlhttp.responseText) callback&&callback(result) return ; } - var result = JSON.parse(xmlhttp.responseText).body; - callback&&callback(result) + + if (type === 'response') { // get方法返回Response + var result = JSON.parse(xmlhttp.responseText).Response; + callback&&callback(result) + return ; + } + + // get方法返回Body + if (type === 'body') { + var result = JSON.parse(xmlhttp.responseText).body; + callback&&callback(result) + return ; + } } }; xmlhttp.setRequestHeader(