|
@@ -11,6 +11,7 @@ import { showAuthModal } from '@/hooks/useModal'
|
|
|
import { rewardEventTrackClick } from '@/api/integral'
|
|
|
import { getSuffixAfterPrefix } from '@/utils/prefixUrl'
|
|
|
import { encryptionFun } from '@/utils/openEncryption'
|
|
|
+import { useSystem } from '@/store/system'
|
|
|
|
|
|
import qs from 'qs'
|
|
|
|
|
@@ -85,7 +86,7 @@ const http = new Request({
|
|
|
* @description 请求拦截器
|
|
|
*/
|
|
|
http.interceptors.request.use(
|
|
|
- (config) => {
|
|
|
+ async (config) => {
|
|
|
const useUserStore = userStore()
|
|
|
// 自定义处理【auth 授权】:必须登录的接口,则跳出 AuthModal 登录弹窗
|
|
|
if (config.custom.auth && !useUserStore.isLogin) {
|
|
@@ -133,12 +134,39 @@ http.interceptors.request.use(
|
|
|
|
|
|
// 开启参数加密
|
|
|
if (config.custom?.openEncryption) {
|
|
|
+ const { getTimeDifference, setTimeDifference, systemInfo } = useSystem()
|
|
|
const raw = config.url.split('?')[1]
|
|
|
- const body = {
|
|
|
- ...config.data,
|
|
|
- ...config.params
|
|
|
- }
|
|
|
- const header = encryptionFun({raw, body, appId: 'web_client', AppSecret: 'fa0fc0b5098b974b'})
|
|
|
+ const body = {
|
|
|
+ ...typeof config.data === 'string' ? JSON.parse(config.data) : config.data,
|
|
|
+ ...typeof config.params === 'string' ? JSON.parse(config.params) : config.params
|
|
|
+ }
|
|
|
+ console.log(123, '->timeDifference:', systemInfo.timeDifference)
|
|
|
+ if (!systemInfo?.timeDifference) {
|
|
|
+ const _difference = await getTimeDifference()
|
|
|
+ console.log(123, '->打印_difference:', _difference)
|
|
|
+ setTimeDifference(_difference)
|
|
|
+ }
|
|
|
+
|
|
|
+ const header = encryptionFun({
|
|
|
+ raw,
|
|
|
+ body,
|
|
|
+ appId: 'web_client',
|
|
|
+ AppSecret: 'fa0fc0b5098b974b',
|
|
|
+ timestamp: new Date().getTime() + systemInfo.timeDifference,
|
|
|
+ })
|
|
|
+ const content = {
|
|
|
+ data: config.data,
|
|
|
+ params: config.params,
|
|
|
+ body,
|
|
|
+ raw,
|
|
|
+ config
|
|
|
+ }
|
|
|
+ // 记录错误
|
|
|
+ errorData.push({
|
|
|
+ time: header.timestamp,
|
|
|
+ url: config.url,
|
|
|
+ content
|
|
|
+ })
|
|
|
Object.assign(config.header, header)
|
|
|
}
|
|
|
|
|
@@ -381,7 +409,7 @@ const getIntegral = (url) => {
|
|
|
|
|
|
/** 获得必填人才信息情况 */
|
|
|
export const showNecessaryInfoPopup = () => {
|
|
|
- return uni.getStorageSync('necessaryInfoReady') === 'fddeaddc47868b';
|
|
|
+ return uni.getStorageSync('necessaryInfoReady') === 'student';
|
|
|
}
|
|
|
|
|
|
/** 获得访问令牌 */
|