From 18eabf15daa1876b5200659e8fac24b2bd76ff39 Mon Sep 17 00:00:00 2001
From: zhanmingkan <496160012@qq.com>
Date: 星期二, 17 五月 2022 11:36:32 +0800
Subject: [PATCH] initToken
---
assets/js/config.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 1 deletions(-)
diff --git a/assets/js/config.js b/assets/js/config.js
index db20c9e..23934b5 100644
--- a/assets/js/config.js
+++ b/assets/js/config.js
@@ -10,4 +10,95 @@
var layerPageStyle={
offsetX: 100,
offsetY:50
-}
\ No newline at end of file
+}
+
+
+var vMsg = new Vue({
+ methods: {
+ success(msg) {
+ this.$message({ message: msg, type: 'success' });
+ },
+ info(msg) {
+ this.$message(msg);
+ },
+ warning(msg) {
+ this.$message({ message: msg, type: 'warning' });
+ },
+ error(msg) {
+ this.$message.error(msg);
+ },
+ iconSuccess(title,msg) {
+ this.$notify({
+ title: title,
+ message: msg,
+ type: 'success'
+ });
+ },
+ iconWarning(title,msg) {
+ this.$notify({
+ title: title,
+ message: msg,
+ type: 'warning'
+ });
+ },
+ iconWarningWithTime(title,msg,time) {
+ this.$notify({
+ duration:time,
+ title: title,
+ message: msg,
+ type: 'warning'
+ });
+ },
+ },
+});
+
+
+function getQueryString(name) {
+ var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
+ var r = decodeURI(window.location.search.substr(1)).match(reg);
+ if (r != null) {
+ return unescape(r[2]);
+ }
+ return null;
+}
+initToken();
+function initToken(){
+ var userName = getQueryString("username");
+ var JSESSIONID = getQueryString("JSESSIONID");
+ window.localStorage.setItem("username", userName);
+ window.localStorage.setItem("JSESSIONID", JSESSIONID);
+ $("#username").append(userName);
+
+ $.ajax({
+ type: "post",
+ async: false,
+ url: httpConfig.webApiUrl + "landstamp/front/token?sessionId=" + JSESSIONID,
+ contentType: "application/json;charset=utf-8",
+ success: function (data) {
+ if(data.code==0){
+ window.localStorage.setItem("token", data.token);
+ }
+ console.log(data);
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ console.log("ajax璇锋眰澶辫触锛�");
+ }
+ });
+ var token = window.localStorage.getItem("token");
+ $.ajax({
+ type: "post",
+ async: false,
+ url: httpConfig.webApiUrl + "landstamp/front/userlogo" ,
+ contentType: "application/json;charset=utf-8",
+ beforeSend:function(request){
+ request.setRequestHeader("token",token);
+ },
+ success: function (data) {
+ document.getElementById("userlogo").setAttribute("src", data.avatar);
+ },
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
+ console.log("ajax璇锋眰澶辫触锛�");
+ }
+ });
+
+}
--
Gitblit v1.9.1