@conecli/cone-render 0.9.1-shop2.3 → 0.9.1-shop2.31
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/api/index.ts +1 -1
- package/dist/assets/icon_blue_info.svg +1 -0
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -0
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/jdplayerSdk.ts +1 -0
- package/dist/common/jssdk.ts +1 -0
- package/dist/common/pageType.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/token/token.ts +1 -1
- package/dist/common/wxappApi.jd.ts +1 -0
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.module.scss +7 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +5 -0
- package/dist/components/base/Dialog/index.tsx +1 -1
- package/dist/components/base/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +23 -20
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +17 -0
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -0
- package/dist/components/base/NetworkDataError/const.ts +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +7 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +32 -2
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/interface/utils.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.h5.ts +1 -1
- package/dist/jumpEventReport/index.jd.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
- package/dist/jumpEventReport/web.tjapp.ts +1 -0
- package/dist/jumpEventReport/web.tjm.ts +1 -0
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/modules/ContainerFloorList/index.h5.module.scss +18 -1
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/index.ts +1 -1
- package/dist/open/api/jump copy.ts +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/track.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +49 -3
- package/dist/sass/base.scss +57 -0
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/draExceptionAndProfile.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/sgmCodeUtils.ts +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +26 -3
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
- package/dist/utils/memberFormatUtils.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
export const HttpStatus = {
|
|
2
1
|
SUCCESS: 200,
|
|
3
2
|
CREATED: 201,
|
|
4
3
|
ACCEPTED: 202,
|
|
5
4
|
CLIENT_ERROR: 400,
|
|
6
5
|
AUTHENTICATE: 401,
|
|
7
6
|
FORBIDDEN: 403,
|
|
8
7
|
NOT_FOUND: 404,
|
|
9
8
|
SERVER_ERROR: 500,
|
|
10
9
|
BAD_GATEWAY: 502,
|
|
11
10
|
SERVICE_UNAVAILABLE: 503,
|
|
12
11
|
GATEWAY_TIMEOUT: 504,
|
|
13
12
|
[HttpStatus.NOT_FOUND]: '请求资源不存在',
|
|
14
13
|
[HttpStatus.BAD_GATEWAY]: '服务端异常,请稍后重试',
|
|
15
14
|
[HttpStatus.FORBIDDEN]: '没有权限访问',
|
|
16
15
|
[HttpStatus.AUTHENTICATE]: '需要鉴权',
|
|
17
16
|
[HttpStatus.SUCCESS]: '成功',
|
|
18
17
|
'whx_getShopHomeFloorInfo',
|
|
19
18
|
'whx_searchWare',
|
|
20
19
|
'shopGuessYouLike',
|
|
21
20
|
'whx_getMShopCategory',
|
|
22
21
|
'whx_newWareList',
|
|
23
22
|
'getShopHomePromotionWebPage',
|
|
24
23
|
'whx_getShopCampaignPage',
|
|
25
24
|
'whx_getPromotionWares',
|
|
26
25
|
'whx_buyerShowPage',
|
|
27
26
|
'whx_getShopGwredPage',
|
|
28
27
|
'whx_getShopSpeciSecKillPage',
|
|
29
28
|
'whx_getSignInfo',
|
|
30
29
|
'whx_getSignPrize',
|
|
31
30
|
'getShopHomeFloorInfo',
|
|
32
31
|
'shopGuessYouLike',
|
|
33
32
|
'getShopHomePromotionWebPage',
|
|
34
33
|
'getVipDetail',
|
|
35
34
|
'getShopCategory',
|
|
36
35
|
'getShopNavigationCategory',
|
|
37
36
|
'getPagePreview',
|
|
38
37
|
'bmall_cart',
|
|
39
38
|
'bmall_getOmittedProduct',
|
|
40
39
|
'bmall_cartAdd',
|
|
41
40
|
'bmall_cartChange',
|
|
42
41
|
'bmall_cartRemove',
|
|
43
42
|
"whx_getShopHomeFloorInfo",
|
|
44
43
|
"whx_searchWare",
|
|
45
44
|
"shopGuessYouLike",
|
|
46
45
|
"whx_getMShopCategory",
|
|
47
46
|
"whx_newWareList",
|
|
48
47
|
"getShopHomePromotionWebPage",
|
|
49
48
|
"whx_getShopCampaignPage",
|
|
50
49
|
"whx_getPromotionWares",
|
|
51
50
|
"whx_buyerShowPage"
|
|
52
51
|
'getShopHomeFloorInfo',
|
|
53
52
|
'getShopCategory',
|
|
54
53
|
'getShopNavigationCategory',
|
|
55
54
|
'receiveShopCoupon',
|
|
56
55
|
'getShopHomePromotionWebPage',
|
|
57
56
|
'shopGuessYouLike',
|
|
58
57
|
'addRemind',
|
|
59
58
|
'cancelRemind',
|
|
60
59
|
'getVipDetail',
|
|
61
60
|
'shopDetail',
|
|
62
61
|
'address_queryAddress',
|
|
63
62
|
'shopMemberSprintJoinActivity',
|
|
64
63
|
'shopMemberSprintReceivePrize',
|
|
65
64
|
'customerCenterDispatch'
|
|
66
65
|
'bmall_cart',
|
|
67
66
|
'bmall_getOmittedProduct',
|
|
68
67
|
'bmall_cartAdd',
|
|
69
68
|
'bmall_cartChange',
|
|
70
69
|
'bmall_cartRemove',
|
|
71
70
|
SHOP_COLOR_APPID: 'shop_m_jd_com',
|
|
72
71
|
JSHOPX_COLOR_APPID: 'jshopx_jd_com',
|
|
73
72
|
PAGES_COLOR_APPID: 'pages_jd_com',
|
|
74
73
|
B2B_COLOR_APPID: 'b2b',
|
|
75
74
|
SHOP_MEMBER_COLOR_APPID: 'shopmember_m_jd_com'
|
|
75
|
+
export const HttpStatus = {
|
|
76
76
|
SUCCESS: 200,
|
|
77
77
|
CREATED: 201,
|
|
78
78
|
ACCEPTED: 202,
|
|
79
79
|
CLIENT_ERROR: 400,
|
|
80
80
|
AUTHENTICATE: 401,
|
|
81
81
|
FORBIDDEN: 403,
|
|
82
82
|
NOT_FOUND: 404,
|
|
83
83
|
SERVER_ERROR: 500,
|
|
84
84
|
BAD_GATEWAY: 502,
|
|
85
85
|
SERVICE_UNAVAILABLE: 503,
|
|
86
86
|
GATEWAY_TIMEOUT: 504,
|
|
87
87
|
[HttpStatus.NOT_FOUND]: '请求资源不存在',
|
|
88
88
|
[HttpStatus.BAD_GATEWAY]: '服务端异常,请稍后重试',
|
|
89
89
|
[HttpStatus.FORBIDDEN]: '没有权限访问',
|
|
90
90
|
[HttpStatus.AUTHENTICATE]: '需要鉴权',
|
|
91
91
|
[HttpStatus.SUCCESS]: '成功',
|
|
92
92
|
'whx_getShopHomeFloorInfo',
|
|
93
93
|
'whx_searchWare',
|
|
94
94
|
'shopGuessYouLike',
|
|
95
95
|
'whx_getMShopCategory',
|
|
96
96
|
'whx_newWareList',
|
|
97
97
|
'getShopHomePromotionWebPage',
|
|
98
98
|
'whx_getShopCampaignPage',
|
|
99
99
|
'whx_getPromotionWares',
|
|
100
100
|
'whx_buyerShowPage',
|
|
101
101
|
'whx_getShopGwredPage',
|
|
102
102
|
'whx_getShopSpeciSecKillPage',
|
|
103
103
|
'whx_getSignInfo',
|
|
104
104
|
'whx_getSignPrize',
|
|
105
105
|
'getShopHomeFloorInfo',
|
|
106
106
|
'shopGuessYouLike',
|
|
107
107
|
'getShopHomePromotionWebPage',
|
|
108
108
|
'getVipDetail',
|
|
109
109
|
'getShopCategory',
|
|
110
110
|
'getShopNavigationCategory',
|
|
111
111
|
'getPagePreview',
|
|
112
112
|
'bmall_cart',
|
|
113
113
|
'bmall_getOmittedProduct',
|
|
114
114
|
'bmall_cartAdd',
|
|
115
115
|
'bmall_cartChange',
|
|
116
116
|
'bmall_cartRemove',
|
|
117
117
|
"whx_getShopHomeFloorInfo",
|
|
118
118
|
"whx_searchWare",
|
|
119
119
|
"shopGuessYouLike",
|
|
120
120
|
"whx_getMShopCategory",
|
|
121
121
|
"whx_newWareList",
|
|
122
122
|
"getShopHomePromotionWebPage",
|
|
123
123
|
"whx_getShopCampaignPage",
|
|
124
124
|
"whx_getPromotionWares",
|
|
125
125
|
"whx_buyerShowPage"
|
|
126
126
|
'getShopHomeFloorInfo',
|
|
127
127
|
'getShopCategory',
|
|
128
128
|
'getShopNavigationCategory',
|
|
129
129
|
'receiveShopCoupon',
|
|
130
130
|
'getShopHomePromotionWebPage',
|
|
131
131
|
'shopGuessYouLike',
|
|
132
132
|
'addRemind',
|
|
133
133
|
'cancelRemind',
|
|
134
134
|
'getVipDetail',
|
|
135
135
|
'shopDetail',
|
|
136
136
|
'address_queryAddress',
|
|
137
137
|
'shopMemberSprintJoinActivity',
|
|
138
138
|
'shopMemberSprintReceivePrize',
|
|
139
139
|
'customerCenterDispatch'
|
|
140
140
|
'bmall_cart',
|
|
141
141
|
'bmall_getOmittedProduct',
|
|
142
142
|
'bmall_cartAdd',
|
|
143
143
|
'bmall_cartChange',
|
|
144
144
|
'bmall_cartRemove',
|
|
145
145
|
SHOP_COLOR_APPID: 'shop_m_jd_com',
|
|
146
146
|
JSHOPX_COLOR_APPID: 'jshopx_jd_com',
|
|
147
147
|
PAGES_COLOR_APPID: 'pages_jd_com',
|
|
148
148
|
B2B_COLOR_APPID: 'b2b',
|
|
149
149
|
SHOP_MEMBER_COLOR_APPID: 'shopmember_m_jd_com',
|
|
150
150
|
MALL_COLOR_APPID: 'mall_jd_com'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import Taro from '@tarojs/taro'
|
|
2
|
isSupportHybridHttpRequest,
|
|
1
3
|
draInterfaceCustomReport,
|
|
2
4
|
draBusinessCustomReport,
|
|
3
5
|
jsonHeader = 'application/json;charset=utf-8',
|
|
4
6
|
formDataHeader = 'application/x-www-form-urlencoded',
|
|
5
7
|
HYBRID: 'httpRequest_hybrid',
|
|
6
8
|
TARO: 'httpRequest_taro',
|
|
7
9
|
#requestTimeStamp: number
|
|
8
10
|
#responseTimeStamp: number
|
|
9
11
|
#getResTimeStamp: number
|
|
10
12
|
#reportType: string
|
|
11
13
|
#callbackFunction: string
|
|
12
14
|
|
|
13
15
|
async request({
|
|
14
16
|
url,
|
|
15
17
|
method = 'POST',
|
|
16
18
|
timeout = 7000,
|
|
17
19
|
isColorVerify = false,
|
|
18
20
|
...otherOptions
|
|
19
21
|
}): Promise<Taro.request.SuccessCallbackResult<any>> {
|
|
20
22
|
const { header: otherHeader, ...otherOpts } = otherOptions
|
|
21
23
|
const header = {
|
|
22
24
|
'content-type':
|
|
23
25
|
method === 'POST'
|
|
24
26
|
? RequestHeaderContentType.formDataHeader
|
|
25
27
|
: RequestHeaderContentType.jsonHeader,
|
|
26
28
|
...otherHeader,
|
|
27
29
|
}
|
|
28
30
|
let getRequestUrl = url
|
|
29
31
|
let requestTask
|
|
30
32
|
const data = otherOpts?.data
|
|
31
33
|
const isGatewayRequest =
|
|
32
34
|
url === this.api.apiFunc && typeof data === 'object'
|
|
33
35
|
if (isGatewayRequest) {
|
|
34
36
|
getRequestUrl = this._handleSpecialGatewayUrl(url)
|
|
35
37
|
const shouldUseHybridRequest = this._shouldUseHybridRequest()
|
|
36
38
|
if (shouldUseHybridRequest) {
|
|
37
39
|
requestTask = this._hybridRequest(getRequestUrl, data)
|
|
38
40
|
} else {
|
|
39
41
|
otherOpts.data = await this._prepareGatewayReqData(data, isColorVerify)
|
|
40
42
|
requestTask = this._taroRequest(
|
|
41
43
|
getRequestUrl,
|
|
42
44
|
otherOpts,
|
|
43
45
|
method,
|
|
44
46
|
timeout,
|
|
45
47
|
header,
|
|
46
48
|
)
|
|
47
49
|
}
|
|
48
50
|
} else {
|
|
49
51
|
requestTask = this._taroRequest(
|
|
50
52
|
getRequestUrl,
|
|
51
53
|
otherOpts,
|
|
52
54
|
method,
|
|
53
55
|
timeout,
|
|
54
56
|
header,
|
|
55
57
|
)
|
|
56
58
|
}
|
|
57
59
|
const requestTimeoutPromise =
|
|
58
60
|
new Promise<ServiceInterFace.RequestPromiseRes>((resolve) => {
|
|
59
61
|
setTimeout(() => {
|
|
60
62
|
resolve({
|
|
61
63
|
statusCode: 500,
|
|
62
64
|
resTimeoutState: true,
|
|
63
65
|
errMsg: 'request timeout',
|
|
64
66
|
})
|
|
65
67
|
}, timeout)
|
|
66
68
|
})
|
|
67
69
|
return Promise.race([requestTask, requestTimeoutPromise]).then(
|
|
68
70
|
(res: any) => {
|
|
69
71
|
if (res && res.statusCode === 500 && res.resTimeoutState) {
|
|
70
72
|
if (this.#reportType === HTTP_REQUEST_TYPE.HYBRID) {
|
|
71
73
|
this._clearFunction(this.#callbackFunction)
|
|
72
74
|
} else {
|
|
73
75
|
requestTask.abort && requestTask.abort()
|
|
74
76
|
}
|
|
75
77
|
}
|
|
76
78
|
this._handleReportInterfaceError(url, data, timeout, res)
|
|
77
79
|
return res
|
|
78
80
|
},
|
|
79
81
|
)
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
_handleSpecialGatewayUrl(url: string): string {
|
|
83
85
|
if (isPc && window.location.hostname.includes('.jd.hk')) {
|
|
84
86
|
return this.api.hkApiFunc
|
|
85
87
|
}
|
|
86
88
|
if (
|
|
87
89
|
isJdApp &&
|
|
88
90
|
window?.shopGlobalSwitch?.dualProtocol &&
|
|
89
91
|
!window.location.href.includes('jshopx_vconsole')
|
|
90
92
|
) {
|
|
91
93
|
return window?.shopGlobalSwitch?.dualProtocol?.apiTestApp || url
|
|
92
94
|
}
|
|
93
95
|
return url
|
|
94
96
|
}
|
|
95
97
|
|
|
96
98
|
_shouldUseHybridRequest(): boolean {
|
|
97
99
|
try {
|
|
98
100
|
if (!isJdApp || !isSupportHybridHttpRequest || isJdAndHarmonyDevice) {
|
|
99
101
|
return false
|
|
100
102
|
}
|
|
101
103
|
const configData = global.getDynamicConfig('hybridHttpSwitch')
|
|
102
104
|
const { globalOn = false, grayscale = {} } = configData || {}
|
|
103
105
|
const buildType = process.env.BUILD_TYPE || ''
|
|
104
106
|
const isInvokeGray = globalOn || grayscale[buildType]
|
|
105
107
|
console.log(
|
|
106
108
|
'使用hybrid请求是否命中灰度,isInvokeGray:',
|
|
107
109
|
isInvokeGray,
|
|
108
110
|
'获取mpaas配置hybridHttpSwitch原始数据configData',
|
|
109
111
|
configData,
|
|
110
112
|
)
|
|
111
113
|
const hasWindowXWebView = !!window.XWebView
|
|
112
114
|
return isInvokeGray && hasWindowXWebView
|
|
113
115
|
} catch (e) {
|
|
114
116
|
console.log('获取是否使用Hybrid请求出错,e:', e)
|
|
115
117
|
return false
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
120
|
|
|
119
121
|
_hybridRequest(url: string, data: any): Promise<any> {
|
|
120
122
|
return new Promise((resolve, reject) => {
|
|
121
123
|
try {
|
|
122
124
|
const changeCurrentUrl = url.startsWith('//') ? `https:${url}` : url
|
|
123
125
|
const { functionId, body, ...otherH5Param } = data
|
|
124
126
|
const reqParams = {
|
|
125
127
|
url: isIosDevice ? `${changeCurrentUrl}/` : changeCurrentUrl,
|
|
126
128
|
functionId: functionId,
|
|
127
129
|
body: body,
|
|
128
130
|
headerType: '0',
|
|
129
131
|
param: {
|
|
130
132
|
...otherH5Param,
|
|
131
133
|
},
|
|
132
134
|
header: {
|
|
133
135
|
Referer: window.location.origin,
|
|
134
136
|
},
|
|
135
137
|
}
|
|
136
138
|
const callbackFunction = this._generateCallbackFunction()
|
|
137
139
|
this.#callbackFunction = callbackFunction
|
|
138
140
|
this.#requestTimeStamp = Date.now()
|
|
139
141
|
this.#reportType = HTTP_REQUEST_TYPE.HYBRID
|
|
140
142
|
window.XWebView.callNative(
|
|
141
143
|
'ColorQueryPlugin',
|
|
142
144
|
'colorRequest',
|
|
143
145
|
JSON.stringify(reqParams),
|
|
144
146
|
callbackFunction,
|
|
145
147
|
'1',
|
|
146
148
|
)
|
|
147
149
|
window[callbackFunction] = (result) => {
|
|
148
150
|
this.#responseTimeStamp = Date.now()
|
|
149
151
|
try {
|
|
150
152
|
const resultObj =
|
|
151
153
|
typeof result === 'string' ? JSON.parse(result) : result
|
|
152
154
|
resolve(resultObj)
|
|
153
155
|
} catch (error) {
|
|
154
156
|
const errMsg = 'hybrid网络请求JSON解析失败, error: ' + error
|
|
155
157
|
draBusinessCustomReport({
|
|
156
158
|
type: `${HTTP_REQUEST_TYPE.HYBRID}_jsonParseError`,
|
|
157
159
|
errMsg,
|
|
158
160
|
result,
|
|
159
161
|
})
|
|
160
162
|
reject({ errMsg })
|
|
161
163
|
}
|
|
162
164
|
this._clearFunction(callbackFunction)
|
|
163
165
|
}
|
|
164
166
|
} catch (error) {
|
|
165
167
|
reject({
|
|
166
168
|
errMsg:
|
|
167
169
|
'hybrid网络请求,App下调用window.XWebView.callNative出错, error: ' +
|
|
168
170
|
error,
|
|
169
171
|
})
|
|
170
172
|
}
|
|
171
173
|
})
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
_generateCallbackFunction() {
|
|
175
177
|
return `hybridHttpRequestCallback_${Date.now()}_${Math.ceil(
|
|
176
178
|
Math.random() * 100000,
|
|
177
179
|
)}`
|
|
178
180
|
}
|
|
179
181
|
|
|
180
182
|
_clearFunction(functionName: string) {
|
|
181
183
|
try {
|
|
182
184
|
delete window[functionName]
|
|
183
185
|
} catch (e) {
|
|
184
186
|
window[functionName] = undefined
|
|
185
187
|
}
|
|
186
188
|
}
|
|
187
189
|
|
|
188
190
|
async _prepareGatewayReqData(
|
|
189
191
|
data: any,
|
|
190
192
|
isColorVerify: boolean,
|
|
191
193
|
): Promise<any> {
|
|
192
194
|
const { functionId } = data
|
|
193
195
|
console.log('获取当前是否需要color加固', isColorVerify, functionId)
|
|
194
196
|
if (isColorVerify) {
|
|
195
197
|
const { h5st } = await colorSign.paramsSign(data)
|
|
196
198
|
h5st && (data.h5st = encodeURI(h5st))
|
|
197
199
|
console.log(`${functionId}的apiReq_h5st===>:${h5st}`)
|
|
198
200
|
}
|
|
199
201
|
const { jsToken } = await colorSign.getFmInfo()
|
|
200
202
|
console.log(`${functionId}的api jsToken指纹===>:${jsToken}`)
|
|
201
203
|
jsToken && (data['x-api-eid-token'] = jsToken)
|
|
202
204
|
return data
|
|
203
205
|
}
|
|
204
206
|
|
|
205
207
|
_taroRequest(
|
|
206
208
|
url: string,
|
|
207
209
|
otherOpts: any,
|
|
208
210
|
method: string,
|
|
209
211
|
timeout: number,
|
|
210
212
|
header: string,
|
|
211
213
|
): Promise<any> {
|
|
212
214
|
const reqParam = {
|
|
213
215
|
url,
|
|
214
216
|
method,
|
|
215
217
|
timeout,
|
|
216
218
|
header,
|
|
217
219
|
credentials: 'include',
|
|
218
220
|
...otherOpts,
|
|
219
221
|
}
|
|
220
222
|
this.#requestTimeStamp = Date.now()
|
|
221
223
|
this.#reportType = HTTP_REQUEST_TYPE.TARO
|
|
222
224
|
return Taro.request(reqParam)
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
_reportRequestTime(url: string, data: any): void {
|
|
226
228
|
this.#getResTimeStamp = Date.now()
|
|
227
229
|
if (this.#reportType === HTTP_REQUEST_TYPE.TARO) {
|
|
228
230
|
this.#responseTimeStamp = this.#getResTimeStamp
|
|
229
231
|
}
|
|
230
232
|
draInterfaceCustomReport(
|
|
231
233
|
{
|
|
232
234
|
type: `${this.#reportType}_consumeTime`,
|
|
233
235
|
url,
|
|
234
236
|
functionId: data?.functionId,
|
|
235
237
|
requestTimeStamp: this.#requestTimeStamp,
|
|
236
238
|
responseTimeStamp: this.#responseTimeStamp,
|
|
237
239
|
errMsg: `使用${this.#reportType}调用接口请求响应耗时`,
|
|
238
240
|
source: 'remote',
|
|
239
241
|
},
|
|
240
242
|
{
|
|
241
243
|
consumeTime: `${this.#responseTimeStamp - this.#requestTimeStamp}ms`,
|
|
242
244
|
getResTime: `${this.#getResTimeStamp - this.#requestTimeStamp}ms`,
|
|
243
245
|
},
|
|
244
246
|
)
|
|
245
247
|
}
|
|
246
248
|
|
|
247
249
|
_handleReportInterfaceError(
|
|
248
250
|
url: string,
|
|
249
251
|
reqData: any,
|
|
250
252
|
timeOut: any,
|
|
251
253
|
res: any,
|
|
252
254
|
): void {
|
|
253
255
|
const source = 'remote'
|
|
254
256
|
const requestType = this.#reportType
|
|
255
257
|
let errorType = ''
|
|
256
258
|
let subMsg = ''
|
|
257
259
|
let reportFlag = false
|
|
258
260
|
if (res) {
|
|
259
261
|
const { statusCode, data, status, resTimeoutState } = res
|
|
260
262
|
if (statusCode === 500 && resTimeoutState) {
|
|
261
263
|
reportFlag = true
|
|
262
264
|
errorType = 'timeout'
|
|
263
265
|
subMsg = `接口请求超时${timeOut}ms`
|
|
264
266
|
} else if ((statusCode === 200 || status === '0') && data) {
|
|
265
267
|
const resCode = Object.prototype.hasOwnProperty.call(data, 'code')
|
|
266
268
|
? Number(data.code)
|
|
267
269
|
: -1
|
|
268
270
|
const isSuccess = resCode === 0 || resCode === 200 || data?.success
|
|
269
271
|
if (!isSuccess) {
|
|
270
272
|
reportFlag = true
|
|
271
273
|
errorType = 'dataError'
|
|
272
274
|
subMsg = '接口请求返回数据异常'
|
|
273
275
|
}
|
|
274
276
|
} else {
|
|
275
277
|
reportFlag = true
|
|
276
278
|
errorType = 'statusError'
|
|
277
279
|
subMsg = '接口请求本身异常'
|
|
278
280
|
}
|
|
279
281
|
}
|
|
280
282
|
reportFlag &&
|
|
281
283
|
draInterfaceCustomReport({
|
|
282
284
|
subMsg,
|
|
283
285
|
url,
|
|
284
286
|
source,
|
|
285
287
|
requestType,
|
|
286
288
|
errorType,
|
|
287
289
|
code: res?.data?.code,
|
|
288
290
|
body: reqData?.body,
|
|
289
291
|
appid: reqData?.appId,
|
|
290
292
|
t: reqData?.t,
|
|
291
293
|
client: reqData?.client,
|
|
292
294
|
clientVersion: reqData?.clientVersion,
|
|
293
295
|
...res,
|
|
294
296
|
})
|
|
295
297
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import H5Http from "./h5Http"
|