|
|
|
|
|
|
|
|
|
|
|
import qs from 'qs'; |
|
|
|
|
|
let httpRoot = 'http://news.envisioncn.com/api/web';//接口根路径 |
|
|
|
|
|
// let httpRoot = 'http://www.jiyou-tech.com/2019/404/api/web/';//接口根路径 |
|
|
|
|
|
/* |
|
|
|
|
|
* http方法 |
|
|
|
|
|
* 参数:{ |
|
|
|
|
|
* url:接口路径 |
|
|
|
|
|
* params:传入的参数 |
|
|
|
|
|
* callback:回调函数 |
|
|
|
|
|
* thisArg:指向接口调用页面(接口调用页面的this) |
|
|
|
|
|
* type:调用方式(post or get) |
|
|
|
|
|
* } |
|
|
|
|
|
*/ |
|
|
|
|
|
function httpFun(url,params,callback, thisArg,uid,type) { |
|
|
|
|
|
if(!type || type.toUpperCase() == "GET"){ |
|
|
|
|
|
this.axios.get(httpRoot+url,{params, |
|
|
|
|
|
headers:{ |
|
|
|
|
|
uid:uid || "" |
|
|
|
|
|
} |
|
|
|
|
|
}).then((response)=>{ |
|
|
|
|
|
if (callback && thisArg) { |
|
|
|
|
|
callback.call(thisArg,response.data); |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((response)=>{ |
|
|
|
|
|
console.log(response); |
|
|
|
|
|
}) |
|
|
|
|
|
}else{ |
|
|
|
|
|
this.axios.post(httpRoot+url,qs.stringify(params),{ |
|
|
|
|
|
headers:{ |
|
|
|
|
|
uid:uid || "", |
|
|
|
|
|
"Content-Type":"application/x-www-form-urlencoded" |
|
|
|
|
|
} |
|
|
|
|
|
}).then((response)=>{ |
|
|
|
|
|
if (callback && thisArg) { |
|
|
|
|
|
callback.call(thisArg,response.data); |
|
|
|
|
|
} |
|
|
|
|
|
}).catch((response)=>{ |
|
|
|
|
|
console.log(response); |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
function stopPullDown (){ |
|
|
|
|
|
let that = this; |
|
|
|
|
|
let all = document.getElementById("app"); |
|
|
|
|
|
let startSite = 0; |
|
|
|
|
|
all.addEventListener("touchstart",function () { |
|
|
|
|
|
startSite=event.touches[0].clientY; |
|
|
|
|
|
}); |
|
|
|
|
|
all.addEventListener("touchmove",function () { |
|
|
|
|
|
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; |
|
|
|
|
|
if(scrollTop==0 && event.touches[0].clientY>startSite && !that.$store.state.menuState){ |
|
|
|
|
|
event.preventDefault(); |
|
|
|
|
|
} |
|
|
|
|
|
},false); |
|
|
|
|
|
} |
|
|
|
|
|
export {httpFun,stopPullDown}; |