适配2.0端登录 请求修改 增加token
parent
9a3b24c0f4
commit
df92b3e4e8
|
@ -1,6 +1,7 @@
|
|||
import {post, upload, uploads,videoApiGet} from "../utils/request";
|
||||
|
||||
export const submitLogin = (params) => post("/admin/check", params) // 登录
|
||||
export const submitLogin = (params) => post("/sys/login", params) // 登录
|
||||
export const getUserInfo = (params) => post("/sys/user/info", params); // 获取用户信息
|
||||
export const getHotWorkListByState = (params) => post("/app/hotworkapplication/list", params)//获取动火列表
|
||||
export const getHotWorkGoEdit = (params) => post("/app/hotworkapplication/goEdit", params) //获取动火详情
|
||||
export const getImgfilesListByKeyAndType = (params) => post("/app/imgfiles/listImgs", params) //获取附件表的信息
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import {submitLogin} from '../../api/index'
|
||||
import {getUserInfo, submitLogin} from '../../api/index'
|
||||
import updateVersion from '../../utils/updateVersion'
|
||||
import JSEncrypt from '../../static/js/jsencrypt.min.js'
|
||||
import { encrypt } from "@/utils/aes_secret"
|
||||
|
||||
export default {
|
||||
mixins:[updateVersion],
|
||||
|
@ -91,10 +91,28 @@ export default {
|
|||
});
|
||||
return;
|
||||
}
|
||||
var jsencrypt = new JSEncrypt()
|
||||
jsencrypt.setPublicKey(this.publicKey)
|
||||
const keydataVal = jsencrypt.encrypt('qdkjchina' + this.form.userName + ',qd,' + this.form.userPwd)
|
||||
let resData = await submitLogin({'KEYDATA':keydataVal});
|
||||
|
||||
const { token } = await submitLogin({
|
||||
username: encrypt(this.form.userName),
|
||||
password: encrypt(this.form.userPwd)
|
||||
});
|
||||
uni.setStorageSync('token', token);
|
||||
const { user } = await getUserInfo();
|
||||
const resData = {
|
||||
DEPARTMENT_NAME: user.departmentName,
|
||||
JOB: user.job,
|
||||
JOB_LEVEL: user.jobLevel,
|
||||
BASICINFO_ID: user.basicinfoId,
|
||||
DEPARTMENT_ID: user.departmentId,
|
||||
CORPINFO_ID: user.corpinfoId,
|
||||
NAME: user.name,
|
||||
PRECINCT_ID: user.precinctId,
|
||||
ROLEID: user.roleId,
|
||||
ROLE_NAME: user.roleName,
|
||||
USERBZ: user.bz,
|
||||
USERNAME: user.username,
|
||||
USER_ID: user.userId,
|
||||
};
|
||||
await this.$store.dispatch('setUserInfo', resData);
|
||||
await this.$store.dispatch('setfilePath', '');
|
||||
uni.$u.route({
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import CryptoJS from "crypto-js";
|
||||
|
||||
const key = CryptoJS.enc.Utf8.parse("daac3ae52eff4cec"); // 16位
|
||||
|
||||
const encrypt = (word) => {
|
||||
let encrypted = "";
|
||||
if (typeof word === "string") {
|
||||
const src = CryptoJS.enc.Utf8.parse(word);
|
||||
encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
} else if (typeof word === "object") {
|
||||
// 对象格式的转成json字符串
|
||||
const data = JSON.stringify(word);
|
||||
const src = CryptoJS.enc.Utf8.parse(data);
|
||||
encrypted = CryptoJS.AES.encrypt(src, key, {
|
||||
mode: CryptoJS.mode.ECB,
|
||||
padding: CryptoJS.pad.Pkcs7,
|
||||
});
|
||||
}
|
||||
return encrypted.ciphertext.toString(CryptoJS.enc.Base64);
|
||||
};
|
||||
|
||||
export { encrypt };
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
// export var requestPath = 'https://skqhdg.porthebei.com:9005/qa-regulatory-gwj/'; // 后台请求地址
|
||||
export var requestPath = 'http://192.168.0.100:8092/';
|
||||
export var requestPath = 'http://127.0.0.1:8092/';
|
||||
|
||||
let videoApiPath = 'https://arqsp.qhdsafety.com:10010'; // 视频平台后台请求地址
|
||||
import store from '../store/index'
|
||||
|
@ -20,7 +20,8 @@ function post(url, data) {
|
|||
},
|
||||
method: 'POST',
|
||||
header: {
|
||||
'Content-type': data?.postMethod || 'application/x-www-form-urlencoded'
|
||||
'Content-type': data?.postMethod || 'application/json',
|
||||
'token': uni.getStorageSync('token') || ''
|
||||
},
|
||||
success: (res) => {
|
||||
if (data && data.loading !== false) {
|
||||
|
|
Loading…
Reference in New Issue