ike-weblca-html 2.2.17 → 2.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/src/IkeWebFooter.js +12 -6
- package/src/IkeWebHeader.js +371 -330
- package/src/js/UserAgreement.js +15 -8
- package/src/js/requestError.js +24 -0
package/src/js/UserAgreement.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {css, html, LitElement} from 'lit-element';
|
|
2
|
-
import cookies from 'js-cookie'
|
|
1
|
+
import {css, html, LitElement} from 'lit-element';
|
|
2
|
+
import cookies from 'js-cookie'
|
|
3
|
+
import { getResponseErrorMessage, notifyRequestError } from './requestError'
|
|
3
4
|
|
|
4
5
|
let overlay;
|
|
5
6
|
let modal;
|
|
@@ -10,12 +11,18 @@ const AcceptArgreement = async (url, id, handOk) => {
|
|
|
10
11
|
method: 'POST', headers: {
|
|
11
12
|
Authorization: cookies.get("token")
|
|
12
13
|
}
|
|
13
|
-
});
|
|
14
|
-
const jsonData = await response.json();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
});
|
|
15
|
+
const jsonData = await response.json();
|
|
16
|
+
const errorMessage = getResponseErrorMessage(response, jsonData, '确认用户协议失败');
|
|
17
|
+
if (errorMessage) {
|
|
18
|
+
notifyRequestError(errorMessage);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
let data = jsonData.data; // 将获取到的数据保存到 data 属性中
|
|
22
|
+
handOk()
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error('Error fetching data:', error);
|
|
25
|
+
notifyRequestError('确认用户协议失败');
|
|
19
26
|
}
|
|
20
27
|
}
|
|
21
28
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const REQUEST_ERROR_EVENT = 'ike-web-request-error'
|
|
2
|
+
|
|
3
|
+
export function getResponseErrorMessage(response, payload, fallbackMessage) {
|
|
4
|
+
const code = payload && (payload.Code ?? payload.code)
|
|
5
|
+
const message = payload && (payload.Message || payload.message)
|
|
6
|
+
|
|
7
|
+
if (!response.ok) return message || fallbackMessage
|
|
8
|
+
|
|
9
|
+
if (code !== undefined && code !== null && Number(code) !== 200) {
|
|
10
|
+
return message || fallbackMessage
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (payload && payload.success === false) return message || fallbackMessage
|
|
14
|
+
|
|
15
|
+
return ''
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function notifyRequestError(message) {
|
|
19
|
+
window.dispatchEvent(
|
|
20
|
+
new CustomEvent(REQUEST_ERROR_EVENT, {
|
|
21
|
+
detail: { message },
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
}
|