Xiao_123 hai 1 semana
pai
achega
78122c6f0d
Modificáronse 6 ficheiros con 30 adicións e 9 borrados
  1. 12 0
      api/system.js
  2. 0 1
      pagesA/resumeOnline/baseInfoEdit.vue
  3. 1 3
      store/system.js
  4. 0 1
      store/user.js
  5. 0 1
      utils/openEncryption.js
  6. 17 3
      utils/request.js

+ 12 - 0
api/system.js

@@ -10,4 +10,16 @@ export const getVersion = () => {
       auth: false
     }
   })
+}
+
+export const sendError = (data) => {
+  return request({
+    url: '/app-api/menduner/system/error-record/create',
+    method: 'POST',
+    data,
+    custom: {
+      showLoading: false,
+      auth: false
+    }
+  })
 }

+ 0 - 1
pagesA/resumeOnline/baseInfoEdit.vue

@@ -188,7 +188,6 @@ const submit = async () => {
     }, 1000)
   } catch (err) {
     console.log(123, '->submit-err:', err)
-    debugger
   }
 }
 </script>

+ 1 - 3
store/system.js

@@ -4,7 +4,6 @@ import { getVersion } from '@/api/system'
 
 export const useSystem = defineStore('system', 
   () => {
-
     const systemInfo = ref({
       timeDifference: undefined, // 服务器时间 - 浏览器时间
       beijingTimestamp: 0
@@ -24,11 +23,10 @@ export const useSystem = defineStore('system',
       } catch (err) {
         console.log('->getTimeDifference-err:', err)
       }
-      // return Promise.resolve(_tem)
     }
 
     return {
-      systemInfo: systemInfo.value,
+      systemInfo,
       setTimeDifference,
       getTimeDifference
     }

+ 0 - 1
store/user.js

@@ -100,7 +100,6 @@ export const userStore = defineStore('user', {
     // 校验是否完善人才必填信息
     checkPersonBaseInfoFun(data) {
       data = data || {}
-      debugger
       if (!data || !Object.keys(data).length || data.type === undefined || data.type === null) {
         showAuthModal('selectUserType')
         return

+ 0 - 1
utils/openEncryption.js

@@ -31,7 +31,6 @@ export const decodeURIComponentSafe = (str) => {
 }
 
 export const encryptionFun = ({raw, body, appId, AppSecret, timestamp}) => {
-  console.log(123, '->进入加密:', 456)
   const initSign = {
     appId,
     nonce: generateUUID(),

+ 17 - 3
utils/request.js

@@ -12,6 +12,7 @@ import { rewardEventTrackClick } from '@/api/integral'
 import { getSuffixAfterPrefix } from '@/utils/prefixUrl'
 import { encryptionFun } from '@/utils/openEncryption'
 import { useSystem } from '@/store/system'
+import { sendError } from '@/api/system'
 
 import qs from 'qs'
 
@@ -26,6 +27,8 @@ const getEventList = () => {
 }
 getEventList()
 
+const errorData = []
+
 const options = {
 	// 显示操作成功消息 默认不显示
 	showSuccess: false,
@@ -140,10 +143,8 @@ http.interceptors.request.use(
         ...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)
       }
 
@@ -152,7 +153,7 @@ http.interceptors.request.use(
         body,
         appId: 'web_client',
         AppSecret: 'fa0fc0b5098b974b',
-        timestamp: new Date().getTime() + systemInfo.timeDifference,
+        timestamp: new Date().getTime() + systemInfo?.timeDifference,
       })
       const content = {
         data: config.data,
@@ -215,6 +216,8 @@ http.interceptors.response.use(
       return
     }
 
+		const config = response.config
+
     // 自定处理【loading 加载中】:如果需要显示 loading,则关闭 loading
 		response.config.custom.showLoading && closeLoading();
 
@@ -238,6 +241,17 @@ http.interceptors.response.use(
       }
 			return Promise.reject(response.data);
 		}
+		const code = response.data.code || 200
+
+		const _index = errorData.findIndex(e => e.url === config.url && e.time === +config.header.timestamp)
+    if (_index > -1) {
+      const _d = errorData.splice(_index, 1)
+      const _item = _d[0]
+      // 保存错误信息
+      if (code === 400) {
+        sendError({ content: JSON.stringify(_item.content), mark: _item.time + '' })
+      }
+    }
 
 		// 自定义处理【showSuccess 成功提示】:如果需要显示成功提示,则显示成功提示
 		if (response.config.custom.showSuccess && response.config.custom.successMsg !== '' && response.data.code === 0) {