Commit 322cd3d9 by cocomilk2012

Merge branch 'dev'

parents 61cba9a3 9e8c4c31
VUE_APP_OIDC_CONFIG = '{ "authority": "http://106.120.107.150:5000", "client_id": "teamix-personal-center-web-pc", "client_secret": "123456", "redirect_uri": "http://localhost:8080/callback.html", "response_type": "id_token token", "scope": "openid workapps.client api.workapps.user","post_logout_redirect_uri":"http://localhost:8080", "silent_redirect_uri": "http://localhost:8080/silent-renew.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true,"loadUserInfo":true }' VUE_APP_OIDC_CONFIG = '{ "authority": "http://106.120.107.150:5000", "client_id": "qqxb-self-service-web-mobile", "client_secret": "123456", "redirect_uri": "http://localhost:8080/callback.html", "response_type": "id_token token", "scope": "openid workapps.client api.workapps.user","post_logout_redirect_uri":"http://localhost:8080", "silent_redirect_uri": "http://localhost:8080/silent-renew.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true,"loadUserInfo":true }'
VUE_APP_BASE_URL= http://organization.test.hrs100.cn:18080 VUE_APP_BASE_URL= http://organization.test.hrs100.cn:18080
......
VUE_APP_OIDC_CONFIG = '{ "authority": "https://passport.teammix.com", "client_id": "qqxb-activity-web-mobile", "client_secret": "qqxb#teammix#2019", "redirect_uri": "https://invite.activity.h5.hrs100.com/callback.html", "response_type": "id_token token", "scope": "workapps.client api.workapps.user api.workapps.org api.workapps.open openid","post_logout_redirect_uri":"https://invite.activity.h5.hrs100.com", "silent_redirect_uri": "https://invite.activity.h5.hrs100.com/silent-renew-oidc.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true }' VUE_APP_OIDC_CONFIG = '{ "authority": "https://passport.teammix.com", "client_id": "qqxb-self-service-web-mobile", "client_secret": "qqxb#teammix#2019", "redirect_uri": "https://invite.activity.h5.hrs100.com/callback.html", "response_type": "id_token token", "scope": "workapps.client api.workapps.user api.workapps.org api.workapps.open openid","post_logout_redirect_uri":"https://invite.activity.h5.hrs100.com", "silent_redirect_uri": "https://invite.activity.h5.hrs100.com/silent-renew-oidc.html", "automaticSilentRenew": true,"accessTokenExpiringNotificationTime":60,"filterProtocolClaims":true,"loadUserInfo":true }'
VUE_APP_USERINFO_URL=""; VUE_APP_USERINFO_URL="";
......
...@@ -2009,7 +2009,8 @@ ...@@ -2009,7 +2009,8 @@
"base64-js": { "base64-js": {
"version": "1.3.1", "version": "1.3.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==",
"dev": true
}, },
"batch": { "batch": {
"version": "0.6.1", "version": "0.6.1",
...@@ -3262,11 +3263,6 @@ ...@@ -3262,11 +3263,6 @@
"randomfill": "^1.0.3" "randomfill": "^1.0.3"
} }
}, },
"crypto-js": {
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.3.0.tgz",
"integrity": "sha512-DIT51nX0dCfKltpRiXV+/TVZq+Qq2NgF4644+K7Ttnla7zEzqc+kjJyiB96BHNyUTBxyjzRcZYpUdZa+QAqi6Q=="
},
"css-color-names": { "css-color-names": {
"version": "0.0.4", "version": "0.0.4",
"resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz", "resolved": "https://registry.npmjs.org/css-color-names/-/css-color-names-0.0.4.tgz",
...@@ -6852,24 +6848,6 @@ ...@@ -6852,24 +6848,6 @@
"integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==", "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==",
"dev": true "dev": true
}, },
"oidc-client": {
"version": "1.10.1",
"resolved": "https://registry.npmjs.org/oidc-client/-/oidc-client-1.10.1.tgz",
"integrity": "sha512-/QB5Nl7c9GmT9ir1E+OVY3+yZZnuk7Qa9ZEAJqSvDq0bAyAU9KAgeKipTEfKjGdGLTeOLy9FRWuNpULMkfZydQ==",
"requires": {
"base64-js": "^1.3.0",
"core-js": "^2.6.4",
"crypto-js": "^3.1.9-1",
"uuid": "^3.3.2"
},
"dependencies": {
"core-js": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.11.tgz",
"integrity": "sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg=="
}
}
},
"on-finished": { "on-finished": {
"version": "2.3.0", "version": "2.3.0",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz",
...@@ -10056,7 +10034,8 @@ ...@@ -10056,7 +10034,8 @@
"uuid": { "uuid": {
"version": "3.4.0", "version": "3.4.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==" "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
"dev": true
}, },
"validate-npm-package-license": { "validate-npm-package-license": {
"version": "3.0.4", "version": "3.0.4",
...@@ -10085,6 +10064,11 @@ ...@@ -10085,6 +10064,11 @@
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=", "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"dev": true "dev": true
}, },
"vconsole": {
"version": "3.3.4",
"resolved": "https://registry.npm.taobao.org/vconsole/download/vconsole-3.3.4.tgz",
"integrity": "sha1-p9rNiIez0+kC6NGEJc2lbDTnf1E="
},
"vendors": { "vendors": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz", "resolved": "https://registry.npmjs.org/vendors/-/vendors-1.0.4.tgz",
......
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
"echarts": "^4.8.0", "echarts": "^4.8.0",
"fastclick": "^1.0.6", "fastclick": "^1.0.6",
"moment": "^2.26.0", "moment": "^2.26.0",
"oidc-client": "^1.10.1",
"qs": "^6.9.4", "qs": "^6.9.4",
"vant": "^2.2.0", "vant": "^2.2.0",
"vconsole": "^3.3.4",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-class-component": "^7.2.3", "vue-class-component": "^7.2.3",
"vue-router": "^3.3.1", "vue-router": "^3.3.1",
......
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head>
<meta charset="utf-8"> <head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="icon" href="<%= BASE_URL %>favicon.ico"> <meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>员工自助</title> <link rel="icon" href="<%= BASE_URL %>favicon.ico">
</head> <title>员工自助</title>
<body> </head>
<noscript>
<strong>We're sorry but typescript doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> <body>
</noscript> <noscript>
<div id="app"></div> <strong>We're sorry but typescript doesn't work properly without JavaScript enabled. Please enable it to
<!-- built files will be auto injected --> continue.</strong>
</body> </noscript>
</html> <div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
\ No newline at end of file
function bin2hex (s) {
var i,
l,
o = "",
n;
s += "";
for (i = 0, l = s.length; i < l; i++) {
n = s.charCodeAt(i).toString(16)
o += n.length < 2 ? "0" + n : n;
}
return o;
}
function getCanvas () {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "#f60";
ctx.fillRect(125, 1, 62, 20);
var b64 = canvas.toDataURL().replace("data:image/png;base64,", "");
var bin = atob(b64);
var crc = bin2hex(bin.slice(-16, -12));
return crc;
}
function getOsInfo () {
var userAgent = navigator.userAgent.toLowerCase();
var name = "Unknown";
var version = "Unknown";
if (userAgent.indexOf("win") > -1) {
name = "Windows";
if (userAgent.indexOf("windows nt 5.0") > -1) {
version = "Windows 2000";
} else if (
userAgent.indexOf("windows nt 5.1") > -1 ||
userAgent.indexOf("windows nt 5.2") > -1
) {
version = "Windows XP";
} else if (userAgent.indexOf("windows nt 6.0") > -1) {
version = "Windows Vista";
} else if (
userAgent.indexOf("windows nt 6.1") > -1 ||
userAgent.indexOf("windows 7") > -1
) {
version = "Windows 7";
} else if (
userAgent.indexOf("windows nt 6.2") > -1 ||
userAgent.indexOf("windows 8") > -1
) {
version = "Windows 8";
} else if (userAgent.indexOf("windows nt 6.3") > -1) {
version = "Windows 8.1";
} else if (
userAgent.indexOf("windows nt 6.2") > -1 ||
userAgent.indexOf("windows nt 10.0") > -1
) {
version = "Windows 10";
} else {
version = "Unknown";
}
} else if (userAgent.indexOf("iphone") > -1) {
name = "Iphone";
} else if (userAgent.indexOf("mac") > -1) {
name = "Mac";
} else if (
userAgent.indexOf("x11") > -1 ||
userAgent.indexOf("unix") > -1 ||
userAgent.indexOf("sunname") > -1 ||
userAgent.indexOf("bsd") > -1
) {
name = "Unix";
} else if (userAgent.indexOf("linux") > -1) {
if (userAgent.indexOf("android") > -1) {
name = "Android"
} else {
name = "Linux";
}
} else {
name = "Unknown";
}
var os = new Object();
os.name = name;
os.version = version;
return os;
//document.write("系统:" + os.name + "版本:" + os.name)
}
function getBrowerInfo () {
var Browser =
Browser ||
(function (window) {
var document = window.document,
navigator = window.navigator,
agent = navigator.userAgent.toLowerCase(),
//IE8+支持.返回浏览器渲染当前文档所用的模式
//IE6,IE7:undefined.IE8:8(兼容模式返回7).IE9:9(兼容模式返回7||8)
//IE10:10(兼容模式7||8||9)
IEMode = document.documentMode,
//chorme
chrome = window.chrome || false,
System = {
//user-agent
agent: agent,
//是否为IE
isIE: /trident/.test(agent),
//Gecko内核
isGecko: agent.indexOf("gecko") > 0 && agent.indexOf("like gecko") < 0,
//webkit内核
isWebkit: agent.indexOf("webkit") > 0,
//是否为标准模式
isStrict: document.compatMode === "CSS1Compat",
//是否支持subtitle
supportSubTitle: function () {
return "track" in document.createElement("track");
},
//是否支持scoped
supportScope: function () {
return "scoped" in document.createElement("style");
},
//获取IE的版本号
ieVersion: function () {
var rMsie = /(msie\s|trident.*rv:)([\w.]+)/;
var ma = window.navigator.userAgent.toLowerCase()
var match = rMsie.exec(ma);
try {
return match[2];
} catch (e) {
// console.log("error");
return IEMode;
}
},
//Opera版本号
operaVersion: function () {
try {
if (window.opera) {
return agent.match(/opera.([\d.]+)/)[1];
} else if (agent.indexOf("opr") > 0) {
return agent.match(/opr\/([\d.]+)/)[1];
}
} catch (e) {
return 0;
}
}
};
try {
//浏览器类型(IE、Opera、Chrome、Safari、Firefox)
System.type = System.isIE
? "IE"
: window.opera || agent.indexOf("opr") > 0
? "Opera"
: agent.indexOf("chrome") > 0
? "Chrome"
: //safari也提供了专门的判定方式
window.openDatabase
? "Safari"
: agent.indexOf("firefox") > 0
? "Firefox"
: "unknow";
//版本号
System.version = (System.type === "IE") ? System.ieVersion() :
(System.type === "Firefox") ? agent.match(/firefox\/([\d.]+)/)[1] :
(System.type === "Chrome") ? agent.match(/chrome\/([\d.]+)/)[1] :
(System.type === "Opera") ? System.operaVersion() :
(System.type === "Safari") ? agent.match(/version\/([\d.]+)/)[1] :
"0";
//浏览器外壳
System.shell = function () {
if (agent.indexOf("edge") > 0) {
System.version = agent.match(/edge\/([\d.]+)/)[1] || System.version;
return "edge浏览器";
}
//遨游浏览器
if (agent.indexOf("maxthon") > 0) {
System.version = agent.match(/maxthon\/([\d.]+)/)[1] || System.version;
return "傲游浏览器";
}
//QQ浏览器
if (agent.indexOf("qqbrowser") > 0) {
System.version = agent.match(/qqbrowser\/([\d.]+)/)[1] || System.version;
return "QQ浏览器";
}
//搜狗浏览器
if (agent.indexOf("se 2.x") > 0) {
return '搜狗浏览器';
}
//Chrome:也可以使用window.chrome && window.chrome.webstore判断
if (chrome && System.type !== "Opera") {
var external = window.external,
clientInfo = window.clientInformation,
//客户端语言:zh-cn,zh.360下面会返回undefined
clientLanguage = clientInfo.languages;
//猎豹浏览器:或者agent.indexOf("lbbrowser")>0
if (external && 'LiebaoGetVersion' in external) {
return '猎豹浏览器';
}
//百度浏览器
if (agent.indexOf("bidubrowser") > 0) {
System.version = agent.match(/bidubrowser\/([\d.]+)/)[1] ||
agent.match(/chrome\/([\d.]+)/)[1];
return "百度浏览器";
}
//360极速浏览器和360安全浏览器
if (System.supportSubTitle() && typeof clientLanguage === "undefined") {
//object.key()返回一个数组.包含可枚举属性和方法名称
var storeKeyLen = Object.keys(chrome.webstore).length,
v8Locale = "v8Locale" in window;
return storeKeyLen > 1 ? '360极速浏览器' : '360安全浏览器';
}
return "Chrome";
}
return System.type;
};
//浏览器名称(如果是壳浏览器,则返回壳名称)
System.name = System.shell();
//对版本号进行过滤过处理
// System.version = System.versionFilter(System.version);
} catch (e) {
// console.log(e.message);
}
return {
client: System
};
})(window);
if (Browser.client.name == undefined || Browser.client.name == "") {
Browser.client.name = "Unknown";
Browser.client.version = "Unknown";
} else if (Browser.client.version == undefined) {
Browser.client.version = "Unknown";
}
// document.write(Browser.client.name + " " + Browser.client.version);
return Browser;
}
function GetCommonPms () {
const v = "1.0.1";
const did = getCanvas();
const dh = getOsInfo().version;
const BrowerInfo = getBrowerInfo();
const db = BrowerInfo.client.name;
const dv = BrowerInfo.client.version;
const t = new Date().getTime();
const pms = `v=${v}&&did=${did}&&dh=${dh}&&db=${db}&&dv=${dv}&&dm=&&lat=&&lng=&&t=${t}`;
return pms;
}
export {
GetCommonPms
};
/* eslint-disable */
import qs from "qs";
import Oidc from "oidc-client";
// import "babel-polyfill";
const oidc_config = JSON.parse(process.env.VUE_APP_OIDC_CONFIG)
var mgr: Oidc.UserManager;
mgr = new Oidc.UserManager({
userStore: new Oidc.WebStorageStateStore({}),
authority: oidc_config.authority,
client_id: oidc_config.client_id,
redirect_uri: oidc_config.redirect_uri,
response_type: oidc_config.response_type,
scope: oidc_config.scope,
post_logout_redirect_uri: oidc_config.post_logout_redirect_uri,
silent_redirect_uri: oidc_config.silent_redirect_uri,
accessTokenExpiringNotificationTime: oidc_config.accessTokenExpiringNotificationTime,
automaticSilentRenew: oidc_config.filterProtocolClaims,
filterProtocolClaims: oidc_config.loadUserInfo,
loadUserInfo: oidc_config.loadUserInfo
});
Oidc.Log.logger = console;
Oidc.Log.level = Oidc.Log.INFO;
mgr!.events.addUserLoaded(function (user: any) {
console.log("初始化");
});
mgr!.events.addAccessTokenExpiring(function () {
console.log("过期前");
console.log("AccessToken Expiring:", arguments);
});
mgr!.events.addAccessTokenExpired(function () {
console.log("AccessToken Expired:", arguments);
mgr
.signoutRedirect()
.then(function (resp: any) {
console.log("signed out", resp);
})
.catch(function (err: any) {
console.log(err);
});
});
mgr!.events.addSilentRenewError(function () {
console.error("Silent Renew Error:", arguments);
});
mgr!.events.addUserSignedOut(function () {
console.log("UserSignedOut:", arguments);
mgr
.signoutRedirect()
.then(function (resp: any) {
window.location.href = "/";
})
.catch(function (err: any) {
console.log(err);
});
});
export default class SecurityService {
signinRedirectCallback() {
mgr
.signinRedirectCallback()
.then(function (user: any) {
// console.log("=============================");
// console.log(user);
})
.catch(function (err: any) {
// console.log(err);
});
}
signinSilentCallback() {
mgr.signinSilentCallback().catch(function (err: any) {
// console.log(err);
});
}
// Renew the token manually
renewToken(): Promise<Oidc.User | null> {
let self = this;
console.log("执行");
return new Promise((resolve, reject) => {
mgr
.signinSilent()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
} else {
return resolve(user);
}
})
.catch(function (err: any) {
alert(err);
console.log(err);
return reject(err);
});
});
}
// Get the user who is logged in
getUser(): Promise<Oidc.User | undefined> {
let self = this;
return new Promise<Oidc.User | undefined>((resolve, reject) => {
mgr
.getUser()
.then(function (user) {
if (user == null) {
// self.signIn();
return resolve(undefined);
} else {
if (!!user.expired) {
return resolve(undefined);
}
return resolve(user);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Check if there is any user logged in
getSignedIn(): Promise<boolean> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: any) {
let authcode = qs.parse(window.location.search).authcode;
if (authcode) {
mgr
.signinRedirect({
extraQueryParams: { authcode }
})
.catch(error => {
console.error(error);
});
return resolve(false);
} else if (user == null) {
self.signIn();
return resolve(false);
} else {
return resolve(true);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Redirect of the current window to the authorization endpoint.
signIn(args = {}) {
mgr.signinRedirect(args).catch(function (err: any) {
console.log(err);
});
}
signInto(args: any = null) {
mgr.signinRedirect(args).catch(function (err: any) {
console.log(err);
});
}
// Redirect of the current window to the end session endpoint
signOut() {
mgr
.signoutRedirect()
.then(function (resp: any) {
console.log("signed out", resp);
})
.catch(function (err: any) {
console.log(err);
});
}
// Get the profile of the user logged in
getProfile(): Promise<Oidc.Profile | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.profile);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Get the token id
getIdToken(): Promise<string | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.id_token);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Get the session state
getSessionState(): Promise<any | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.session_state);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Get the access token of the logged in user
getAcessToken(): Promise<string | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.access_token);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Takes the scopes of the logged in user
getScope(): Promise<string | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.scope);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
// Get the user roles logged in
getRole(): Promise<any | null> {
let self = this;
return new Promise((resolve, reject) => {
mgr
.getUser()
.then(function (user: Oidc.User | null) {
if (user == null) {
self.signIn();
return resolve(null);
} else {
return resolve(user.profile.role);
}
})
.catch(function (err: any) {
console.log(err);
return reject(err);
});
});
}
}
//import "babel-polyfill";
import Oidc from "oidc-client";
var mgr = new Oidc.UserManager({
userStore: new Oidc.WebStorageStateStore({}),
loadUserInfo: true,
filterProtocolClaims: true
});
mgr.signinRedirectCallback().then(function (user: any) {
let returnUrl = localStorage.getItem("returnUrl");
if (returnUrl) {
window.location.href = returnUrl;
} else {
window.location.href = "/";
}
}).catch(function (err: any) {
console.log(err);
});
// import "babel-polyfill";
import Oidc from 'oidc-client';
var mgr = new Oidc.UserManager({
userStore: new Oidc.WebStorageStateStore({}),
loadUserInfo: true,
filterProtocolClaims: true
});
mgr.signinSilentCallback();
import Vue from 'vue'; import Vue from 'vue';
import App from './App.vue'; import App from './App.vue';
import router from './router' import router from './router';
import store from './store' import store from './store';
import 'amfe-flexible/index.js' import 'amfe-flexible/index.js';
import server from '@/services/install' import server from '@/services/install';
// import FastClick from 'fastclick' // import FastClick from 'fastclick'
import '@/assets/css/index.less' import '@/assets/css/index.less';
import * as filters from "@/utils/filters"; import * as filters from '@/utils/filters';
Vue.config.productionTip = false; Vue.config.productionTip = false;
// FastClick.attach(document.body); // FastClick.attach(document.body);
...@@ -15,8 +14,15 @@ Object.keys(filters).forEach((key: string) => { ...@@ -15,8 +14,15 @@ Object.keys(filters).forEach((key: string) => {
Vue.filter(key, (filters as any)[key]); Vue.filter(key, (filters as any)[key]);
}); });
Vue.use(server) Vue.use(server);
if (
process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'staging'
) {
const VConsole = require('vconsole');
const my_console = new VConsole();
}
new Vue({ new Vue({
router, router,
......
import Vue from 'vue'; import Vue from 'vue';
import Router from 'vue-router'; import Router from 'vue-router';
import Mgr from '@/common/SecurityService'; // import Mgr from '@/common/SecurityService';
import employee_router from './employee/employee-router'; import employee_router from './employee/employee-router';
import qs from 'qs';
import axios from 'axios';
//@ts-ignore
import { GetCommonPms } from '../assets/js/CommonPms.js';
Vue.use(Router); Vue.use(Router);
let mgr = new Mgr(); // let mgr = new Mgr();
const oidc_config = JSON.parse(process.env.VUE_APP_OIDC_CONFIG);
const isOpenHttps = process.env.VUE_APP_OPEN_HTTPS; const isOpenHttps = process.env.VUE_APP_OPEN_HTTPS;
/** /**
* 加载和设置路由 * 加载和设置路由
*/ */
const router = new Router({ const router = new Router({
mode: 'history', mode: 'history',
base: process.env.BASE_URL,//'/', base: process.env.BASE_URL, //'/',
routes: [ routes: [...employee_router],
...employee_router
]
}); });
/** /**
* 使用授权码登录 * 使用授权码登录
* @param authCode 授权码 * @param authCode 授权码
*/ */
function loginByAuthcode(authCode: any) { // function loginByAuthcode(authCode: any) {
let loginArgs = { extraQueryParams: { authcode: authCode } }; // let loginArgs = { extraQueryParams: { authcode: authCode } };
mgr.signIn(loginArgs); // mgr.signIn(loginArgs);
} // }
/** /**
* 自动登录 * 自动登录
* @param authcode 授权码 * @param authcode 授权码
*/ */
function autoLogin(authcode: any) { // function autoLogin(authcode: any) {
mgr.getUser().then(user => { // mgr.getUser().then((user) => {
if (user == null) { // if (user == null) {
loginByAuthcode(authcode); // loginByAuthcode(authcode);
} else { // } else {
//如果已经登录,则先退出 // //如果已经登录,则先退出
localStorage.setItem("authcode", authcode); // localStorage.setItem('authcode', authcode);
mgr.signOut(); // mgr.signOut();
} // }
}) // });
// }
//@ts-ignore
function getAccessToken(authcode) {
console.log('authcode=', authcode);
return new Promise((resolve, reject) => {
let commonPms = GetCommonPms();
//@ts-ignore
let url = `${oidc_config.authority}/connect/token?${commonPms}`;
let pms = {
//@ts-ignore
client_id: oidc_config.client_id,
//@ts-ignore
client_secret: oidc_config.client_secret,
grant_type: 'auth_code',
scope:
'openid workapps.client api.workapps.user api.workapps.org api.workapps.open',
code: authcode,
};
axios.post(url, qs.stringify(pms)).then((res) => {
if (res && res.status) {
const accessToken = res.data.access_token;
resolve(accessToken);
} else {
reject(res);
}
});
});
}
//@ts-ignore
function getPathByTo(to, authcode_key) {
let toPath = to.path || '/';
for (let key in to.query) {
key = key.toLowerCase();
console.log('key=', key);
if (key == authcode_key) {
continue;
}
toPath += toPath.indexOf('?') > -1 ? '&' : '?';
toPath += `${key}=${to.query[key]}`;
}
toPath =
toPath.indexOf('?') > -1
? toPath + '&t=' + new Date().valueOf()
: toPath + '?t=' + new Date().valueOf();
return toPath;
} }
router.beforeEach((to, from, next) => {
if (isOpenHttps === 'true' && location.href.startsWith('http://')) {
location.href = location.href.replace('http://', 'https://');
}
const requiresAuth = to.matched.some((record) => record.meta.requiresAuth);
//更改标题
if (to.meta.title) {
document.title = to.meta.title;
}
const authcode = to.query.authCode || to.query.authcode;
if (!!authcode) {
getAccessToken(authcode)
.then((res) => {
const redirectPath = getPathByTo(to, 'authcode');
//@ts-ignore
const accessToken: string = res;
localStorage.setItem('token', accessToken);
window.location.href = redirectPath;
})
.catch((err) => {
console.log('err=', err);
});
} else {
console.log('to.path=', to.path);
next();
}
});
/** /**
* 请求路由前 一些操作 * 请求路由前 一些操作
*/ */
router.beforeEach((to, from, next) => { // router.beforeEach((to, from, next) => {
// console.log(isOpenHttps); // // console.log(isOpenHttps);
if (isOpenHttps === "true" && location.href.startsWith("http://")) { // if (isOpenHttps === "true" && location.href.startsWith("http://")) {
location.href = location.href.replace("http://", "https://"); // location.href = location.href.replace("http://", "https://");
} // }
const requiresAuth = to.matched.some(record => record.meta.requiresAuth); // const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
localStorage.setItem("returnUrl", to.path); // localStorage.setItem("returnUrl", to.path);
//更改标题 // //更改标题
if (to.meta.title) { // if (to.meta.title) {
document.title = to.meta.title; // document.title = to.meta.title;
} // }
let authcode = localStorage.getItem("authcode") // let authcode = localStorage.getItem("authcode")
if (authcode) { // if (authcode) {
localStorage.removeItem("authcode"); // localStorage.removeItem("authcode");
loginByAuthcode(authcode) // loginByAuthcode(authcode)
} else { // } else {
let authcode = to.query.authcode; // let authcode = to.query.authcode;
if (authcode) { // if (authcode) {
autoLogin(authcode); // autoLogin(authcode);
} else { // } else {
if (requiresAuth) { // if (requiresAuth) {
mgr.getUser().then(user => { // mgr.getUser().then(user => {
if (user == null) { // if (user == null) {
mgr.signIn(); // mgr.signIn();
} else { // } else {
next(); // next();
} // }
}); // });
} // }
else { // else {
next(); // next();
} // }
} // }
} // }
}); // });
export default router; export default router;
// import * as types from "../types"; // import * as types from "../types";
// import { isNullOrEmpty } from "@/utils/public"; // import { isNullOrEmpty } from "@/utils/public";
import Mgr from "@/common/SecurityService"; // import Mgr from '@/common/SecurityService';
// import request from '@/utils/method'; // import request from '@/utils/method';
// import urls from '@/utils/urls'; // import urls from '@/utils/urls';
let mgr = new Mgr(); // let mgr = new Mgr();
const initPageState = () => { const initPageState = () => {
return { return {
userInfo: {}, userInfo: {},
accessToken: "", accessToken: '',
anymouseAccessToken: "", anymouseAccessToken: '',
companyAccessToken: "" companyAccessToken: '',
} };
}; };
const user = { const user = {
state: initPageState(), state: initPageState(),
mutations: {}, mutations: {},
actions: {}, actions: {},
getters: { getters: {
async getUserInfo(state: Object | any) { // async getUserInfo(state: Object | any) {
if (Object.keys(state.userInfo).length > 0) { // if (Object.keys(state.userInfo).length > 0) {
return state.userInfo; // return state.userInfo;
} // }
let user = await mgr.getUser(); // let user = await mgr.getUser();
if (user) { // if (user) {
state.userInfo = user!.profile; // state.userInfo = user!.profile;
} // }
return state.userInfo; // return state.userInfo;
}, // },
async getAccessToken(state: Object | any) { async getAccessToken(state: Object | any) {
if (state.accessToken === "") { if (state.accessToken === '') {
let user = await mgr.getUser(); //let user = await mgr.getUser();
if (user) { // if (user) {
state.accessToken = user!.access_token; // state.accessToken = user!.access_token;
} // }
} state.accessToken = localStorage.getItem('token');
return state.accessToken; }
}, return state.accessToken;
async getAnymouseAccessToken(state: Object | any) { },
if (state.anymouseAccessToken === "") { async getAnymouseAccessToken(state: Object | any) {
let aToken = localStorage.getItem("aat"); if (state.anymouseAccessToken === '') {
if (!!(aToken)) { let aToken = localStorage.getItem('aat');
state.anymouseAccessToken = aToken; if (!!aToken) {
} else { state.anymouseAccessToken = aToken;
// let url = `${urls.tokenUrl}/connect/token`; } else {
// await request.post(url,) // let url = `${urls.tokenUrl}/connect/token`;
} // await request.post(url,)
}
return state.anymouseAccessToken;
} }
} }
return state.anymouseAccessToken;
},
},
}; };
export default user; export default user;
<template> <template>
<!-- 1、已接单 进行中 #077AEC 2、已拒回 #FF9100 3、已完成 #95989E--> <!-- 1、已接单 进行中 #077AEC 2、已拒回 #FF9100 3、已完成 #95989E-->
<div class="fe-bigbox"> <div class="fe-bigbox">
<div v-if="taskRecordList!=null"> <div v-if="showList == 1">
<div class="person-information"> <div class="person-information">
<div class="person-information-top"> <div class="person-information-top">
<div class="person-information-left"> <div class="person-information-left">
<h3>{{name}}</h3> <h3>{{ name }}</h3>
<p>{{birthday}}</p> <p>{{ birthday }}</p>
</div> </div>
</div> </div>
<div class="person-information-bottom"> <div class="person-information-bottom">
<div class="person-information-bottom-child" id="person-information-yjrw"> <div
<h3>{{accept_work | isEmpty}}</h3> class="person-information-bottom-child"
id="person-information-yjrw"
>
<h3>{{ accept_work }}</h3>
<p>已接任务</p> <p>已接任务</p>
</div> </div>
<div class="person-information-bottom-child" id="person-information-wcrw"> <div
<h3>{{perform_work | isEmpty}}</h3> class="person-information-bottom-child"
id="person-information-wcrw"
>
<h3>{{ perform_work }}</h3>
<p>完成任务</p> <p>完成任务</p>
</div> </div>
<div class="person-information-bottom-child" id="person-information-ysbc"> <div
<h3>{{Payment_receivable | money(true,false) | isEmpty}}</h3> class="person-information-bottom-child"
id="person-information-ysbc"
>
<h3>{{ Payment_receivable }}</h3>
<p>应收报酬</p> <p>应收报酬</p>
</div> </div>
<div class="person-information-bottom-child" id="person-information-yysbc"> <div
<h3>{{receive_receivable | isEmpty}}</h3> class="person-information-bottom-child"
id="person-information-yysbc"
>
<h3>{{ receive_receivable }}</h3>
<p>已收报酬</p> <p>已收报酬</p>
</div> </div>
</div> </div>
...@@ -42,13 +53,21 @@ ...@@ -42,13 +53,21 @@
@click="toDetail(item.id)" @click="toDetail(item.id)"
> >
<div class="fe-list-child-left"> <div class="fe-list-child-left">
<h3>{{item.description}}</h3> <h3>
<p>{{item.createTime |format}}</p> {{
item.title.length > 20
? item.title.substring(0, 19) + "..."
: item.title
}}
</h3>
<p>{{ item.createTime | format }}</p>
</div> </div>
<div class="fe-list-child-right"> <div class="fe-list-child-right">
<div class="fe-list-child-right-desc"> <div class="fe-list-child-right-desc">
<h3>{{item.paidSalary | money(true,true)}}</h3> <h3>{{ Number(item.paidSalary / 100).toFixed(2) }}</h3>
<p :style="matchColor(item.billStatus)">{{item.billStatus}}</p> <p :style="matchColor(item.billStatus)">
{{ item.billStatus }}
</p>
</div> </div>
<img src="../assets/images/agent/next_gray.png" alt /> <img src="../assets/images/agent/next_gray.png" alt />
</div> </div>
...@@ -56,7 +75,7 @@ ...@@ -56,7 +75,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="empty_data" v-else> <div class="empty_data" v-if="showList == 0">
<p> <p>
您在亲亲小保未从事灵活用工的相关任务 您在亲亲小保未从事灵活用工的相关任务
<br />暂无相关记录 <br />暂无相关记录
...@@ -80,15 +99,16 @@ import { Component, Vue } from "vue-property-decorator"; ...@@ -80,15 +99,16 @@ import { Component, Vue } from "vue-property-decorator";
// } // }
}) })
export default class FlexEmployee extends Vue { export default class FlexEmployee extends Vue {
private name: string = "迪丽热巴";//入参 private name: string = ""; //入参
private birthday: string = "1987-10-16";//入参 private birthday: string = ""; //
private accept_work: string = ""; private accept_work: string = "0";
private perform_work: string = ""; private perform_work: string = "0";
private Payment_receivable: string = ""; private Payment_receivable: string = "0.00";
private receive_receivable: string = ""; private receive_receivable: string = "0.00";
private fullName: string = ""; private fullName: string = "";
private taskRecordList: any = []; private taskRecordList: any = null;
private showList: number = -1;
private toDetail(id: any): void { private toDetail(id: any): void {
this.$router.push({ name: "FlexEmployeeDetial", query: { id } }); this.$router.push({ name: "FlexEmployeeDetial", query: { id } });
...@@ -109,17 +129,25 @@ export default class FlexEmployee extends Vue { ...@@ -109,17 +129,25 @@ export default class FlexEmployee extends Vue {
} }
mounted() { mounted() {
this.name = localStorage.getItem("name") as string;
this.birthday = localStorage.getItem("birthday") as string;
const idNo = window.atob(decodeURI(String(this.$route.query.id_no)));
console.log("idNo=", idNo);
let params = { let params = {
idNo: this.$route.query.id_no //371327198511175134 idNo: idNo //371327198511175134
}; };
this.$server.EmployeeService.getAgileWorker(params).then((res: any) => { this.$server.EmployeeService.getAgileWorker(params).then((res: any) => {
console.log(res); console.log("res=", res);
this.accept_work = res.alCount; // 已接任务 this.accept_work = res.alCount; // 已接任务
this.perform_work = res.comCount; // 完成任务 this.perform_work = res.comCount; // 完成任务
this.Payment_receivable = res.receivableSalary; // 应收报酬 this.Payment_receivable = res.receivableSalary.toFixed(2); // 应收报酬
this.receive_receivable = res.receivedSalary; // 已收报酬 this.receive_receivable = res.receivedSalary.toFixed(2); // 已收报酬
this.taskRecordList = res.taskList; // 任务记录 this.taskRecordList = res.taskList; // 任务记录
this.taskRecordList.length > 0
? (this.showList = 1)
: (this.showList = 0);
console.log("taskRecordList=", this.taskRecordList);
localStorage.setItem("taskList", JSON.stringify(res.taskList)); localStorage.setItem("taskList", JSON.stringify(res.taskList));
}); });
} }
......
...@@ -2,21 +2,29 @@ ...@@ -2,21 +2,29 @@
<div class="fe-detial-box"> <div class="fe-detial-box">
<div class="fe-detial-top"> <div class="fe-detial-top">
<h4>任务报酬</h4> <h4>任务报酬</h4>
<h3>+{{item.paidSalary | money}}</h3> <h3>+{{ (item.paidSalary / 100).toFixed(2) }}</h3>
<p :style="matchColor(item.status)">{{item.status}}</p> <p :style="matchColor(item.status)">{{ item.status }}</p>
</div> </div>
<div class="fe-detial-bottom"> <div class="fe-detial-bottom">
<div class="fe-detial-bottom-title"> <div class="fe-detial-bottom-title">
<p>发包企业</p> <p>发包企业</p>
<p>任务内容</p> <p>任务名称</p>
<p>服务类别</p>
<p>发放时间</p> <p>发放时间</p>
<p>收款账户</p> <p>收款账户</p>
</div> </div>
<div class="fe-detial-bottom-detial"> <div class="fe-detial-bottom-detial">
<p>{{item.fullName}}</p> <p>{{ item.fullName }}</p>
<p>{{item.description}}</p> <p>
<p>{{item.payTime}}</p> {{
<p>{{item.banko}}</p> item.title.length > 24
? item.title.substring(0, 22) + "..."
: item.title
}}
</p>
<p>{{ item.description }}</p>
<p>{{ item.payTime }}</p>
<p>{{ item.banko }}</p>
</div> </div>
</div> </div>
</div> </div>
...@@ -32,7 +40,6 @@ import { toMoney } from "@/utils/public"; ...@@ -32,7 +40,6 @@ import { toMoney } from "@/utils/public";
} }
}) })
export default class FlexEmployee extends Vue { export default class FlexEmployee extends Vue {
private item: any; private item: any;
get matchColor() { get matchColor() {
...@@ -56,6 +63,8 @@ export default class FlexEmployee extends Vue { ...@@ -56,6 +63,8 @@ export default class FlexEmployee extends Vue {
let task_info = localStorage.getItem("taskList"); let task_info = localStorage.getItem("taskList");
if (task_info != null) { if (task_info != null) {
let tasks = JSON.parse(task_info); let tasks = JSON.parse(task_info);
console.log(tasks.find((x: any) => x.id == id));
this.item = tasks.find((x: any) => x.id == id); this.item = tasks.find((x: any) => x.id == id);
} }
} }
......
...@@ -7,7 +7,12 @@ ...@@ -7,7 +7,12 @@
<p>可查看专项订单服务,使用职场小工具</p> <p>可查看专项订单服务,使用职场小工具</p>
</div> </div>
</a>--> </a>-->
<a v-if="company_num>0" class="si-child" id="dispatch-employee" @click="toIndex_click"> <a
v-if="company_num > 0"
class="si-child"
id="dispatch-employee"
@click="toIndex_click"
>
<img src="../assets/images/agent/dispatch-employee.png" alt /> <img src="../assets/images/agent/dispatch-employee.png" alt />
<div class="si-child-desc"> <div class="si-child-desc">
<h4>我是派遣员工</h4> <h4>我是派遣员工</h4>
...@@ -79,13 +84,16 @@ export default class SelectIdentity extends Vue { ...@@ -79,13 +84,16 @@ export default class SelectIdentity extends Vue {
.then(res => { .then(res => {
if (res.data && res.data.uthStatus && res.data.uthStatus > 0) { if (res.data && res.data.uthStatus && res.data.uthStatus > 0) {
this.id_no = res.data.personalIdCardNo; this.id_no = res.data.personalIdCardNo;
localStorage.setItem("id_no", res.data.personalIdCardNo);
localStorage.setItem("name", res.data.personalName);
localStorage.setItem("birthday", res.data.birthday);
} else { } else {
//TODO: 跳转到实名认证 //TODO: 跳转到实名认证
console.log("跳转到实名认证", res); console.log("跳转到实名认证", res);
} }
}) })
.catch(err => { .catch(err => {
console.log("err=", err); console.log("err=");
}); });
} }
......
...@@ -16,20 +16,20 @@ module.exports = { ...@@ -16,20 +16,20 @@ module.exports = {
chunks: ['app', 'chunk-vendors'], chunks: ['app', 'chunk-vendors'],
excludeChunks: ['silent-renew-oidc'] excludeChunks: ['silent-renew-oidc']
}, },
silentrenewoidc: { // silentrenewoidc: {
entry: './src/common/silent-renew.ts', // entry: './src/common/silent-renew.ts',
template: 'public/silent-renew.html', // template: 'public/silent-renew.html',
filename: 'silent-renew.html', // filename: 'silent-renew.html',
favicon: 'public/favicon.ico', // favicon: 'public/favicon.ico',
excludeChunks: ['app'] // excludeChunks: ['app']
}, // },
callback: { // callback: {
entry: './src/common/callback.ts', // entry: './src/common/callback.ts',
template: 'public/callback.html', // template: 'public/callback.html',
filename: 'callback.html', // filename: 'callback.html',
favicon: 'public/favicon.ico', // favicon: 'public/favicon.ico',
excludeChunks: ['app'] // excludeChunks: ['app']
}, // },
}, },
// eslint-loader 是否在保存的时候检查 // eslint-loader 是否在保存的时候检查
lintOnSave: true, lintOnSave: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment