|
@@ -1,5 +1,6 @@
|
|
|
import numeral from 'numeral';
|
|
|
import dayjs from 'dayjs';
|
|
|
+import qs from 'query-string';
|
|
|
|
|
|
export const browser = () => {
|
|
|
const u = navigator.userAgent;
|
|
@@ -29,17 +30,27 @@ export const browser = () => {
|
|
|
// 获取授权的code码
|
|
|
export const getUrlCode = (name = 'code') => {
|
|
|
// 截取url中的code方法
|
|
|
- const url = location.search;
|
|
|
- const theRequest: any = new Object();
|
|
|
- if (url.indexOf('?') != -1) {
|
|
|
- const str = url.substr(1);
|
|
|
- const strs = str.split('&');
|
|
|
- for (let i = 0; i < strs.length; i++) {
|
|
|
- theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
|
|
|
- }
|
|
|
+ // const url = location.search;
|
|
|
+ // const theRequest: any = new Object();
|
|
|
+ // if (url.indexOf('?') != -1) {
|
|
|
+ // const str = url.substr(1);
|
|
|
+ // const strs = str.split('&');
|
|
|
+ // for (let i = 0; i < strs.length; i++) {
|
|
|
+ // theRequest[strs[i].split('=')[0]] = strs[i].split('=')[1];
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // console.log(theRequest, 'theRequest');
|
|
|
+ // return theRequest[name];
|
|
|
+ let search: any = {};
|
|
|
+ try {
|
|
|
+ search = {
|
|
|
+ ...qs.parse(location.search),
|
|
|
+ ...qs.parse(location.hash.split('?')[1])
|
|
|
+ };
|
|
|
+ } catch (error) {
|
|
|
+ //
|
|
|
}
|
|
|
- console.log(theRequest, 'theRequest');
|
|
|
- return theRequest[name];
|
|
|
+ return search[name];
|
|
|
};
|
|
|
|
|
|
export const getRandomKey = () => {
|