1234567891011121314151617181920212223242526272829303132333435 |
- //获取url的参数params
- export const getParams = () => {
- let str = location.href;
- let num = str.indexOf('?');
- const param = {};
- str = str.substr(num + 1);
- //history模式使用这个
- // let num2 = str.indexOf('#');
- // console.log(num2);
- // let str2 = '';
- // if (num2 > 0) {
- // str2 = str.substr(0, num2);
- // } else {
- // num2 = str.indexOf('/');
- // str2 = str.substr(0, num2);
- // console.log(str2);
- // }
- const arr = str.split('&');
- for (let i = 0; i < arr.length; i++) {
- num = arr[i].indexOf('=');
- if (num > 0) {
- const name = arr[i].substring(0, num);
- const value = arr[i].substr(num + 1);
- param[name] = decodeURI(value);
- }
- }
- return param;
- };
- //判断信息是否过期
- export const isDateOff = dataDate => {
- const now = new Date(new Date().getTime() - 24 * 60 * 60 * 1000);
- dataDate = new Date(dataDate);
- return now.getTime() <= dataDate.getTime();
- };
|