通过url,获取参数
export const getParamsByUrl = function () {
let obj = {}
let search = window.location.search.split('?').pop()
let arr = search.split('&')
for (let i = 0; i < arr.length; i++) {
let temp = arr[i].split('=')
obj[temp[0]] = temp[1]
}
return obj
}
// layer移动端的用法,页面初始化时,需要加载layer依赖的css和js
layer.open({
type: 2,
time: 2,
success: function(){
setTimeout(() => {
window.location.reload(true)
}, 3000)
}
})
// 获取token,getTokenSettimeout()方法需要初始化调用
window.getToken = function getToken(res) {
if(res){
let userInfo = res.split(",");
setStore("language",userInfo[0])
setStore("token",userInfo[1])
}
};
function getTokenSettimeout() {
let timerToken = setInterval(function (){
if(getStore("token")!==undefined){
clearTimeout(timerToken);
}else{
getToken()
if(getStore("token")===undefined){
getTokenSettimeout()
}
}
},300)
}
网友评论