@conecli/cone-render 0.8.22-beta.1 → 0.8.22-beta.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import React from 'react'
|
|
2
1
|
subMessage?: string
|
|
3
2
|
customErrorIsvFloorModule?: React.ReactElement | undefined
|
|
4
3
|
containerIndex?: number
|
|
5
4
|
containerData?: any
|
|
6
5
|
shopTotalInfo?: any
|
|
7
6
|
selectContainerFn?: Function
|
|
8
7
|
selectContainerId?: string
|
|
9
8
|
placeHolderPreContainerId?: string
|
|
10
9
|
children?: any
|
|
11
10
|
style?: {
|
|
12
11
|
[key: string]: any
|
|
13
12
|
};
|
|
14
13
|
layoutLeftRightMargin?: number
|
|
15
14
|
}
|
|
15
|
+
import React from 'react'
|
|
16
16
|
subMessage?: string
|
|
17
17
|
showCommonFloorHead?: boolean
|
|
18
18
|
customErrorIsvFloorModule?: React.ReactElement | undefined
|
|
19
19
|
containerIndex?: number
|
|
20
20
|
containerData?: any
|
|
21
21
|
shopTotalInfo?: any
|
|
22
22
|
selectContainerFn?: Function
|
|
23
23
|
selectContainerId?: string
|
|
24
24
|
placeHolderPreContainerId?: string
|
|
25
25
|
children?: any
|
|
26
26
|
style?: {
|
|
27
27
|
[key: string]: any
|
|
28
28
|
};
|
|
29
29
|
layoutLeftRightMargin?: number
|
|
30
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import { JdJumpJdApp } from './jdJumpJdApp'
|
|
2
1
|
reportClick,
|
|
3
2
|
reportToCart,
|
|
4
3
|
routerInfo: {
|
|
5
4
|
params: {},
|
|
6
5
|
},
|
|
7
6
|
nativeEvent: null,
|
|
8
7
|
jumpConfig: {
|
|
9
8
|
venderId: null,
|
|
10
9
|
shopId: null,
|
|
11
10
|
sourceValue: '',
|
|
12
11
|
sourceType: 'App-H5',
|
|
13
12
|
activityType: 'shopx',
|
|
14
13
|
moduleId: 'none',
|
|
15
14
|
entrance: 'none',
|
|
16
15
|
},
|
|
17
16
|
logPageParamStr: '',
|
|
18
17
|
public logPageId: string
|
|
19
18
|
public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
|
|
20
19
|
constructor(opt = {}) {
|
|
21
20
|
console.log("jdb加载==========")
|
|
22
21
|
super(opt)
|
|
23
22
|
this.getConfig(opt)
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
jdJumpToProduct(skuParams, logEventInfo) {
|
|
27
26
|
if(typeof skuParams !== 'object') {
|
|
28
27
|
console.error('万商app跳转商品详情参数需要对象,详情请查看文档')
|
|
29
28
|
return
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
let { skuId, bMallTag, skuUniformBizInfo } = skuParams
|
|
33
32
|
skuId = skuId.toString().trim()
|
|
34
33
|
this.jdNavigateToNative({
|
|
35
34
|
category: 'jump',
|
|
36
35
|
des: 'skudetail',
|
|
37
36
|
param: {
|
|
38
37
|
skuId: skuId,
|
|
39
38
|
bMallTag: bMallTag,
|
|
40
39
|
skuUniformBizInfo
|
|
41
40
|
},
|
|
42
41
|
logEventInfo,
|
|
43
42
|
})
|
|
44
43
|
}
|
|
45
44
|
jdNavigateToNative(
|
|
46
45
|
console.log("otherParams", otherParams)
|
|
47
46
|
const paramsStr = JSON.stringify(otherParams)
|
|
48
47
|
console.log(
|
|
49
48
|
'跳转web jd open协议',
|
|
50
49
|
`${url}?params=${paramsStr}`,
|
|
51
50
|
)
|
|
52
51
|
console.log('catch', e)
|
|
53
52
|
clickEventLog(
|
|
54
53
|
getConfig(opt = {}) {
|
|
55
54
|
return Object.assign(this, {}, defaultConfig, opt)
|
|
56
55
|
}
|
|
56
|
+
import { JdJumpJdApp } from './jdJumpJdApp'
|
|
57
57
|
reportClick,
|
|
58
58
|
reportToCart,
|
|
59
59
|
routerInfo: {
|
|
60
60
|
params: {},
|
|
61
61
|
},
|
|
62
62
|
nativeEvent: null,
|
|
63
63
|
jumpConfig: {
|
|
64
64
|
venderId: null,
|
|
65
65
|
shopId: null,
|
|
66
66
|
sourceValue: '',
|
|
67
67
|
sourceType: 'App-H5',
|
|
68
68
|
activityType: 'shopx',
|
|
69
69
|
moduleId: 'none',
|
|
70
70
|
entrance: 'none',
|
|
71
71
|
},
|
|
72
72
|
logPageParamStr: '',
|
|
73
73
|
public logPageId: string
|
|
74
74
|
public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
|
|
75
75
|
constructor(opt = {}) {
|
|
76
76
|
console.log("jdb加载==========")
|
|
77
77
|
super(opt)
|
|
78
78
|
this.getConfig(opt)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
jdJumpConfigUrl(detail, logEventInfo = {}) {
|
|
82
82
|
const { configDataType, configDataValue } = detail
|
|
83
83
|
switch (configDataType) {
|
|
84
84
|
case LinkConfigType.CONFIG_TYPE_SKU_LIST:
|
|
85
85
|
this.jdJumpToProduct({
|
|
86
86
|
...configDataValue,
|
|
87
87
|
skuId: configDataValue.skuIds,
|
|
88
88
|
}, logEventInfo)
|
|
89
89
|
break
|
|
90
90
|
default:
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
jdJumpToProduct(skuParams, logEventInfo) {
|
|
95
95
|
if(typeof skuParams !== 'object') {
|
|
96
96
|
console.error('万商app跳转商品详情参数需要对象,详情请查看文档')
|
|
97
97
|
return
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
let { skuId, bMallTag = "1", skuUniformBizInfo } = skuParams
|
|
101
101
|
skuId = skuId.toString().trim()
|
|
102
102
|
this.jdNavigateToNative({
|
|
103
103
|
category: 'jump',
|
|
104
104
|
des: 'skudetail',
|
|
105
105
|
param: {
|
|
106
106
|
skuId: skuId,
|
|
107
107
|
bMallTag: bMallTag,
|
|
108
108
|
skuUniformBizInfo
|
|
109
109
|
},
|
|
110
110
|
logEventInfo,
|
|
111
111
|
})
|
|
112
112
|
}
|
|
113
113
|
jdNavigateToNative(
|
|
114
114
|
console.log("otherParams", otherParams)
|
|
115
115
|
const paramsStr = JSON.stringify(otherParams)
|
|
116
116
|
console.log(
|
|
117
117
|
'跳转web jdb open协议',
|
|
118
118
|
`${url}?params=${paramsStr}`,
|
|
119
119
|
)
|
|
120
120
|
console.log('catch', e)
|
|
121
121
|
clickEventLog(
|
|
122
122
|
getConfig(opt = {}) {
|
|
123
123
|
return Object.assign(this, {}, defaultConfig, opt)
|
|
124
124
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const getUserInfo = () => {
|
|
2
|
let result = {}
|
|
1
3
|
try {
|
|
2
4
|
result = JSON.parse(
|
|
3
5
|
window.WebViewCommon && window.WebViewCommon.getUserInfo(),
|
|
4
6
|
)
|
|
5
7
|
} catch {}
|
|
6
8
|
return result
|
|
7
9
|
buId: userInfo?.data?.buId,
|
|
8
10
|
process.env.NODE_ENV === 'development'
|
|
9
11
|
? {
|
|
10
12
|
apolloId: '48ee955b0fb04d19b9f9fe8cb73d387f',
|
|
11
13
|
apolloSecret: '0d9c76ee66b0487da4e17d3cf1d7af7a',
|
|
12
14
|
}
|
|
13
15
|
: {
|
|
14
16
|
apolloId: '80c46fd06e4442998609d9f6a4ab96f0',
|
|
15
17
|
apolloSecret: 'f36bef08bcba4683b409732095793fb2',
|
|
16
18
|
}
|
|
17
19
|
if (typeof window.crypto === 'object') {
|
|
18
20
|
if (typeof (window.crypto as any).randomUUID === 'function') {
|
|
19
21
|
return (window.crypto as any).randomUUID()
|
|
20
22
|
}
|
|
21
23
|
if (
|
|
22
24
|
typeof (window.crypto as any).getRandomValues === 'function' &&
|
|
23
25
|
typeof Uint8Array === 'function'
|
|
24
26
|
) {
|
|
25
27
|
const callback = (c) => {
|
|
26
28
|
const num = Number(c)
|
|
27
29
|
return (
|
|
28
30
|
num ^
|
|
29
31
|
((window.crypto as any).getRandomValues(new Uint8Array(1))[0] &
|
|
30
32
|
(15 >> (num / 4)))
|
|
31
33
|
).toString(16)
|
|
32
34
|
}
|
|
33
35
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, callback)
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
let timestamp = new Date().getTime()
|
|
37
39
|
let perforNow =
|
|
38
40
|
(typeof window.performance !== 'undefined' &&
|
|
39
41
|
window.performance.now &&
|
|
40
42
|
window.performance.now() * 1000) ||
|
|
41
43
|
0
|
|
42
44
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
43
45
|
let random = Math.random() * 16
|
|
44
46
|
if (timestamp > 0) {
|
|
45
47
|
random = (timestamp + random) % 16 | 0
|
|
46
48
|
timestamp = Math.floor(timestamp / 16)
|
|
47
49
|
} else {
|
|
48
50
|
random = (perforNow + random) % 16 | 0
|
|
49
51
|
perforNow = Math.floor(perforNow / 16)
|
|
50
52
|
}
|
|
51
53
|
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
|
|
52
54
|
})
|
|
53
55
|
let params = {
|
|
54
56
|
uniformBizInfo: {
|
|
55
57
|
tenantId: 1024,
|
|
56
58
|
ua: 1,
|
|
57
59
|
buId: commonParam.buId || 377,
|
|
58
60
|
bMallTag: bMallTag,
|
|
59
61
|
},
|
|
60
62
|
commonParam: {
|
|
61
63
|
pid: 100,
|
|
62
64
|
verticalCode: 'cn_retail_bmall',
|
|
63
65
|
ua: 1,
|
|
64
66
|
language: 'zh',
|
|
65
67
|
},
|
|
66
68
|
operations: [{ TheSkus: [{ Id: skuId, num: num || 1 }] }],
|
|
67
69
|
apolloId: APOLLO.apolloId,
|
|
68
70
|
apolloSecret: APOLLO.apolloSecret,
|
|
69
71
|
client: 'H5',
|
|
70
72
|
verticalTag: 'cn_retail_bmall',
|
|
71
73
|
carttype: bMallTag == 1 ? 21 : 22,
|
|
72
74
|
bMallTag: bMallTag,
|
|
73
75
|
traceId: getUuid(),
|
|
74
76
|
noResponse: true,
|
|
75
77
|
}
|
|
76
78
|
if (skuUuid) {
|
|
77
79
|
params.operations[0].TheSkus[0].skuUuid = skuUuid
|
|
78
80
|
}
|
|
79
81
|
if (window?.siteTransResult?.gridInfoList) {
|
|
80
82
|
params = {
|
|
81
83
|
...params,
|
|
82
84
|
cartLocationList: [
|
|
83
85
|
{
|
|
84
86
|
gridInfos:
|
|
85
87
|
window?.siteTransResult?.gridInfoList &&
|
|
86
88
|
JSON.parse(window?.siteTransResult?.gridInfoList),
|
|
87
89
|
areaIdSet:
|
|
88
90
|
window?.siteTransResult?.area &&
|
|
89
91
|
window?.siteTransResult?.area?.split('-'),
|
|
90
92
|
},
|
|
91
93
|
],
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
return params
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
SHOP_COLOR_APPID,
|
|
3
2
|
JshopxColorFunctionIdList,
|
|
4
3
|
PagesColorFunctionIdList,
|
|
5
4
|
JSHOPX_COLOR_APPID,
|
|
6
5
|
PAGES_COLOR_APPID,
|
|
7
6
|
PAGES_DOMAIN,
|
|
8
7
|
B2BColorFunctionIdList,
|
|
9
8
|
B2B_COLOR_APPID,
|
|
10
9
|
cookiesStr: '',
|
|
11
10
|
requestHeaderContentType: {
|
|
12
11
|
jsonHeader: {
|
|
13
12
|
'content-type': 'application/json;charset=utf-8',
|
|
14
13
|
},
|
|
15
14
|
formDataHeader: {
|
|
16
15
|
'content-type': 'application/x-www-form-urlencoded',
|
|
17
16
|
},
|
|
18
17
|
},
|
|
19
18
|
requestBaseParam: {
|
|
20
19
|
data: null,
|
|
21
20
|
header: {
|
|
22
21
|
'content-type': 'application/json;charset=utf-8',
|
|
23
22
|
},
|
|
24
23
|
},
|
|
25
24
|
timeOut: 7000,
|
|
26
25
|
apiClientParams: {
|
|
27
26
|
appid: SHOP_COLOR_APPID,
|
|
28
27
|
clientVersion:
|
|
29
28
|
isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
30
29
|
client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
|
|
31
30
|
area: '1_72_2799_0',
|
|
32
31
|
uuid: UUID,
|
|
33
32
|
},
|
|
34
33
|
public addressFetchInfo: {
|
|
35
34
|
reqState: boolean
|
|
36
35
|
promiseInstance: null | Promise<any>
|
|
37
36
|
}
|
|
38
37
|
public getPromotionConfig: {
|
|
39
38
|
projectId: null | string | number
|
|
40
39
|
pageId: null | string | number
|
|
41
40
|
}
|
|
42
41
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
43
42
|
public api: ServiceInterFace.HttpApi
|
|
44
43
|
public isPageDomain: boolean
|
|
45
44
|
constructor(opt) {
|
|
46
45
|
this._init()
|
|
47
46
|
this.addressFetchInfo = {
|
|
48
47
|
reqState: false,
|
|
49
48
|
promiseInstance: null,
|
|
50
49
|
}
|
|
51
50
|
this.getPromotionConfig = {
|
|
52
51
|
projectId: null,
|
|
53
52
|
pageId: null,
|
|
54
53
|
}
|
|
55
54
|
this._userAreaUpdateListen()
|
|
56
55
|
this.resInfo = this._getResConfig(opt)
|
|
57
56
|
this.api = api
|
|
58
57
|
this.isPageDomain = window.location.hostname === PAGES_DOMAIN
|
|
59
58
|
}
|
|
60
59
|
_init(): void {
|
|
61
60
|
httpInterceptors.forEach((item) => {
|
|
62
61
|
Taro.addInterceptor((chain) => item(chain))
|
|
63
62
|
})
|
|
64
63
|
}
|
|
65
64
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
66
65
|
return Object.assign({}, DefaultConfig, opt)
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
_userAreaUpdateListen() {
|
|
70
69
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
71
70
|
this.updateApiClientParamsResInfo({
|
|
72
71
|
area,
|
|
73
72
|
})
|
|
74
73
|
})
|
|
75
74
|
}
|
|
76
75
|
updateApiClientParamsResInfo(opt = {}) {
|
|
77
76
|
this.resInfo.apiClientParams = {
|
|
78
77
|
...this.resInfo.apiClientParams,
|
|
79
78
|
...opt,
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
_paramsSign(data) {
|
|
84
83
|
return Promise.resolve(data)
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
checkFunctionIdToReturnAppId(functionId) {
|
|
88
87
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
89
88
|
return JSHOPX_COLOR_APPID
|
|
90
89
|
} else if (
|
|
91
90
|
this.isPageDomain &&
|
|
92
91
|
PagesColorFunctionIdList.includes(functionId)
|
|
93
92
|
) {
|
|
94
93
|
return PAGES_COLOR_APPID
|
|
95
94
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
96
95
|
return B2B_COLOR_APPID
|
|
97
96
|
} else {
|
|
98
97
|
return SHOP_COLOR_APPID
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
100
|
|
|
102
101
|
gatewayReq(
|
|
103
102
|
functionId: string,
|
|
104
103
|
bodyParams = {},
|
|
105
104
|
clientParams = {},
|
|
106
105
|
): Promise<any> {
|
|
107
106
|
if (
|
|
108
107
|
functionId === 'receiveShopCoupon' &&
|
|
109
108
|
((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
|
|
110
109
|
) {
|
|
111
110
|
clientParams = Object.assign(
|
|
112
111
|
{},
|
|
113
112
|
{
|
|
114
113
|
loginType: '1',
|
|
115
114
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
116
115
|
},
|
|
117
116
|
clientParams,
|
|
118
117
|
)
|
|
119
118
|
}
|
|
120
119
|
const apiClientParams = Object.assign(
|
|
121
120
|
{},
|
|
122
121
|
this.resInfo.apiClientParams,
|
|
123
122
|
clientParams,
|
|
124
123
|
)
|
|
125
124
|
apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId)
|
|
126
125
|
const getReqData = {
|
|
127
126
|
functionId: functionId,
|
|
128
127
|
body: JSON.stringify(bodyParams),
|
|
129
128
|
t: Date.now(),
|
|
130
129
|
...apiClientParams,
|
|
131
130
|
}
|
|
132
131
|
return http
|
|
133
132
|
.request({
|
|
134
133
|
url: this.api.apiFunc,
|
|
135
134
|
data: getReqData,
|
|
136
135
|
method: 'GET',
|
|
137
136
|
})
|
|
138
137
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
139
138
|
const { statusCode, data } = res
|
|
140
139
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
141
140
|
ok: true,
|
|
142
141
|
}
|
|
143
142
|
if (statusCode === 200 && data) {
|
|
144
143
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
145
144
|
? Number(res.data.code)
|
|
146
145
|
: -1
|
|
147
146
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
148
147
|
res.data,
|
|
149
148
|
'subCode',
|
|
150
149
|
)
|
|
151
150
|
? Number(res.data.subCode)
|
|
152
151
|
: -1
|
|
153
152
|
if (
|
|
154
153
|
data.success === true ||
|
|
155
154
|
data.isSuccess ||
|
|
156
155
|
resCode === 0 ||
|
|
157
156
|
resCode === 200 ||
|
|
158
157
|
subCode === 0
|
|
159
158
|
) {
|
|
160
159
|
changeRes = {
|
|
161
160
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
162
161
|
? data.result
|
|
163
162
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
164
163
|
? data.data
|
|
165
164
|
: data,
|
|
166
165
|
code: data.code || 200,
|
|
167
166
|
ok: true,
|
|
168
167
|
source: data,
|
|
169
168
|
}
|
|
170
169
|
return changeRes
|
|
171
170
|
} else {
|
|
172
171
|
changeRes = {
|
|
173
172
|
...data,
|
|
174
173
|
ok: false,
|
|
175
174
|
statusCode: res.statusCode,
|
|
176
175
|
}
|
|
177
176
|
return changeRes
|
|
178
177
|
}
|
|
179
178
|
} else {
|
|
180
179
|
changeRes = {
|
|
181
180
|
...data,
|
|
182
181
|
ok: false,
|
|
183
182
|
statusCode: res.statusCode,
|
|
184
183
|
}
|
|
185
184
|
return changeRes
|
|
186
185
|
}
|
|
187
186
|
})
|
|
188
187
|
.catch((res) => {
|
|
189
188
|
return {
|
|
190
189
|
...res,
|
|
191
190
|
ok: false,
|
|
192
191
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
193
192
|
})
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
async receiveCoupon(param = {}, clientParams) {
|
|
197
196
|
return await this.gatewayReq(
|
|
198
197
|
'receiveShopCoupon',
|
|
199
198
|
{
|
|
200
199
|
operation: '3',
|
|
201
200
|
...param,
|
|
202
201
|
},
|
|
203
202
|
clientParams,
|
|
204
203
|
)
|
|
205
204
|
}
|
|
206
205
|
async bMallAddCart(params = {}) {
|
|
207
206
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
208
207
|
client: 'H5',
|
|
209
208
|
})
|
|
210
209
|
}
|
|
211
210
|
async bMallChangeCart(params = {}) {
|
|
212
211
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
213
212
|
client: 'H5',
|
|
214
213
|
})
|
|
215
214
|
}
|
|
216
215
|
async bMallRemoveCart(params = {}) {
|
|
217
216
|
return await this.gatewayReq(
|
|
218
217
|
'bmall_cartRemove',
|
|
219
218
|
params,
|
|
220
219
|
{
|
|
221
220
|
client: 'H5',
|
|
222
221
|
},
|
|
223
222
|
)
|
|
224
223
|
}
|
|
225
224
|
async bMallGetOmittedProduct(params = {}) {
|
|
226
225
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
227
226
|
client: 'H5',
|
|
228
227
|
})
|
|
229
228
|
}
|
|
230
229
|
async bMallAddCartService({ skuId, bMallTag, num }) {
|
|
231
230
|
const params = getParams({ skuId, bMallTag, num })
|
|
232
231
|
return await this.bMallAddCart(params)
|
|
233
232
|
}
|
|
234
233
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
235
234
|
const params = getParams({ bMallTag })
|
|
236
235
|
delete params.operations
|
|
237
236
|
return await this.bMallGetOmittedProduct(params)
|
|
238
237
|
}
|
|
239
238
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid }) {
|
|
240
239
|
let params = getParams({ skuId, bMallTag, num, skuUuid })
|
|
241
240
|
return await this.bMallRemoveCart(params)
|
|
242
241
|
}
|
|
243
242
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid }) {
|
|
244
243
|
let params = getParams({ skuId, bMallTag, num, skuUuid })
|
|
245
244
|
return await this.bMallChangeCart(params)
|
|
246
245
|
}
|
|
247
246
|
|
|
248
247
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
249
248
|
if (!needRequest && window.bMallCartData) {
|
|
250
249
|
return window.bMallCartData
|
|
251
250
|
}
|
|
252
251
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
253
252
|
let items
|
|
254
253
|
if (cartData.ok && cartData.result) {
|
|
255
254
|
items = cartData?.result?.items || {}
|
|
256
255
|
}
|
|
257
256
|
window.bMallCartData = items
|
|
258
257
|
return items
|
|
259
258
|
}
|
|
260
259
|
|
|
261
260
|
async bMallCartHandle(goodItem, num) {
|
|
262
261
|
try {
|
|
263
262
|
const {
|
|
264
263
|
skuUuid,
|
|
265
264
|
limitUpper,
|
|
266
265
|
limitLower,
|
|
267
266
|
} = goodItem
|
|
268
267
|
let cartNum = Number(num)
|
|
269
268
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
270
269
|
cartNum = limitLower
|
|
271
270
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
272
271
|
cartNum = limitUpper
|
|
273
272
|
}
|
|
274
273
|
if (skuUuid && cartNum > 0) {
|
|
275
274
|
return this.bMallChangeCartService({
|
|
276
275
|
...goodItem,
|
|
277
276
|
skuUuid,
|
|
278
277
|
num: cartNum,
|
|
279
278
|
})
|
|
280
279
|
} else if (!skuUuid && cartNum > 0) {
|
|
281
280
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
282
281
|
} else if (skuUuid && !cartNum) {
|
|
283
282
|
return this.bMallRemoveCartService({
|
|
284
283
|
...goodItem,
|
|
285
284
|
skuUuid,
|
|
286
285
|
num: cartNum,
|
|
287
286
|
})
|
|
288
287
|
} else {
|
|
289
288
|
console.error('参数不全')
|
|
290
289
|
return false
|
|
291
290
|
}
|
|
292
291
|
} catch (e) {
|
|
293
292
|
console.error(e)
|
|
294
293
|
}
|
|
295
294
|
}
|
|
295
|
+
import Taro from '@tarojs/taro'
|
|
296
296
|
SHOP_COLOR_APPID,
|
|
297
297
|
JshopxColorFunctionIdList,
|
|
298
298
|
PagesColorFunctionIdList,
|
|
299
299
|
JSHOPX_COLOR_APPID,
|
|
300
300
|
PAGES_COLOR_APPID,
|
|
301
301
|
PAGES_DOMAIN,
|
|
302
302
|
B2BColorFunctionIdList,
|
|
303
303
|
B2B_COLOR_APPID,
|
|
304
304
|
cookiesStr: '',
|
|
305
305
|
requestHeaderContentType: {
|
|
306
306
|
jsonHeader: {
|
|
307
307
|
'content-type': 'application/json;charset=utf-8',
|
|
308
308
|
},
|
|
309
309
|
formDataHeader: {
|
|
310
310
|
'content-type': 'application/x-www-form-urlencoded',
|
|
311
311
|
},
|
|
312
312
|
},
|
|
313
313
|
requestBaseParam: {
|
|
314
314
|
data: null,
|
|
315
315
|
header: {
|
|
316
316
|
'content-type': 'application/json;charset=utf-8',
|
|
317
317
|
},
|
|
318
318
|
},
|
|
319
319
|
timeOut: 7000,
|
|
320
320
|
apiClientParams: {
|
|
321
321
|
appid: SHOP_COLOR_APPID,
|
|
322
322
|
clientVersion:
|
|
323
323
|
isH5AndJdShopView && jdAppVersionStr !== '' ? jdAppVersionStr : '11.0.0',
|
|
324
324
|
client: isH5AndJdShopView ? (isIosDevice ? 'apple' : 'android') : 'wh5',
|
|
325
325
|
area: '1_72_2799_0',
|
|
326
326
|
uuid: UUID,
|
|
327
327
|
},
|
|
328
328
|
public addressFetchInfo: {
|
|
329
329
|
reqState: boolean
|
|
330
330
|
promiseInstance: null | Promise<any>
|
|
331
331
|
}
|
|
332
332
|
public getPromotionConfig: {
|
|
333
333
|
projectId: null | string | number
|
|
334
334
|
pageId: null | string | number
|
|
335
335
|
}
|
|
336
336
|
public resInfo: ServiceInterFace.HttpRequestInfo
|
|
337
337
|
public api: ServiceInterFace.HttpApi
|
|
338
338
|
public isPageDomain: boolean
|
|
339
339
|
constructor(opt) {
|
|
340
340
|
this._init()
|
|
341
341
|
this.addressFetchInfo = {
|
|
342
342
|
reqState: false,
|
|
343
343
|
promiseInstance: null,
|
|
344
344
|
}
|
|
345
345
|
this.getPromotionConfig = {
|
|
346
346
|
projectId: null,
|
|
347
347
|
pageId: null,
|
|
348
348
|
}
|
|
349
349
|
this._userAreaUpdateListen()
|
|
350
350
|
this.resInfo = this._getResConfig(opt)
|
|
351
351
|
this.api = api
|
|
352
352
|
this.isPageDomain = window.location.hostname === PAGES_DOMAIN
|
|
353
353
|
}
|
|
354
354
|
_init(): void {
|
|
355
355
|
httpInterceptors.forEach((item) => {
|
|
356
356
|
Taro.addInterceptor((chain) => item(chain))
|
|
357
357
|
})
|
|
358
358
|
}
|
|
359
359
|
_getResConfig(opt = {}): ServiceInterFace.HttpRequestInfo {
|
|
360
360
|
return Object.assign({}, DefaultConfig, opt)
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
_userAreaUpdateListen() {
|
|
364
364
|
Taro.eventCenter.on(TaroEventType.USER_AREA_UPDATE, (area) => {
|
|
365
365
|
this.updateApiClientParamsResInfo({
|
|
366
366
|
area,
|
|
367
367
|
})
|
|
368
368
|
})
|
|
369
369
|
}
|
|
370
370
|
updateApiClientParamsResInfo(opt = {}) {
|
|
371
371
|
this.resInfo.apiClientParams = {
|
|
372
372
|
...this.resInfo.apiClientParams,
|
|
373
373
|
...opt,
|
|
374
374
|
}
|
|
375
375
|
}
|
|
376
376
|
|
|
377
377
|
_paramsSign(data) {
|
|
378
378
|
return Promise.resolve(data)
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
checkFunctionIdToReturnAppId(functionId) {
|
|
382
382
|
if (JshopxColorFunctionIdList.includes(functionId)) {
|
|
383
383
|
return JSHOPX_COLOR_APPID
|
|
384
384
|
} else if (
|
|
385
385
|
this.isPageDomain &&
|
|
386
386
|
PagesColorFunctionIdList.includes(functionId)
|
|
387
387
|
) {
|
|
388
388
|
return PAGES_COLOR_APPID
|
|
389
389
|
} else if (B2BColorFunctionIdList.includes(functionId)) {
|
|
390
390
|
return B2B_COLOR_APPID
|
|
391
391
|
} else {
|
|
392
392
|
return SHOP_COLOR_APPID
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
gatewayReq(
|
|
397
397
|
functionId: string,
|
|
398
398
|
bodyParams = {},
|
|
399
399
|
clientParams = {},
|
|
400
400
|
): Promise<any> {
|
|
401
401
|
if (
|
|
402
402
|
functionId === 'receiveShopCoupon' &&
|
|
403
403
|
((isH5 && window.isJingGouMiniViewState) || isWxMinAndWxapp)
|
|
404
404
|
) {
|
|
405
405
|
clientParams = Object.assign(
|
|
406
406
|
{},
|
|
407
407
|
{
|
|
408
408
|
loginType: '1',
|
|
409
409
|
loginWQBiz: WXAPP_BIZ_KEY,
|
|
410
410
|
},
|
|
411
411
|
clientParams,
|
|
412
412
|
)
|
|
413
413
|
}
|
|
414
414
|
const apiClientParams = Object.assign(
|
|
415
415
|
{},
|
|
416
416
|
this.resInfo.apiClientParams,
|
|
417
417
|
clientParams,
|
|
418
418
|
)
|
|
419
419
|
apiClientParams.appid = this.checkFunctionIdToReturnAppId(functionId)
|
|
420
420
|
const getReqData = {
|
|
421
421
|
functionId: functionId,
|
|
422
422
|
body: JSON.stringify(bodyParams),
|
|
423
423
|
t: Date.now(),
|
|
424
424
|
...apiClientParams,
|
|
425
425
|
}
|
|
426
426
|
return http
|
|
427
427
|
.request({
|
|
428
428
|
url: this.api.apiFunc,
|
|
429
429
|
data: getReqData,
|
|
430
430
|
method: 'GET',
|
|
431
431
|
})
|
|
432
432
|
.then((res: ServiceInterFace.RequestPromiseRes) => {
|
|
433
433
|
const { statusCode, data } = res
|
|
434
434
|
let changeRes: ServiceInterFace.RequestResponseFormatRes = {
|
|
435
435
|
ok: true,
|
|
436
436
|
}
|
|
437
437
|
if (statusCode === 200 && data) {
|
|
438
438
|
const resCode = Object.prototype.hasOwnProperty.call(res.data, 'code')
|
|
439
439
|
? Number(res.data.code)
|
|
440
440
|
: -1
|
|
441
441
|
const subCode = Object.prototype.hasOwnProperty.call(
|
|
442
442
|
res.data,
|
|
443
443
|
'subCode',
|
|
444
444
|
)
|
|
445
445
|
? Number(res.data.subCode)
|
|
446
446
|
: -1
|
|
447
447
|
if (
|
|
448
448
|
data.success === true ||
|
|
449
449
|
data.isSuccess ||
|
|
450
450
|
resCode === 0 ||
|
|
451
451
|
resCode === 200 ||
|
|
452
452
|
subCode === 0
|
|
453
453
|
) {
|
|
454
454
|
changeRes = {
|
|
455
455
|
result: Object.prototype.hasOwnProperty.call(data, 'result')
|
|
456
456
|
? data.result
|
|
457
457
|
: Object.prototype.hasOwnProperty.call(data, 'data')
|
|
458
458
|
? data.data
|
|
459
459
|
: data,
|
|
460
460
|
code: data.code || 200,
|
|
461
461
|
ok: true,
|
|
462
462
|
source: data,
|
|
463
463
|
}
|
|
464
464
|
return changeRes
|
|
465
465
|
} else {
|
|
466
466
|
changeRes = {
|
|
467
467
|
...data,
|
|
468
468
|
ok: false,
|
|
469
469
|
statusCode: res.statusCode,
|
|
470
470
|
}
|
|
471
471
|
return changeRes
|
|
472
472
|
}
|
|
473
473
|
} else {
|
|
474
474
|
changeRes = {
|
|
475
475
|
...data,
|
|
476
476
|
ok: false,
|
|
477
477
|
statusCode: res.statusCode,
|
|
478
478
|
}
|
|
479
479
|
return changeRes
|
|
480
480
|
}
|
|
481
481
|
})
|
|
482
482
|
.catch((res) => {
|
|
483
483
|
return {
|
|
484
484
|
...res,
|
|
485
485
|
ok: false,
|
|
486
486
|
} as ServiceInterFace.RequestResponseFormatRes
|
|
487
487
|
})
|
|
488
488
|
}
|
|
489
489
|
|
|
490
490
|
async receiveCoupon(param = {}, clientParams) {
|
|
491
491
|
return await this.gatewayReq(
|
|
492
492
|
'receiveShopCoupon',
|
|
493
493
|
{
|
|
494
494
|
operation: '3',
|
|
495
495
|
...param,
|
|
496
496
|
},
|
|
497
497
|
clientParams,
|
|
498
498
|
)
|
|
499
499
|
}
|
|
500
500
|
bMallGetUserInfo = () => {
|
|
501
501
|
return userInfo
|
|
502
502
|
}
|
|
503
503
|
async bMallAddCart(params = {}) {
|
|
504
504
|
return await this.gatewayReq('bmall_cartAdd', params, {
|
|
505
505
|
client: 'H5',
|
|
506
506
|
})
|
|
507
507
|
}
|
|
508
508
|
async bMallChangeCart(params = {}) {
|
|
509
509
|
return await this.gatewayReq('bmall_cartChange', params, {
|
|
510
510
|
client: 'H5',
|
|
511
511
|
})
|
|
512
512
|
}
|
|
513
513
|
async bMallRemoveCart(params = {}) {
|
|
514
514
|
return await this.gatewayReq(
|
|
515
515
|
'bmall_cartRemove',
|
|
516
516
|
params,
|
|
517
517
|
{
|
|
518
518
|
client: 'H5',
|
|
519
519
|
},
|
|
520
520
|
)
|
|
521
521
|
}
|
|
522
522
|
async bMallGetOmittedProduct(params = {}) {
|
|
523
523
|
return await this.gatewayReq('bmall_getOmittedProduct', params, {
|
|
524
524
|
client: 'H5',
|
|
525
525
|
})
|
|
526
526
|
}
|
|
527
527
|
async bMallAddCartService({ skuId, bMallTag, num }) {
|
|
528
528
|
const params = getParams({ skuId, bMallTag, num })
|
|
529
529
|
return await this.bMallAddCart(params)
|
|
530
530
|
}
|
|
531
531
|
async bMallGetSkuNumService(bMallTag = 1) {
|
|
532
532
|
const params = getParams({ bMallTag })
|
|
533
533
|
delete params.operations
|
|
534
534
|
return await this.bMallGetOmittedProduct(params)
|
|
535
535
|
}
|
|
536
536
|
async bMallRemoveCartService({ skuId, bMallTag, num, skuUuid }) {
|
|
537
537
|
let params = getParams({ skuId, bMallTag, num, skuUuid })
|
|
538
538
|
return await this.bMallRemoveCart(params)
|
|
539
539
|
}
|
|
540
540
|
async bMallChangeCartService({ skuId, bMallTag, num, skuUuid }) {
|
|
541
541
|
let params = getParams({ skuId, bMallTag, num, skuUuid })
|
|
542
542
|
return await this.bMallChangeCart(params)
|
|
543
543
|
}
|
|
544
544
|
|
|
545
545
|
async bMallGetSkuNumApi(needRequest = false, bMallTag = 1) {
|
|
546
546
|
if (!needRequest && window.bMallCartData) {
|
|
547
547
|
return window.bMallCartData
|
|
548
548
|
}
|
|
549
549
|
const cartData = await this.bMallGetSkuNumService(bMallTag)
|
|
550
550
|
let items
|
|
551
551
|
if (cartData.ok && cartData.result) {
|
|
552
552
|
items = cartData?.result?.items || {}
|
|
553
553
|
}
|
|
554
554
|
window.bMallCartData = items
|
|
555
555
|
return items
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
async bMallCartHandle(goodItem, num) {
|
|
559
559
|
try {
|
|
560
560
|
const {
|
|
561
561
|
skuUuid,
|
|
562
562
|
limitUpper,
|
|
563
563
|
limitLower,
|
|
564
564
|
} = goodItem
|
|
565
565
|
let cartNum = Number(num)
|
|
566
566
|
if (limitLower && cartNum && cartNum < limitLower) {
|
|
567
567
|
cartNum = limitLower
|
|
568
568
|
} else if (limitUpper && cartNum && cartNum > limitUpper) {
|
|
569
569
|
cartNum = limitUpper
|
|
570
570
|
}
|
|
571
571
|
if (skuUuid && cartNum > 0) {
|
|
572
572
|
return this.bMallChangeCartService({
|
|
573
573
|
...goodItem,
|
|
574
574
|
skuUuid,
|
|
575
575
|
num: cartNum,
|
|
576
576
|
})
|
|
577
577
|
} else if (!skuUuid && cartNum > 0) {
|
|
578
578
|
return this.bMallAddCartService({ ...goodItem, num: cartNum })
|
|
579
579
|
} else if (skuUuid && !cartNum) {
|
|
580
580
|
return this.bMallRemoveCartService({
|
|
581
581
|
...goodItem,
|
|
582
582
|
skuUuid,
|
|
583
583
|
num: cartNum,
|
|
584
584
|
})
|
|
585
585
|
} else {
|
|
586
586
|
console.error('参数不全')
|
|
587
587
|
return false
|
|
588
588
|
}
|
|
589
589
|
} catch (e) {
|
|
590
590
|
console.error(e)
|
|
591
591
|
}
|
|
592
592
|
}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const userInfo =
|
|
2
|
(window.WebViewCommon && window.WebViewCommon.getUserInfo()) || '{}'
|
|
3
1
|
buId: JSON.parse(userInfo)?.data?.buId,
|
|
4
2
|
process.env.NODE_ENV === 'development'
|
|
5
3
|
? {
|
|
6
4
|
apolloId: '48ee955b0fb04d19b9f9fe8cb73d387f',
|
|
7
5
|
apolloSecret: '0d9c76ee66b0487da4e17d3cf1d7af7a',
|
|
8
6
|
}
|
|
9
7
|
: {
|
|
10
8
|
apolloId: '80c46fd06e4442998609d9f6a4ab96f0',
|
|
11
9
|
apolloSecret: 'f36bef08bcba4683b409732095793fb2',
|
|
12
10
|
}
|
|
13
11
|
if (typeof window.crypto === 'object') {
|
|
14
12
|
if (typeof (window.crypto as any).randomUUID === 'function') {
|
|
15
13
|
return (window.crypto as any).randomUUID()
|
|
16
14
|
}
|
|
17
15
|
if (
|
|
18
16
|
typeof (window.crypto as any).getRandomValues === 'function' &&
|
|
19
17
|
typeof Uint8Array === 'function'
|
|
20
18
|
) {
|
|
21
19
|
const callback = (c) => {
|
|
22
20
|
const num = Number(c)
|
|
23
21
|
return (
|
|
24
22
|
num ^
|
|
25
23
|
((window.crypto as any).getRandomValues(new Uint8Array(1))[0] &
|
|
26
24
|
(15 >> (num / 4)))
|
|
27
25
|
).toString(16)
|
|
28
26
|
}
|
|
29
27
|
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, callback)
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
let timestamp = new Date().getTime()
|
|
33
31
|
let perforNow =
|
|
34
32
|
(typeof window.performance !== 'undefined' &&
|
|
35
33
|
window.performance.now &&
|
|
36
34
|
window.performance.now() * 1000) ||
|
|
37
35
|
0
|
|
38
36
|
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
|
39
37
|
let random = Math.random() * 16
|
|
40
38
|
if (timestamp > 0) {
|
|
41
39
|
random = (timestamp + random) % 16 | 0
|
|
42
40
|
timestamp = Math.floor(timestamp / 16)
|
|
43
41
|
} else {
|
|
44
42
|
random = (perforNow + random) % 16 | 0
|
|
45
43
|
perforNow = Math.floor(perforNow / 16)
|
|
46
44
|
}
|
|
47
45
|
return (c === 'x' ? random : (random & 0x3) | 0x8).toString(16)
|
|
48
46
|
})
|
|
49
47
|
let params = {
|
|
50
48
|
uniformBizInfo: {
|
|
51
49
|
tenantId: 1024,
|
|
52
50
|
ua: 1,
|
|
53
51
|
buId: commonParam.buId || 377,
|
|
54
52
|
bMallTag: bMallTag,
|
|
55
53
|
},
|
|
56
54
|
commonParam: {
|
|
57
55
|
pid: 100,
|
|
58
56
|
verticalCode: 'cn_retail_bmall',
|
|
59
57
|
ua: 1,
|
|
60
58
|
language: 'zh',
|
|
61
59
|
},
|
|
62
60
|
operations: [{ TheSkus: [{ Id: skuId, num: num || 1 }] }],
|
|
63
61
|
apolloId: APOLLO.apolloId,
|
|
64
62
|
apolloSecret: APOLLO.apolloSecret,
|
|
65
63
|
client: 'H5',
|
|
66
64
|
verticalTag: 'cn_retail_bmall',
|
|
67
65
|
carttype: bMallTag == 1 ? 21 : 22,
|
|
68
66
|
bMallTag: bMallTag,
|
|
69
67
|
traceId: getUuid(),
|
|
70
68
|
noResponse: true,
|
|
71
69
|
}
|
|
72
70
|
if (skuUuid) {
|
|
73
71
|
params.operations[0].TheSkus[0].skuUuid = skuUuid
|
|
74
72
|
}
|
|
75
73
|
if (window?.siteTransResult?.gridInfoList) {
|
|
76
74
|
params = {
|
|
77
75
|
...params,
|
|
78
76
|
cartLocationList: [
|
|
79
77
|
{
|
|
80
78
|
gridInfos:
|
|
81
79
|
window?.siteTransResult?.gridInfoList &&
|
|
82
80
|
JSON.parse(window?.siteTransResult?.gridInfoList),
|
|
83
81
|
areaIdSet:
|
|
84
82
|
window?.siteTransResult?.area &&
|
|
85
83
|
window?.siteTransResult?.area?.split('-'),
|
|
86
84
|
},
|
|
87
85
|
],
|
|
88
86
|
}
|
|
89
87
|
}
|
|
90
88
|
return params
|