Commit ba7814f9 authored by Mac's avatar Mac

1

parent 1dbd5f81
import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import Erpindex from '../utils/erpindex'
import axios from 'axios'
Vue.use(ElementUI)
Vue.use(Erpindex)
Vue.prototype.$axios = axios
export default{
data:{
loginUser: {},
apiurl: ''
},
install(Vue, options){
//ERP本地缓存
Vue.prototype.getLocalStorage = function () {
console.log('进入~~~~~~')
var localStorageData = window.localStorage["userInfo"];
if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData);
} else {
return null;
}
},
//HTTP提交数据
Vue.prototype.apipost = function (cmd, msg, successCall, faildCall, isOnline) {
if (this.$route.name.indexOf('login') === -1 && this.$route.name.indexOf('clientConfirm') === -1 &&
this.$route.name.indexOf('confirmationOrderDownLoad') === -1 && this.$route.name.indexOf('PrintPage') === -1 &&
this.$route.name.indexOf('TravelContractConfirm') === -1 && this.$route.name.indexOf('ViittoContractConfirm') === -1 &&
this.$route.name.indexOf('OrderProfitLossList') === -1
) {
let previousPathInfo = {
path: this.$route.name,
query: this.$route.query
}
localStorage.previousPathInfo = JSON.stringify(previousPathInfo);
}
if (msg == null || msg == "") {
msg = {}
}
var apiurl = this.domainManager().PostUrl;
//酒店接口
if (isOnline) {
apiurl = this.domainManager().HotelApi;
}
var timestamp = (new Date()).valueOf();
this.apiurl = apiurl;
if (this.$route.path.toLowerCase() == "/signature") {
this.$router.push({
path: '/signature'
})
} else if (this.$route.path == "/clientConfirm") {
let TCID = this.$route.query.TCID;
let orderID = this.$route.query.orderID;
this.$router.push({
name: "clientConfirm",
query: {
TCID: TCID,
orderID: orderID
}
})
} else if (this.$route.path == "/TravelContractConfirm") {
let ContractId = this.$route.query.ContractId;
this.$router.push({
name: "TravelContractConfirm",
query: {
ContractId: ContractId
}
})
} else if (this.$route.path == "/ViittoContractConfirm") {
let Id = this.$route.query.Id;
this.$router.push({
name: "ViittoContractConfirm",
query: {
Id: Id
}
})
} else {
if (!localStorage.userInfo && localStorage.userInfo != "" && this.$route.path.toLowerCase() != "/login") {
this.$router.push({
path: '/login'
})
}
}
var token = "";
var key = "";
if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token;
key = this.getLocalStorage().SecretKey;
}
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
let tempLanguage = 0;
if (localStorage.language && localStorage.language != '') {
if (localStorage.language == "zh-TW") {
tempLanguage = 1;
} else if (localStorage.language == "Japanese") {
tempLanguage = 2;
}
}
var postData = {
"msg": msg,
"cmd": cmd,
"timestamp": timestamp,
"token": token,
"sign": md5Str,
"languageId": tempLanguage
}
this.$http.post(apiurl, postData, {
headers: {
'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path
}
})
.then(res => {
if (res.data.resultCode == 10000 || res.data.resultCode == 10001) {
this.$router.push({
path: '/login'
});
} else if (res.resultCode == 10005) {
this.$router.go(-1);
} else {
successCall(res);
}
}, faildCall)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment