//var APIURL = "http://192.168.1.145:83/api/";
|
var APIURL = "http://localhost:55640/api/";
|
var APIURL_PC = "http://192.168.1.145:81/api/";
|
var ISNEEDLOGIN = true;
|
String.prototype.trim = function () {
|
return this.replace(/(^\s*)|(\s*$)/g, "");
|
}
|
String.prototype.ltrim = function () {
|
return this.replace(/(^\s*)/g, "");
|
}
|
String.prototype.rtrim = function () {
|
return this.replace(/(\s*$)/g, "");
|
}
|
Vue.prototype.CHECKLOGIN = function () {
|
var that = this;
|
var loginInfo = {
|
loginGuid: Cookies.get('loginGuid'),
|
loginAccount: Cookies.get('loginAccount'),
|
}
|
if (!loginInfo
|
|| (loginInfo) == "undefined"
|
|| typeof (loginInfo.loginGuid) == "undefined"
|
|| typeof (loginInfo.loginGuid) == "undefined"
|
|| typeof (loginInfo.loginGuid).length < 1
|
) {
|
if (ISNEEDLOGIN == true)
|
window.location.href = "/UserLogin.aspx";
|
return;
|
}
|
}
|
Vue.prototype.Request = function (paras) {
|
if (typeof (paras) == "undefined") {
|
return "";
|
}
|
var url = location.href;
|
var paraString = url.substring(url.indexOf("?") + 1, url.length).split("&");
|
var paraObj = {}
|
for (i = 0; j = paraString[i]; i++) {
|
paraObj[j.substring(0, j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=") + 1, j.length);
|
}
|
var returnValue = paraObj[paras.toLowerCase()];
|
if (typeof (returnValue) == "undefined") {
|
return "";
|
} else {
|
return decodeURI(returnValue);
|
}
|
}
|
Vue.prototype.GetLoginInfor = function () {
|
var that = this;
|
var loginInfo = {
|
loginGuid: Cookies.get('loginGuid'),
|
loginAccount: Cookies.get('loginAccount'),
|
}
|
if (!loginInfo
|
|| (loginInfo) == "undefined"
|
|| typeof (loginInfo.loginGuid) == "undefined"
|
|| typeof (loginInfo.loginGuid) == "undefined"
|
|| typeof (loginInfo.loginGuid).length < 1
|
) {
|
if (ISNEEDLOGIN == true)
|
window.location.href = "/UserLogin.aspx";
|
}
|
else {
|
return loginInfo;
|
}
|
}
|
/**
|
* axios
|
* @param:{string} method 请求类型,必填
|
* @param:{string} url 请求地址,必填
|
* @param:{string} params 请求参数,非必填
|
* @param:{string} variation 请求头,非必填
|
**/
|
Vue.prototype.AxiosHttp = (method, url, params = {}, isToken = true) => {
|
url = (APIURL + url);
|
let headers = { 'Content-Type': 'application/json', }
|
if (isToken) {
|
var timestamp = (new Date()).getTime();
|
var token = "BasicAuth " + timestamp + "_" + Cookies.get('loginGuid');
|
headers['Authorization'] = token;
|
}
|
if (method == 'get') {
|
// console.log("params")
|
return axios({
|
method: method,
|
url: url,
|
headers: headers,
|
params: params
|
}).then(res => res.data);
|
} else {
|
return axios({
|
method: method,
|
url: url,
|
headers: headers,
|
data: params
|
}).then(res => res.data);
|
}
|
};
|
//axiosRequest('get', '/user/page', {},false).then(res=>{})
|
//axiosRequest('post', '/user/page', {},false).then(res=>{})
|
|
// 添加全局v-focus指令
|
Vue.directive("focus", {
|
//inserted: function (el, { modifiers: { noKeyboard } }) {
|
// try {
|
// const tagName = el.tagName;
|
// if (tagName !== "INPUT") {
|
// let child = el.children[0];
|
// if (child && child.tagName === "INPUT") {
|
// el = child;
|
// }
|
// }
|
// var _count = (el.children.length);
|
// if (_count > 1)
|
// el = el.children[1].children[0].children[0];
|
// else
|
// el = el.children[0].children[0].children[0];
|
// // alert(el);
|
// // 可以重新获得焦点又不弹起软键盘;xxx是el-input的ref
|
// // this.$refs[xxx].$refs.input.noKeyboardFocus();
|
// el.noKeyboardFocus = function () {
|
// Vue.nextTick(() => {
|
// this.focus();
|
// this.setAttribute("readonly", "readonly");
|
// var timer = null;
|
// timer = setTimeout(() => {
|
// this.removeAttribute("readonly");
|
// clearTimeout(timer);
|
// }, 100);
|
// });
|
// };
|
// el.focus();
|
// // v-focus.noKeyboard 不弹起软键盘
|
// if (noKeyboard) {
|
// el.setAttribute("readonly", "readonly");
|
// var timer = null;
|
// timer = setTimeout(() => {
|
// el.removeAttribute("readonly");
|
// clearTimeout(timer);
|
// }, 100);
|
// }
|
// } catch (error) {
|
// throw new Error(error);
|
// }
|
//}
|
});
|
|
|
Vue.prototype.GoBack=function(){
|
var _userGuid = Cookies.get('loginGuid');
|
var _userAccount = Cookies.get('loginAccount');
|
var _url = "/H5/Default.aspx?userGuid=" + _userGuid + "&userAccount" + _userAccount + "&tabIdx=" + this.Request("tabIdx");
|
window.location.href = _url;
|
return;
|
window.history.back();
|
}
|