flat: 暂存
This commit is contained in:
120
App.vue
120
App.vue
@@ -3,37 +3,29 @@ import { reactive, inject, onMounted } from 'vue';
|
|||||||
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
|
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
|
||||||
import useUserStore from './stores/useUserStore';
|
import useUserStore from './stores/useUserStore';
|
||||||
import useDictStore from './stores/useDictStore';
|
import useDictStore from './stores/useDictStore';
|
||||||
const { $api, navTo, appendScriptTagElement } = inject('globalFunction');
|
const { $api, navTo, appendScriptTagElement, aes_Decrypt, sm2_Decrypt } = inject('globalFunction');
|
||||||
import config from '@/config.js';
|
import config from '@/config.js';
|
||||||
|
|
||||||
|
const appword = 'aKd20dbGdFvmuwrt'; // 固定值
|
||||||
|
|
||||||
onLaunch((options) => {
|
onLaunch((options) => {
|
||||||
if (lightAppJssdk.user) {
|
getUserInfo();
|
||||||
lightAppJssdk.user.getTicket({
|
|
||||||
success: function (data) {
|
|
||||||
//成功回调
|
|
||||||
console.log(data);
|
|
||||||
},
|
|
||||||
fail: function (data) {
|
|
||||||
$api.msg('获取用户信息失败');
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
useUserStore().initSeesionId(); //更新
|
useUserStore().initSeesionId(); //更新
|
||||||
useDictStore().getDictData();
|
useDictStore().getDictData();
|
||||||
// uni.hideTabBar();
|
// uni.hideTabBar();
|
||||||
// 登录
|
// 登录
|
||||||
let token = uni.getStorageSync('token') || ''; // 同步获取 缓存信息
|
// let token = uni.getStorageSync('token') || ''; // 同步获取 缓存信息
|
||||||
if (token) {
|
// if (token) {
|
||||||
useUserStore()
|
// useUserStore()
|
||||||
.loginSetToken(token)
|
// .loginSetToken(token)
|
||||||
.then(() => {
|
// .then(() => {
|
||||||
$api.msg('登录成功');
|
// $api.msg('登录成功');
|
||||||
});
|
// });
|
||||||
} else {
|
// } else {
|
||||||
uni.redirectTo({
|
// uni.redirectTo({
|
||||||
url: '/pages/login/login',
|
// url: '/pages/login/login',
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
});
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
@@ -52,6 +44,86 @@ onShow(() => {
|
|||||||
onHide(() => {
|
onHide(() => {
|
||||||
console.log('App Hide');
|
console.log('App Hide');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getUserInfo() {
|
||||||
|
lightAppJssdk.user.getUserInfoWithEncryptedParamByAppId({
|
||||||
|
appId: 'qdsrgznrgpp', // 接入方在成功创建应用后自动生成
|
||||||
|
success: function (data) {
|
||||||
|
console.log('res', data);
|
||||||
|
if (data == '未登录') onLoginApp();
|
||||||
|
else {
|
||||||
|
if (typeof data == 'string') data = JSON.parse(data);
|
||||||
|
|
||||||
|
const sm2_privateKey = '7e14966df4ecd4241ed082ef716d82b52113cb5899ebdc704a98844d0a32b0dc';
|
||||||
|
let sm2_encrypt_result = data.data;
|
||||||
|
let sm2_decrypt_result = sm2_Decrypt(sm2_encrypt_result, sm2_privateKey);
|
||||||
|
|
||||||
|
if (typeof sm2_decrypt_result == 'string') sm2_decrypt_result = JSON.parse(sm2_decrypt_result);
|
||||||
|
|
||||||
|
// 其次,对sm2解密后的结果进行 aes解密
|
||||||
|
// aes解密需要用到 appword , 为固定值,使用示例代码中的即可
|
||||||
|
let aes_encrypt_result = sm2_decrypt_result.data;
|
||||||
|
let aes_decrypt_result = aes_Decrypt(aes_encrypt_result, appword);
|
||||||
|
|
||||||
|
// 加密
|
||||||
|
loginCallback(aes_decrypt_result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function (data) {
|
||||||
|
console.log('err', data);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 使用jssdk调用登录页面
|
||||||
|
*/
|
||||||
|
function onLoginApp() {
|
||||||
|
lightAppJssdk.user.loginapp({
|
||||||
|
success: function (data) {
|
||||||
|
if (data == '未登录') {
|
||||||
|
//取消登录或登录失败,关闭页面
|
||||||
|
oncloseWindow();
|
||||||
|
} else {
|
||||||
|
getUserInfo();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: function (data) {
|
||||||
|
//关闭页面
|
||||||
|
oncloseWindow();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关闭容器
|
||||||
|
*/
|
||||||
|
function oncloseWindow() {
|
||||||
|
lightAppJssdk.navigation.close({
|
||||||
|
success: function (data) {},
|
||||||
|
fail: function (data) {},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function loginCallback(userInfo) {
|
||||||
|
let pramams = {
|
||||||
|
token: userInfo,
|
||||||
|
};
|
||||||
|
$api.createRequest('/app/login', params, 'post').then((resData) => {
|
||||||
|
useUserStore()
|
||||||
|
.loginSetToken(resData.token)
|
||||||
|
.then((resume) => {
|
||||||
|
if (resume.data.jobTitleId) {
|
||||||
|
useUserStore().initSeesionId();
|
||||||
|
uni.reLaunch({
|
||||||
|
url: '/pages/index/index',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
nextStep();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -67,14 +67,14 @@ export const navTo = function(url, {
|
|||||||
onBack = null
|
onBack = null
|
||||||
} = {}) {
|
} = {}) {
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
if(isJumping) return
|
if (isJumping) return
|
||||||
isJumping=true
|
isJumping = true
|
||||||
if (needLogin && !userStore.hasLogin) {
|
if (needLogin && !userStore.hasLogin) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/login/login'
|
url: '/pages/login/login'
|
||||||
});
|
});
|
||||||
isJumping=false
|
isJumping = false
|
||||||
}, 170);
|
}, 170);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ export const navTo = function(url, {
|
|||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: finalUrl
|
url: finalUrl
|
||||||
});
|
});
|
||||||
isJumping=false
|
isJumping = false
|
||||||
}, 170);
|
}, 170);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -552,6 +552,25 @@ function isEmptyObject(obj) {
|
|||||||
return obj && typeof obj === 'object' && !Array.isArray(obj) && Object.keys(obj).length === 0;
|
return obj && typeof obj === 'object' && !Array.isArray(obj) && Object.keys(obj).length === 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function aes_Decrypt(word, key) {
|
||||||
|
var key = CryptoJS.enc.Utf8.parse(key) //转为128bit
|
||||||
|
var srcs = CryptoJS.enc.Hex.parse(word) //转为16进制
|
||||||
|
var str = CryptoJS.enc.Base64.stringify(srcs) //变为Base64编码的字符串
|
||||||
|
var decrypt = CryptoJS.AES.decrypt(str, key, {
|
||||||
|
mode: CryptoJS.mode.ECB,
|
||||||
|
spadding: CryptoJS.pad.Pkcs7
|
||||||
|
})
|
||||||
|
return decrypt.toString(CryptoJS.enc.Utf8)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function sm2_Decrypt(word, key) {
|
||||||
|
return SM.decrypt(word, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sm2_Encrypt(word, key) {
|
||||||
|
return SM.encrypt(word, key);
|
||||||
|
}
|
||||||
|
|
||||||
export const $api = {
|
export const $api = {
|
||||||
msg,
|
msg,
|
||||||
@@ -565,7 +584,8 @@ export const $api = {
|
|||||||
uploadFile,
|
uploadFile,
|
||||||
formatFileSize,
|
formatFileSize,
|
||||||
sendingMiniProgramMessage,
|
sendingMiniProgramMessage,
|
||||||
copyText
|
copyText,
|
||||||
|
aes_Decrypt,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -595,4 +615,7 @@ export default {
|
|||||||
insertSortData,
|
insertSortData,
|
||||||
isInWechatMiniProgramWebview,
|
isInWechatMiniProgramWebview,
|
||||||
isEmptyObject,
|
isEmptyObject,
|
||||||
|
aes_Decrypt,
|
||||||
|
sm2_Decrypt,
|
||||||
|
sm2_Encrypt
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
export default {
|
export default {
|
||||||
// baseUrl: 'http://39.98.44.136:8080', // 测试
|
// baseUrl: 'https://fw.rc.qingdao.gov.cn/rgpp-api', // 内网
|
||||||
baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
|
baseUrl: 'https://qd.zhaopinzao8dian.com/api', // 测试
|
||||||
|
// baseUrl: "http://192.168.98.110:18181",
|
||||||
// sseAI+
|
// sseAI+
|
||||||
// StreamBaseURl: 'http://39.98.44.136:8000',
|
// StreamBaseURl: 'http://39.98.44.136:8000',
|
||||||
StreamBaseURl: 'https://qd.zhaopinzao8dian.com/ai',
|
StreamBaseURl: 'https://qd.zhaopinzao8dian.com/ai',
|
||||||
@@ -16,6 +17,10 @@ export default {
|
|||||||
OnlyUseCachedDB: false,
|
OnlyUseCachedDB: false,
|
||||||
// 使用模拟定位
|
// 使用模拟定位
|
||||||
UsingSimulatedPositioning: true,
|
UsingSimulatedPositioning: true,
|
||||||
|
// 私钥
|
||||||
|
pubilcKey: '',
|
||||||
|
// 公钥
|
||||||
|
privateKey: '',
|
||||||
// 应用信息
|
// 应用信息
|
||||||
appInfo: {
|
appInfo: {
|
||||||
// 应用名称
|
// 应用名称
|
||||||
|
|||||||
@@ -25,6 +25,10 @@
|
|||||||
</script>
|
</script>
|
||||||
<!-- 爱山东jssdk -->
|
<!-- 爱山东jssdk -->
|
||||||
<script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
|
<script type="text/javascript" src="https://isdapp.shandong.gov.cn/jmopen/jssdk/index.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" src="./lib/encryption/aes.js"></script>
|
||||||
|
<!-- 引入SM2加密库 -->
|
||||||
|
<script type="text/javascript" src="./lib/encryption/SM.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<!-- <body> -->
|
<!-- <body> -->
|
||||||
<div id="app"><!--app-html--></div>
|
<div id="app"><!--app-html--></div>
|
||||||
|
|||||||
168
lib/encryption/SM.js
Normal file
168
lib/encryption/SM.js
Normal file
File diff suppressed because one or more lines are too long
1354
lib/encryption/aes.js
Normal file
1354
lib/encryption/aes.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,12 @@
|
|||||||
import config from "@/config.js"
|
import config from "@/config.js"
|
||||||
|
import {
|
||||||
|
sm2_Decrypt,
|
||||||
|
sm2_Encrypt
|
||||||
|
} from '@/common/globalFunction';
|
||||||
import useUserStore from '@/stores/useUserStore';
|
import useUserStore from '@/stores/useUserStore';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function request({
|
export function request({
|
||||||
url,
|
url,
|
||||||
method = 'GET',
|
method = 'GET',
|
||||||
|
|||||||
Reference in New Issue
Block a user