Browse Source

loginWork登陆密码加密

preview
jianjun 5 years ago
parent
commit
a160daed21
  1. 1
      epmet-oper-web/package.json
  2. 98
      epmet-oper-web/src/views/pages/loginWork.vue

1
epmet-oper-web/package.json

@ -25,6 +25,7 @@
"gulp-rename": "^1.4.0", "gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2", "gulp-sass": "^4.0.2",
"js-cookie": "^2.2.0", "js-cookie": "^2.2.0",
"jsencrypt": "^3.0.3",
"lodash": "^4.17.15", "lodash": "^4.17.15",
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"portfinder": "^1.0.21", "portfinder": "^1.0.21",

98
epmet-oper-web/src/views/pages/loginWork.vue

@ -142,11 +142,13 @@ import debounce from 'lodash/debounce'
import { messages } from '@/i18n' import { messages } from '@/i18n'
import { getUUID } from '@/utils' import { getUUID } from '@/utils'
import { Loading } from 'element-ui' // Loading import { Loading } from 'element-ui' // Loading
import JSEncrypt from 'jsencrypt'//
let loading // let loading //
export default { export default {
data () { data () {
return { return {
pubKey: null, //
isShowLogin: true, isShowLogin: true,
i18nMessages: messages, i18nMessages: messages,
captchaPath: '', captchaPath: '',
@ -191,18 +193,31 @@ export default {
this.getAutoLogin(this.$route.query.platformToken) this.getAutoLogin(this.$route.query.platformToken)
}else{ }else{
this.getCaptcha() this.getCaptcha()
localStorage.remove('showHeader') //
this.getPubKey()
} }
}, },
methods: { methods: {
//
getPubKey() {
this.$http.post('/auth/govweb/getKey').then(({data: res}) => {
if (res.code !== 0) {
return this.$message.error(res.msg)
}
this.pubKey = res.data; // ;
console.log("pubkey", this.pubKey);
}).catch(() => {
})
},
// //
getCaptcha () { getCaptcha () {
this.dataForm.uuid = getUUID() this.dataForm.uuid = getUUID()
this.captchaPath = `${window.SITE_CONFIG['apiURL']}/auth/login/captcha?uuid=${this.dataForm.uuid}` this.captchaPath = `${window.SITE_CONFIG['apiURL']}/auth/login/captcha?uuid=${this.dataForm.uuid}`
}, },
// //
dataFormSubmitHandle () { dataFormSubmitHandle() {
this.$refs['dataForm'].validate((valid, messageObj) => { this.$refs['dataForm'].validate((valid, messageObj) => {
if (!valid) { if (!valid) {
app.util.validateRule(messageObj) app.util.validateRule(messageObj)
@ -214,38 +229,37 @@ export default {
phone: this.dataForm.phone phone: this.dataForm.phone
} }
window.app.ajax.post( window.app.ajax.post(
url, params, url, params,
(data, rspMsg) => { (data, rspMsg) => {
if (data.length === 0) {//
this.$message.error('账号不存在')
this.endLoading()
} else if (data.length === 1) {
this.selectCustomer(data[0])
} else {
this.endLoading()
this.diaVisible = true
this.$nextTick(() => {
this.tableData = data
})
}
},
(rspMsg, data) => {
this.endLoading()
this.$message.error(rspMsg)
})
if (data.length === 0) {//
this.$message.error('账号不存在')
this.endLoading()
} else if (data.length === 1) {
this.selectCustomer(data[0])
} else {
this.endLoading()
this.diaVisible = true
this.$nextTick(() => {
this.tableData = data
})
}
},
(rspMsg, data) => {
this.endLoading()
this.$message.error(rspMsg)
})
}) })
}, },
// //
getAutoLogin (platformToken) { getAutoLogin(platformToken) {
this.dataForm.thirdToken = platformToken; this.dataForm.thirdToken = platformToken;
this.dataForm.platform = "pyld"; this.dataForm.platform = "pyld";
this.$http.post(`/auth/sso/oper/third/login`,this.dataForm).then(({ data: res }) => { this.$http.post(`/auth/sso/oper/third/login`, this.dataForm).then(({data: res}) => {
if (res.code !== 0) { if (res.code !== 0) {
if(res.code == 8302){ if (res.code == 8302) {
return this.$message.error(res.internalMsg) return this.$message.error(res.internalMsg)
} }
return this.$message.error(res.msg) return this.$message.error(res.msg)
@ -254,12 +268,13 @@ export default {
localStorage.setItem('userType', 'work') localStorage.setItem('userType', 'work')
localStorage.setItem('showHeader', '0') localStorage.setItem('showHeader', '0')
Cookies.set('token', res.data.token) Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' }) this.$router.replace({name: 'home'})
}).catch(() => { }) }).catch(() => {
})
// epmet-ext9.elinkservice.cn/platform-admin // epmet-ext9.elinkservice.cn/platform-admin
}, },
// //
selectCustomer (row) { selectCustomer(row) {
localStorage.setItem('customerId', row.customerId) localStorage.setItem('customerId', row.customerId)
localStorage.setItem('customerName', row.customerName) localStorage.setItem('customerName', row.customerName)
this.startLoading() this.startLoading()
@ -267,7 +282,10 @@ export default {
const url = '/auth/govweb/login' const url = '/auth/govweb/login'
this.dataForm.customerId = row.customerId this.dataForm.customerId = row.customerId
this.$http.post(url, this.dataForm).then(({ data: res }) => { console.log('password pre', this.dataForm.password);
this.dataForm.password = this.encryptedData(this.pubKey, this.dataForm.password);
console.log('password after', this.dataForm.password);
this.$http.post(url, this.dataForm).then(({data: res}) => {
if (res.code !== 0) { if (res.code !== 0) {
this.getCaptcha() this.getCaptcha()
return this.$message.error(res.msg) return this.$message.error(res.msg)
@ -277,18 +295,19 @@ export default {
localStorage.setItem('userType', 'work') localStorage.setItem('userType', 'work')
Cookies.set('token', res.data.token) Cookies.set('token', res.data.token)
this.$router.replace({ name: 'home' }) this.$router.replace({name: 'home'})
}).catch(() => { }) }).catch(() => {
})
this.endLoading() this.endLoading()
}, },
// //
diaCancel () { diaCancel() {
this.diaVisible = false this.diaVisible = false
}, },
// //
startLoading () { startLoading() {
loading = Loading.service({ loading = Loading.service({
lock: true, // lock: true, //
text: '正在加载……', // text: '正在加载……', //
@ -296,13 +315,22 @@ export default {
}) })
}, },
// //
endLoading () { endLoading() {
// clearTimeout(timer); // clearTimeout(timer);
if (loading) { if (loading) {
loading.close() loading.close()
} }
},
//
encryptedData(key, data) {
debugger
// JSEncrypt
let encryptor = new JSEncrypt();
//
encryptor.setPublicKey(key);
//
return encryptor.encrypt(data);
} }
} }
} }

Loading…
Cancel
Save