|
@@ -11,7 +11,7 @@ const { serverAddress } = config
|
|
|
Vue.use(VueAxios, axios)
|
|
|
|
|
|
|
|
|
-/* 常用ajax封装 (固定URL) */
|
|
|
+/* ajax封装 */
|
|
|
export const ajax = function (type = "post", url, params) {
|
|
|
let token = localStorage.getItem("token")
|
|
|
return new Promise((resole, reject) => {
|
|
@@ -36,3 +36,30 @@ export const ajax = function (type = "post", url, params) {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+/* 测试服务的 ajax封装 */
|
|
|
+export const ajaxTest = function (type = "post", url, params) {
|
|
|
+ let token = localStorage.getItem("token")
|
|
|
+ return new Promise((resole, reject) => {
|
|
|
+ axios({
|
|
|
+ method: type,
|
|
|
+ url: "http://192.168.1.116:31288" + url,
|
|
|
+ params,
|
|
|
+ headers: {
|
|
|
+ 'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
+ 'x-auth-token': token
|
|
|
+ }
|
|
|
+ }).then((res) => {
|
|
|
+ switch(res.data.errCode) {
|
|
|
+ case 'request_not_authorize': // 登录过期
|
|
|
+ let url = window.location.protocol + "//" + window.location.host + "/#/login"
|
|
|
+ window.location.replace(url)
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ resole(res.data);
|
|
|
+ }).catch((err) => {
|
|
|
+ reject(err.data);
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|