iframe传参

master
杜函宇 2 years ago
parent 97e1344aca
commit 281579e87d

@ -20,30 +20,37 @@ export default {
},
};
},
mounted() {
//
var queryString = window.location.search;
// URLSearchParams
var params = new URLSearchParams(queryString);
// JSON
// //
// var queryString = window.location.search;
// // URLSearchParams
// var params = new URLSearchParams(queryString);
// // JSON
// var obj = {};
// // JSON
// params.forEach(function (value, key) {
// //
// var decodedValue = decodeURIComponent(value);
// obj[key] = decodedValue;
// });
var obj = {};
// JSON
params.forEach(function (value, key) {
//
var decodedValue = decodeURIComponent(value);
obj[key] = decodedValue;
window.addEventListener("message", function (event) {
console.log(event);
obj = event.data.data;
console.log(obj);
if (obj.token) {
localStorage.setItem("MSSM-LIAONING__TOKEN", obj.token);
} else {
this.$alert("token不能为空", "提示", {
confirmButtonText: "返回",
callback: (action) => {
this.$router.go(-1);
},
});
}
this.$store.commit("app/URLChange", obj);
});
if (obj.token) {
localStorage.setItem("MSSM-LIAONING__TOKEN", obj.token);
} else {
this.$alert("暂无token",'提示', {
confirmButtonText: "返回",
callback: (action) => {
this.$router.go(-1);
},
});
}
this.$store.commit("app/URLChange", obj);
},
};
</script>

@ -12,18 +12,8 @@ import axios from "axios";
NProgress.configure({ showSpinner: false });
const whiteList = ["/login", "/register"];
router.beforeEach(async (to, from, next) => {
let token = localStorage.getItem('MSSM-LIAONING__TOKEN')
if (token) {
next()
} else {
this.$alert("暂无token",'提示', {
confirmButtonText: "返回",
callback: (action) => {
this.$router.go(-1);
},
});
}
router.beforeEach((to, from, next) => {
next()
})
router.afterEach(() => {
NProgress.done();

Loading…
Cancel
Save