Commit ffb9b711 authored by 黄奎's avatar 黄奎

页面修改

parent 308e3d4b
...@@ -3,95 +3,182 @@ import axios from 'axios' ...@@ -3,95 +3,182 @@ import axios from 'axios'
import md5 from 'js-md5' import md5 from 'js-md5'
//域名管理对象 //域名管理对象
Vue.prototype.domainManager = function() { Vue.prototype.domainManager = function () {
let domainUrl = ''; let domainUrl = '';
domainUrl = "http://192.168.2.214:8082"; domainUrl = "http://192.168.2.214:8082";
//domainUrl="http://192.168.0.110"; domainUrl = "http://192.168.0.110";
//let locationName = location.hostname; //let locationName = location.hostname;
// if (locationName.indexOf('testerp.oytour') !== -1) { // if (locationName.indexOf('testerp.oytour') !== -1) {
// domainUrl = "http://testapi.oytour.com"; // domainUrl = "http://testapi.oytour.com";
// } else if (locationName.indexOf('oytour') !== -1) { // } else if (locationName.indexOf('oytour') !== -1) {
// domainUrl = "http://reborn.oytour.com"; // domainUrl = "http://reborn.oytour.com";
// } // }
var obj = { var obj = {
//主地址 //主地址
DomainUrl: domainUrl, DomainUrl: domainUrl,
//常用提交数据URL //常用提交数据URL
PostUrl: domainUrl + "/api/common/post", PostUrl: domainUrl + "/api/common/post",
}; };
return obj; return obj;
} }
//HTTP提交数据 //HTTP提交数据
Vue.prototype.apipost = function(cmd, msg, successCall, faildCall) { Vue.prototype.apipost = function (cmd, msg, successCall, faildCall) {
if (msg == null || msg == "") { if (msg == null || msg == "") {
msg = {} msg = {}
} }
var timestamp = (new Date()).valueOf(); var timestamp = (new Date()).valueOf();
var apiurl = this.domainManager().PostUrl; var apiurl = this.domainManager().PostUrl;
var token = ""; var token = "";
var key = ""; var key = "";
var tempLanguage = 0; var tempLanguage = 0;
if (this.getLocalStorage() != null) { if (this.getLocalStorage() != null) {
token = this.getLocalStorage().token; token = this.getLocalStorage().token;
key = this.getLocalStorage().SecretKey; key = this.getLocalStorage().SecretKey;
} }
var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase(); var encodeMsg = encodeURIComponent(JSON.stringify(msg)).toLowerCase();
var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`); var md5Str = md5(`cmd=${cmd}&msg=${encodeMsg}&timestamp=${timestamp}&token=${token}&key=${key}`);
var postData = { var postData = {
msg: msg, msg: msg,
cmd: cmd, cmd: cmd,
timestamp: timestamp, timestamp: timestamp,
token: token, token: token,
sign: md5Str, sign: md5Str,
languageId: tempLanguage languageId: tempLanguage
} }
this.$axios.post(apiurl, postData, { this.$axios.post(apiurl, postData, {
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
'Referer-Viitto': this.$route.path 'Referer-Viitto': this.$route.path
} }
}) })
.then(res => { .then(res => {
successCall(res); successCall(res);
}, faildCall) }, faildCall)
} }
//获取缓存 //获取缓存
Vue.prototype.getLocalStorage = function() { Vue.prototype.getLocalStorage = function () {
try { try {
var localStorageData = window.localStorage["b2bUser"]; var localStorageData = window.localStorage["b2bUser"];
if (localStorageData !== undefined && localStorageData != 'undefined') { if (localStorageData !== undefined && localStorageData != 'undefined') {
return JSON.parse(localStorageData); return JSON.parse(localStorageData);
} else { } else {
return null; return null;
}
} catch (error) {
return null;
} }
} catch (error) {
return null;
}
} }
//向外跳转 //向外跳转
Vue.prototype.OpenNewUrl = function(URL) { Vue.prototype.OpenNewUrl = function (URL) {
if (URL && URL != '') { if (URL && URL != '') {
if (URL.indexOf("https") != -1) { if (URL.indexOf("https") != -1) {
var str = 'http://' + URL.substring(8); var str = 'http://' + URL.substring(8);
window.open(str, '_blank'); window.open(str, '_blank');
} else if (URL.indexOf("http") != -1) { } else if (URL.indexOf("http") != -1) {
var str = 'http://' + URL.substring(7); var str = 'http://' + URL.substring(7);
window.open(str, '_blank'); window.open(str, '_blank');
} else { } else {
window.open("http://" + URL, '_blank'); window.open("http://" + URL, '_blank');
}
} }
}
} }
//公用跳转 //公用跳转
Vue.prototype.CommonJump = function(path, obj) { Vue.prototype.CommonJump = function (path, obj) {
this.$router.push({ this.$router.push({
path: path, path: path,
query: obj query: obj
}); });
}
Vue.prototype.createCalendar = function (dateStr) {
var days = [];
var date;
if (dateStr) {
date = new Date(dateStr);
} else {
var now = new Date();
date = new Date(this.formatDate(now.getFullYear(), now.getMonth() + 1, 1));
}
var currentDay = date.getDate();
var currentYear = date.getFullYear();
var currentMonth = date.getMonth() + 1;
var currentWeek = date.getDay(); // 1...6,0
var str = this.formatDate(
currentYear,
currentMonth,
currentDay
);
days.length = 0;
// 当月第一天是周日,放在第一行第1个位置,前面0个
//初始化第一周
for (var i = currentWeek; i >= 0; i--) {
var d = new Date(str);
d.setDate(d.getDate() - i);
var dayobject = {};
dayobject.day = d;
days.push(dayobject); //将日期放入data 中的days数组 供页面渲染使用
}
//其他周
var temp = 35;
if (
currentWeek +
new Date(currentYear, currentMonth, 0).getDate() > 35
) {
temp = 41;
}
for (var i = 1; i < temp - currentWeek; i++) {
var d = new Date(str);
d.setDate(d.getDate() + i);
var dayobject = {};
dayobject.day = d;
days.push(dayobject);
}
return {
DayArray: days,
CurrentDay: currentDay,
CurrentMonth: currentMonth,
CurrentYear: currentYear,
CurrentWeek: currentWeek
};
}
//格式化日期
Vue.prototype.formatDate = function (year, month, day) {
var y = year;
var m = month;
if (m < 10) m = "0" + m;
var d = day;
if (d < 10) d = "0" + d;
return y + "-" + m + "-" + d;
}
//格式化日期二
Vue.prototype.formatDate2=function(dateStr)
{
var date=new Date(dateStr);
return {
CYear:date.getFullYear(),
CMonth:(date.getMonth()+1),
CDay:date.getDate(),
}
}
//添加月份
Vue.prototype.AddMonth=function(dateStr,month)
{
var v = new Date(dateStr);
if (v) {
var t = new Date(v.getFullYear(), v.getMonth(), v.getDate(), v.getHours(), v.getMinutes(), v.getSeconds(), v.getMilliseconds());
t.setMonth(v.getMonth() + month);
if (t.getDate() != v.getDate()) { t.setDate(0); }
return t;
}
} }
\ No newline at end of file
This diff is collapsed.
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