@conecli/cone-render 0.9.1-shop2.3 → 0.9.1-shop2.30
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 +1 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
package/dist/common/index.h5.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
urlCookie
|
|
3
2
|
public config: {
|
|
4
3
|
[key: string]: any
|
|
5
4
|
}
|
|
6
5
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
7
6
|
this.config = {}
|
|
8
7
|
...info,
|
|
9
8
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
10
9
|
if(isPc) {
|
|
11
10
|
getFullUrl = getFullUrl.replace(/returnurl/,'ReturnUrl')
|
|
12
11
|
}
|
|
13
12
|
pin: cookie.get('pin') || ''
|
|
14
13
|
})
|
|
15
14
|
if(!this.checkStatusAndLoginPromise){
|
|
16
15
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
17
16
|
try {
|
|
18
17
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
19
18
|
if(getLoginState){
|
|
20
19
|
resolve(true)
|
|
21
20
|
}else {
|
|
22
21
|
this.toLogin(options)
|
|
23
22
|
reject(false)
|
|
24
23
|
}
|
|
25
24
|
}catch (e) {
|
|
26
25
|
this.toLogin(options)
|
|
27
26
|
reject(false)
|
|
28
27
|
}
|
|
29
28
|
})
|
|
30
29
|
return this.checkStatusAndLoginPromise
|
|
31
30
|
}else {
|
|
32
31
|
return this.checkStatusAndLoginPromise.then(() => {
|
|
33
32
|
return Promise.resolve(true)
|
|
34
33
|
}).catch (() => {
|
|
35
34
|
this.toLogin(options)
|
|
36
35
|
return Promise.reject(true)
|
|
37
36
|
})
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
doCheckLoginStateAndForApiCheck() {
|
|
41
40
|
if(this.info.loginState){
|
|
42
41
|
return Promise.resolve(true)
|
|
43
42
|
}else {
|
|
44
43
|
return new Promise((resolve, reject) => {
|
|
45
44
|
if(this.info.isJingGouMiniViewState){
|
|
46
45
|
const getWqAuthToken = cookie.get("wq_auth_token")
|
|
47
46
|
if(getWqAuthToken){
|
|
48
47
|
this.info.loginState = true
|
|
49
48
|
resolve(true)
|
|
50
49
|
}else {
|
|
51
50
|
reject(false)
|
|
52
51
|
}
|
|
53
52
|
}else{
|
|
54
53
|
Taro.request({
|
|
55
54
|
url: api.isLogin,
|
|
56
55
|
jsonp:true,
|
|
57
56
|
timeout: 3000,
|
|
58
57
|
success: (res) => {
|
|
59
58
|
const {statusCode,data} = res
|
|
60
59
|
if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
|
|
61
60
|
this.info.loginState = true
|
|
62
61
|
resolve(true);
|
|
63
62
|
} else {
|
|
64
63
|
reject(false)
|
|
65
64
|
}
|
|
66
65
|
},
|
|
67
66
|
fail:(err) => {
|
|
68
67
|
console.log("登录检查异常", err)
|
|
69
68
|
reject(false)
|
|
70
69
|
}
|
|
71
70
|
})
|
|
72
71
|
}
|
|
73
72
|
})
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
try {
|
|
78
77
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
79
78
|
if(getLoginState){
|
|
80
79
|
const { pin } = await this.getLoginCookie();
|
|
81
80
|
this.info.userInfo = {
|
|
82
81
|
pin,
|
|
83
82
|
encodePin: encodeURIComponent(pin),
|
|
84
83
|
ptkey: '',
|
|
85
84
|
}
|
|
86
85
|
resolve(true)
|
|
87
86
|
}else {
|
|
88
87
|
reject(false)
|
|
89
88
|
}
|
|
90
89
|
}catch (e) {
|
|
91
90
|
reject(false)
|
|
92
91
|
}
|
|
93
92
|
})
|
|
94
93
|
const changeArea = un_area && un_area.length > 0 ? un_area : (ipLoc_djd ? ipLoc_djd : '')
|
|
95
94
|
if(changeArea){
|
|
96
95
|
this.info.pageInfo.address = changeArea
|
|
97
96
|
this.info.pageInfo.un_area = changeArea
|
|
98
97
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
99
98
|
}
|
|
99
|
+
import Taro from '@tarojs/taro'
|
|
100
100
|
isIosDevice,
|
|
101
101
|
isAndroidDevice,
|
|
102
102
|
isJdAndHarmonyDevice,
|
|
103
103
|
isJdAndAndroidDevice,
|
|
104
104
|
jdAppVersion,
|
|
105
105
|
jdAppVersionStr,
|
|
106
106
|
isString,
|
|
107
107
|
isObject,
|
|
108
108
|
serialize,
|
|
109
109
|
dealNativePixelToCssPixel,
|
|
110
110
|
isPc,
|
|
111
111
|
BUSINESS_TYPE,
|
|
112
112
|
JSSDK_APP_WEBVIEW_CODE,
|
|
113
113
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
114
114
|
SECTION_HOME_TAB_TYPE,
|
|
115
115
|
WXAPP_BIZ_KEY,
|
|
116
116
|
WX_BUSINESS_TYPE,
|
|
117
117
|
MPAAS_CONFIG_APP_VERSION,
|
|
118
118
|
MPAAS_CONFIG_APP_LOW_VERSION,
|
|
119
119
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
120
120
|
LoadJsInitLoadEnvType,
|
|
121
121
|
LoadJsInitLoadType,
|
|
122
122
|
LoadJsInitTriggerType
|
|
123
123
|
loginState: false,
|
|
124
124
|
cookiesStr: '',
|
|
125
125
|
userInfo: userPinKey,
|
|
126
126
|
isJingGouMiniViewState: false,
|
|
127
127
|
isJingxiMiniViewState: false,
|
|
128
128
|
pageInfo: {
|
|
129
129
|
wxBusinessType: WX_BUSINESS_TYPE.NO,
|
|
130
130
|
address: '',
|
|
131
131
|
addressCommaStr: '',
|
|
132
132
|
un_area: '',
|
|
133
133
|
vapptype: '1',
|
|
134
134
|
pageType: 'home',
|
|
135
135
|
isExposureState: false,
|
|
136
136
|
moduleId: '',
|
|
137
137
|
entrance: '',
|
|
138
138
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
139
139
|
floorExposureInfo: {},
|
|
140
140
|
floorVideInfo: {},
|
|
141
141
|
productVideInfo: {},
|
|
142
142
|
tabsLoadAllDataInfo: {
|
|
143
143
|
[SECTION_HOME_TAB_NAME_TYPE[
|
|
144
144
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
145
145
|
]]: false,
|
|
146
146
|
},
|
|
147
147
|
updateShopInfosAllState: false,
|
|
148
148
|
isVipShop: false,
|
|
149
149
|
isJdShowNativeImmersivePlayer: false,
|
|
150
150
|
...shopConfig,
|
|
151
151
|
pageScrollTop: 0,
|
|
152
152
|
pageIdxHeightInfo: {
|
|
153
153
|
list: [],
|
|
154
154
|
},
|
|
155
155
|
shopNavBarHeight: 0,
|
|
156
156
|
},
|
|
157
157
|
defaultQueryLogInfo: {
|
|
158
158
|
sourceType: 'JDshop',
|
|
159
159
|
sourceValue: '',
|
|
160
160
|
moduleId: 'none',
|
|
161
161
|
entrance: 'none',
|
|
162
162
|
},
|
|
163
163
|
sysInfo: {
|
|
164
164
|
windowWidth: isPc ? 375 : 0,
|
|
165
165
|
containerWidth: isPc ? 375 : 0,
|
|
166
166
|
windowHeight: 0,
|
|
167
167
|
netWorkType: '4g',
|
|
168
168
|
jdBottomBarHeight: 0,
|
|
169
169
|
jdNativeHeaderHeight: 0,
|
|
170
170
|
},
|
|
171
171
|
queryInfo: {},
|
|
172
172
|
shopInfo: {},
|
|
173
173
|
openAppData: {},
|
|
174
174
|
public info: CommonInterFace.BaseConfigInfo
|
|
175
175
|
public config: {
|
|
176
176
|
[key: string]: any
|
|
177
177
|
}
|
|
178
178
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
179
179
|
public renderedIsvComponents: CommonInterFace.renderedIsvComponents
|
|
180
180
|
public rootEleNode: HTMLElement | null
|
|
181
181
|
public checkStatusAndLoginPromise: object | null
|
|
182
182
|
private jmfeRegisterStatePromise: Promise<any> | null
|
|
183
183
|
private jmfeRegisterState: boolean
|
|
184
184
|
public loadJsSdkList: Array<any>
|
|
185
185
|
public loadJsSdkListCachePromise: any
|
|
186
186
|
constructor(opt) {
|
|
187
187
|
this.info = this._getConfig(opt)
|
|
188
188
|
this.config = {}
|
|
189
189
|
this.loadJsSdkList = []
|
|
190
190
|
this.loadJsSdkListCachePromise = {}
|
|
191
191
|
this.lazyContainer = {
|
|
192
192
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
193
193
|
appLazyContainerList: [],
|
|
194
194
|
appLazyFinishContainerList: [],
|
|
195
195
|
},
|
|
196
196
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
197
197
|
appLazyContainerList: [],
|
|
198
198
|
appLazyFinishContainerList: [],
|
|
199
199
|
},
|
|
200
200
|
}
|
|
201
201
|
this.renderedIsvComponents = {}
|
|
202
202
|
this.rootEleNode = document.querySelector('body')
|
|
203
203
|
this.checkStatusAndLoginPromise = null
|
|
204
204
|
this.jmfeRegisterStatePromise = null
|
|
205
205
|
this.loadOtherSdk()
|
|
206
206
|
isJdApp && this.jmfeReayPromise()
|
|
207
207
|
}
|
|
208
208
|
_getConfig(opt) {
|
|
209
209
|
return Object.assign({}, DefaultConfig, opt)
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
jmfeReayPromise(): Promise<any> {
|
|
213
213
|
if (isJdApp) {
|
|
214
214
|
if (this.jmfeRegisterState) {
|
|
215
215
|
return Promise.resolve(true)
|
|
216
216
|
} else {
|
|
217
217
|
!this.jmfeRegisterStatePromise &&
|
|
218
218
|
(this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
|
|
219
219
|
ready('jmfe', 3000)
|
|
220
220
|
.then(() => {
|
|
221
221
|
window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE)
|
|
222
222
|
this.jmfeRegisterState = true
|
|
223
223
|
resolve(true)
|
|
224
224
|
console.log('松果app内初始化注册jmfe认证完成')
|
|
225
225
|
})
|
|
226
226
|
.catch((err) => {
|
|
227
227
|
console.error('jmfe ready error', err)
|
|
228
228
|
reject(false)
|
|
229
229
|
})
|
|
230
230
|
}))
|
|
231
231
|
return this.jmfeRegisterStatePromise
|
|
232
232
|
}
|
|
233
233
|
} else {
|
|
234
234
|
return Promise.reject(false)
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
updateBusinessDomainAndApi(domain, api) {
|
|
239
239
|
}
|
|
240
240
|
|
|
241
241
|
formatNativeScreenPageData(action) {
|
|
242
242
|
let getChangePageInfo: any = null
|
|
243
243
|
try {
|
|
244
244
|
const getNativeScreenPageInfoStr = window.XWebView?._callNative(
|
|
245
245
|
JSON.stringify({
|
|
246
246
|
plugin: 'JDHybridScreenPlugin',
|
|
247
247
|
action,
|
|
248
248
|
sync: '1',
|
|
249
249
|
}),
|
|
250
250
|
)
|
|
251
251
|
const getChangePageInfoData =
|
|
252
252
|
typeof getNativeScreenPageInfoStr === 'string'
|
|
253
253
|
? JSON.parse(getNativeScreenPageInfoStr)
|
|
254
254
|
: null
|
|
255
255
|
if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
|
|
256
256
|
const { code, data } = getChangePageInfoData
|
|
257
257
|
getChangePageInfo = code && code === '0' ? data : null
|
|
258
258
|
}
|
|
259
259
|
} catch (e) {
|
|
260
260
|
console.log('JDHybridScreenPlugin转换异常', e)
|
|
261
261
|
}
|
|
262
262
|
return getChangePageInfo
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
isAndroidFoldScreen() {
|
|
266
266
|
return this.formatNativeScreenPageData('isFoldScreen') === '1'
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
getJdAndroidPageChangeScreenInfo() {
|
|
270
270
|
const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize')
|
|
271
271
|
if (
|
|
272
272
|
getPageScreenInfo &&
|
|
273
273
|
getPageScreenInfo?.pageWidth &&
|
|
274
274
|
getPageScreenInfo?.pageHeight
|
|
275
275
|
) {
|
|
276
276
|
const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
|
|
277
277
|
pageWidth: getPageScreenInfo.pageWidth,
|
|
278
278
|
pageHeight: getPageScreenInfo.pageHeight,
|
|
279
279
|
})
|
|
280
280
|
getPageScreenInfo.pageWidth = pageWidth
|
|
281
281
|
getPageScreenInfo.pageHeight = pageHeight
|
|
282
282
|
}
|
|
283
283
|
return getPageScreenInfo
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
getSystemInfo(params) {
|
|
287
287
|
let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
|
|
288
288
|
? {}
|
|
289
289
|
: getSystemInfos(params)
|
|
290
290
|
if (isJdAndAndroidDevice && info?.initWindowWidth <= 0) {
|
|
291
291
|
let _isfoldScreen = false
|
|
292
292
|
const getStorageData = getTaroStorageKeyValue("jd_shopx_androidIsFoldScreen")
|
|
293
293
|
console.info("获取当前本地存储是否有jd_shopx_androidIsFoldScreen", getStorageData,"通过缓存值第一次判断是否是折叠屏", getStorageData === 'true')
|
|
294
294
|
if(!getStorageData){
|
|
295
295
|
_isfoldScreen = this.isAndroidFoldScreen()
|
|
296
296
|
setTaroStorage("jd_shopx_androidIsFoldScreen", `${_isfoldScreen}`)
|
|
297
297
|
}else {
|
|
298
298
|
_isfoldScreen = getStorageData === 'true'
|
|
299
299
|
}
|
|
300
300
|
if (_isfoldScreen) {
|
|
301
301
|
const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo()
|
|
302
302
|
if(getJdAndroidPageInfo){
|
|
303
303
|
info = getSystemInfos(getJdAndroidPageInfo)
|
|
304
304
|
console.warn("当前为松果安卓折叠屏app,获取折叠屏信息",getJdAndroidPageInfo,"获取转换后的系统信息",info)
|
|
305
305
|
sgmCustomReport({
|
|
306
306
|
type: 2,
|
|
307
307
|
code: 'android_jdapp_foldScreen_info',
|
|
308
308
|
msg: {
|
|
309
309
|
title: `松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异`,
|
|
310
310
|
androidPageInfo: getJdAndroidPageInfo,
|
|
311
311
|
jdAppVersionStr,
|
|
312
312
|
taroSysInfo: info
|
|
313
313
|
}
|
|
314
314
|
})
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
this.info.sysInfo = {
|
|
319
319
|
actualNavBarHeight: 0,
|
|
320
320
|
...this.info.sysInfo,
|
|
321
321
|
...info,
|
|
322
322
|
safeContentHeight: info?.screenHeight,
|
|
323
323
|
headerHeight: 0,
|
|
324
324
|
tabBarHeight: 0,
|
|
325
325
|
}
|
|
326
326
|
if (isJdApp) {
|
|
327
327
|
this.info.sysInfo['hostVersionName'] = jdAppVersionStr
|
|
328
328
|
this.info.sysInfo['hostAppVersion'] = jdAppVersion
|
|
329
329
|
this.getAddressCachePromise()
|
|
330
330
|
this.getElderModePromise()
|
|
331
331
|
this.getJDAppearanceStatePromise()
|
|
332
332
|
this.createJdAndroidRquestEventForTouchStart()
|
|
333
333
|
}
|
|
334
334
|
this.getWifiVideoAutoPlayAsync()
|
|
335
335
|
this.getMPaasConfigAsync()
|
|
336
336
|
this.getNetWorkType()
|
|
337
337
|
}
|
|
338
338
|
|
|
339
339
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
340
340
|
return new Promise(resolve => {
|
|
341
341
|
setTimeout(() => {
|
|
342
342
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
343
343
|
return resolve(getCallBackRes || false)
|
|
344
344
|
}, timeout)
|
|
345
345
|
})
|
|
346
346
|
}
|
|
347
347
|
|
|
348
348
|
getElderModePromise() {
|
|
349
349
|
if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
|
|
350
350
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
351
351
|
} else {
|
|
352
352
|
if (isJdAndAndroidDevice) {
|
|
353
353
|
this.info.sysInfo.jdAppModeType = '0'
|
|
354
354
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
355
355
|
} else {
|
|
356
356
|
return Promise.race([
|
|
357
357
|
this.taskTimeoutPromise(() => {
|
|
358
358
|
this.info.sysInfo.jdAppModeType = '0'
|
|
359
359
|
return this.info.sysInfo.jdAppModeType
|
|
360
360
|
}),
|
|
361
361
|
new Promise(resolve => {
|
|
362
362
|
const getCallBackName = `getJdCurrentModeType${Date.now()}`
|
|
363
363
|
if (!window[getCallBackName]) {
|
|
364
364
|
window[getCallBackName] = res => {
|
|
365
365
|
try {
|
|
366
366
|
const getResJson =
|
|
367
367
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
368
368
|
const { status, data, msg } = getResJson
|
|
369
369
|
console.log(`获取松果app展示模式成功,返回结果${data}`)
|
|
370
370
|
if (status === '0') {
|
|
371
371
|
this.info.sysInfo.jdAppModeType = data
|
|
372
372
|
resolve(data)
|
|
373
373
|
} else {
|
|
374
374
|
resolve('0')
|
|
375
375
|
}
|
|
376
376
|
} catch (e) {
|
|
377
377
|
resolve('0')
|
|
378
378
|
}
|
|
379
379
|
window[getCallBackName] = null
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
383
383
|
method: 'callSyncRouterModuleWithParams',
|
|
384
384
|
params: JSON.stringify({
|
|
385
385
|
routerURL: 'router://JDBModeModule/getCurrentMode',
|
|
386
386
|
routerParam: {},
|
|
387
387
|
callBackName: `window.${getCallBackName}`,
|
|
388
388
|
callBackId: `${getCallBackName}Ios`,
|
|
389
389
|
}),
|
|
390
390
|
})
|
|
391
391
|
}),
|
|
392
392
|
])
|
|
393
393
|
}
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
396
|
getAPPUseStraightCorner() {
|
|
397
397
|
const routerURL = 'router://JDBaseUtilsModule/isUI14Enable'
|
|
398
398
|
const params = {
|
|
399
399
|
routerURL,
|
|
400
400
|
routerParam: {},
|
|
401
401
|
jdRouter: '1',
|
|
402
402
|
}
|
|
403
403
|
if (this.info.sysInfo.hasOwnProperty('jdStraightCorner')) {
|
|
404
404
|
return Promise.resolve(this.info.sysInfo.jdStraightCorner)
|
|
405
405
|
} else {
|
|
406
406
|
return this.jmfeReayPromise()
|
|
407
407
|
.then(() => {
|
|
408
408
|
if(isJdAndHarmonyDevice || !isJdApp) {
|
|
409
409
|
console.log('not APP or is Harmony')
|
|
410
410
|
return Promise.resolve(false)
|
|
411
411
|
}
|
|
412
412
|
console.log('jmfe setShareInfo', params)
|
|
413
413
|
return Promise.race([window.jmfe.callRouter(params), this.taskTimeoutPromise(() => {return false})])
|
|
414
414
|
.then(({ status, data }) => {
|
|
415
415
|
console.log('004 ~ file: index.tsx:133 ~ .then ~ data:', data)
|
|
416
416
|
console.log('004 ~ file: index.tsx:133 ~ .then ~ status:', status)
|
|
417
417
|
this.info.sysInfo.jdStraightCorner = status === '0' && Number(data) === 1
|
|
418
418
|
return Promise.resolve( status === '0' && Number(data) === 1)
|
|
419
419
|
})
|
|
420
420
|
})
|
|
421
421
|
.catch(e => {
|
|
422
422
|
console.log('jmfe error', e)
|
|
423
423
|
return Promise.resolve(false)
|
|
424
424
|
})
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
|
|
428
428
|
getJDAppearanceStatePromise() {
|
|
429
429
|
if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
|
|
430
430
|
return Promise.resolve(this.info.sysInfo.jdAppearanceState)
|
|
431
431
|
} else {
|
|
432
432
|
return Promise.race([
|
|
433
433
|
this.taskTimeoutPromise(() => {
|
|
434
434
|
this.info.sysInfo.jdAppearanceState = '0'
|
|
435
435
|
return this.info.sysInfo.jdAppearanceState
|
|
436
436
|
}),
|
|
437
437
|
new Promise(resolve => {
|
|
438
438
|
const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`
|
|
439
439
|
if (!window[getCallBackName]) {
|
|
440
440
|
window[getCallBackName] = res => {
|
|
441
441
|
try {
|
|
442
442
|
console.log('getJDAppearanceStatePromise', res)
|
|
443
443
|
const getResJson =
|
|
444
444
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
445
445
|
const { status, data, msg } = getResJson
|
|
446
446
|
console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`)
|
|
447
447
|
if (status === '0') {
|
|
448
448
|
this.info.sysInfo.jdAppearanceState = data
|
|
449
449
|
resolve(data)
|
|
450
450
|
} else {
|
|
451
451
|
resolve('0')
|
|
452
452
|
}
|
|
453
453
|
} catch (e) {
|
|
454
454
|
resolve('0')
|
|
455
455
|
}
|
|
456
456
|
window[getCallBackName] = null
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
if (isAndroidDevice) {
|
|
460
460
|
const jsonString = JSON.stringify({
|
|
461
461
|
callBackName: `window.${getCallBackName}`,
|
|
462
462
|
})
|
|
463
463
|
console.log('window.JDAppearance', window.JDAppearance)
|
|
464
464
|
window.JDAppearance && window.JDAppearance.getUiState(jsonString)
|
|
465
465
|
} else {
|
|
466
466
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
467
467
|
method: 'callSyncRouterModuleWithParams',
|
|
468
468
|
params: JSON.stringify({
|
|
469
469
|
routerURL:
|
|
470
470
|
'router://JDWebViewBusinessModule/getJDAppearanceState',
|
|
471
471
|
routerParam: {},
|
|
472
472
|
callBackName: `window.${getCallBackName}`,
|
|
473
473
|
callBackId: `${getCallBackName}Ios`,
|
|
474
474
|
}),
|
|
475
475
|
})
|
|
476
476
|
}
|
|
477
477
|
}),
|
|
478
478
|
])
|
|
479
479
|
}
|
|
480
480
|
}
|
|
481
481
|
|
|
482
482
|
createJdAndroidRquestEventForTouchStart() {
|
|
483
483
|
if (isJdAndAndroidDevice && window.JdAndroid) {
|
|
484
484
|
const rootEleNode = document.querySelector('body')
|
|
485
485
|
if (rootEleNode) {
|
|
486
486
|
rootEleNode.addEventListener(
|
|
487
487
|
'touchstart',
|
|
488
488
|
this.jdAndroidAddEventListenerTouchStart,
|
|
489
489
|
false,
|
|
490
490
|
)
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
494
|
jdAndroidAddEventListenerTouchStart(e) {
|
|
495
495
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom')
|
|
496
496
|
if (!isH5SwiperCustomEle) {
|
|
497
497
|
const hasCustomEle = e
|
|
498
498
|
? e?.target?.closest('.J_customScroll') ||
|
|
499
499
|
e?.target?.closest('.J_customLayout')
|
|
500
500
|
: false
|
|
501
501
|
if (!hasCustomEle) {
|
|
502
502
|
window.JdAndroid.requestEvent(false)
|
|
503
503
|
console.log(
|
|
504
504
|
'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
|
|
505
505
|
)
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
}
|
|
509
509
|
removeJdAndroidRquestEventForTouchStart() {
|
|
510
510
|
if (isJdAndAndroidDevice && window.JdAndroid) {
|
|
511
511
|
const rootEleNode = document.querySelector('body')
|
|
512
512
|
if (rootEleNode) {
|
|
513
513
|
rootEleNode.removeEventListener(
|
|
514
514
|
'touchstart',
|
|
515
515
|
this.jdAndroidAddEventListenerTouchStart,
|
|
516
516
|
false,
|
|
517
517
|
)
|
|
518
518
|
}
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
getNetWorkType() {
|
|
523
523
|
if (isJdApp) {
|
|
524
524
|
this.jmfeReayPromise().then(() => {
|
|
525
525
|
window.jmfe
|
|
526
526
|
.getNetworkStatus()
|
|
527
527
|
.then(({ status, data }) => {
|
|
528
528
|
console.log(
|
|
529
529
|
'在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====',
|
|
530
530
|
data,
|
|
531
531
|
)
|
|
532
532
|
if (status === '0') {
|
|
533
533
|
this.info.sysInfo['netWorkType'] = data
|
|
534
534
|
} else {
|
|
535
535
|
this._taroGetNetworkType()
|
|
536
536
|
}
|
|
537
537
|
})
|
|
538
538
|
.catch(err => {
|
|
539
539
|
console.log('在app内初始化通过jmfe对象获取网络状态异常====', err)
|
|
540
540
|
this._taroGetNetworkType()
|
|
541
541
|
})
|
|
542
542
|
})
|
|
543
543
|
} else {
|
|
544
544
|
this._taroGetNetworkType()
|
|
545
545
|
}
|
|
546
546
|
}
|
|
547
547
|
_taroGetNetworkType() {
|
|
548
548
|
Taro.getNetworkType().then(getRes => {
|
|
549
549
|
if (getRes && getRes.networkType) {
|
|
550
550
|
this.info.sysInfo['netWorkType'] = getRes.networkType
|
|
551
551
|
console.log(
|
|
552
552
|
'在app内通过taro对象获取网络状态完成,当前网络状态',
|
|
553
553
|
this.info.sysInfo['netWorkType'],
|
|
554
554
|
)
|
|
555
555
|
}
|
|
556
556
|
})
|
|
557
557
|
}
|
|
558
558
|
getCacheAddressRouter() {
|
|
559
559
|
if (!window.jmfe) return
|
|
560
560
|
if (isAndroidDevice) {
|
|
561
561
|
return window.jmfe.callRouter({
|
|
562
562
|
jdRouter: '1',
|
|
563
563
|
routerURL: 'router://JDAddressModule/getCacheAddress',
|
|
564
564
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
565
565
|
})
|
|
566
566
|
} else if (isIosDevice) {
|
|
567
567
|
return window.jmfe.callRouter({
|
|
568
568
|
jdRouter: '1',
|
|
569
569
|
routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
|
|
570
570
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
571
571
|
})
|
|
572
572
|
} else if (isJdAndHarmonyDevice) {
|
|
573
573
|
return new Promise(resolve => {
|
|
574
574
|
resolve({})
|
|
575
575
|
})
|
|
576
576
|
} else {
|
|
577
577
|
throw Error(
|
|
578
578
|
'Unknown device type cannot obtain the address information through the route!',
|
|
579
579
|
)
|
|
580
580
|
}
|
|
581
581
|
}
|
|
582
582
|
|
|
583
583
|
getAddressCachePromise() {
|
|
584
584
|
return new Promise(resolve => {
|
|
585
585
|
if (
|
|
586
586
|
this?.info?.sysInfo?.lat &&
|
|
587
587
|
this?.info?.sysInfo?.lng &&
|
|
588
588
|
this?.info?.sysInfo?.area
|
|
589
589
|
) {
|
|
590
590
|
resolve({
|
|
591
591
|
lat: this.info.sysInfo.lat,
|
|
592
592
|
lng: this.info.sysInfo.lng,
|
|
593
593
|
area: this?.info?.sysInfo?.area,
|
|
594
594
|
})
|
|
595
595
|
} else {
|
|
596
596
|
this.jmfeReayPromise().then(() => {
|
|
597
597
|
this.getCacheAddressRouter()
|
|
598
598
|
.then(({ status, data }) => {
|
|
599
599
|
console.log("原生端获取经纬度原始数据结果",status,data)
|
|
600
600
|
if (status === '0' && data) {
|
|
601
601
|
const {
|
|
602
602
|
lat,
|
|
603
603
|
latitude,
|
|
604
604
|
lng,
|
|
605
605
|
longitude,
|
|
606
606
|
provinceId,
|
|
607
607
|
cityId,
|
|
608
608
|
countyId,
|
|
609
609
|
townId,
|
|
610
610
|
} = data || {}
|
|
611
611
|
let area = ''
|
|
612
612
|
this.info.sysInfo['lat'] = `${lat || latitude || ''}`
|
|
613
613
|
this.info.sysInfo['lng'] = `${lng || longitude || ''}`
|
|
614
614
|
if (provinceId) {
|
|
615
615
|
area = `${provinceId}_${cityId || 0}_${countyId ||
|
|
616
616
|
0}_${townId || 0}`
|
|
617
617
|
this.info.pageInfo['address'] = area
|
|
618
618
|
this.info.pageInfo['addressCommaStr'] = area.replace(
|
|
619
619
|
/_/g,
|
|
620
620
|
',',
|
|
621
621
|
)
|
|
622
622
|
}
|
|
623
623
|
resolve({
|
|
624
624
|
lat: this.info.sysInfo['lat'],
|
|
625
625
|
lng: this.info.sysInfo['lng'],
|
|
626
626
|
area: area,
|
|
627
627
|
})
|
|
628
628
|
} else {
|
|
629
629
|
resolve({ lat: '', lng: '', area: '' })
|
|
630
630
|
}
|
|
631
631
|
})
|
|
632
632
|
.catch(e => {
|
|
633
633
|
console.log(' ~~ file: index.h5.ts:518 ~~ .catch ~~ e:', e)
|
|
634
634
|
resolve({ lat: '', lng: '', area: '' })
|
|
635
635
|
console.log('getCacheAddressRouter catch e,获取经纬度信息异常e', e)
|
|
636
636
|
})
|
|
637
637
|
}).catch(e => {
|
|
638
638
|
resolve({ lat: '', lng: '', area: '' })
|
|
639
639
|
console.log('判断jmfe不存在,获取经纬度信息异常e', e)
|
|
640
640
|
})
|
|
641
641
|
}
|
|
642
642
|
})
|
|
643
643
|
}
|
|
644
644
|
|
|
645
645
|
async updateMPaasConfigAsync(isBeforePageReady: boolean) {
|
|
646
646
|
console.log("updateMPaasConfigAsync isBeforePageReady:", isBeforePageReady)
|
|
647
647
|
if (!isJdApp) {
|
|
648
648
|
return
|
|
649
649
|
}
|
|
650
650
|
const avifSwitch = await getMPaasConfigByBussinessKey(
|
|
651
651
|
'avifSwitch',
|
|
652
652
|
isBeforePageReady,
|
|
653
653
|
)
|
|
654
654
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch
|
|
655
655
|
const hybridHttpSwitch = await getMPaasConfigByBussinessKey(
|
|
656
656
|
'hybridHttpSwitch',
|
|
657
657
|
isBeforePageReady,
|
|
658
658
|
)
|
|
659
659
|
this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = hybridHttpSwitch
|
|
660
660
|
const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
|
|
661
661
|
'isFollowAppVideoPlayStatus',
|
|
662
662
|
isBeforePageReady,
|
|
663
663
|
)
|
|
664
664
|
console.log(
|
|
665
665
|
'isBeforePageReady:',
|
|
666
666
|
isBeforePageReady,
|
|
667
667
|
'isFollowAppVideoPlayStatus:',
|
|
668
668
|
isFollowAppVideoPlayStatus,
|
|
669
669
|
)
|
|
670
670
|
if (
|
|
671
671
|
isFollowAppVideoPlayStatus === true ||
|
|
672
672
|
isFollowAppVideoPlayStatus === 'true'
|
|
673
673
|
) {
|
|
674
674
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true
|
|
675
675
|
}
|
|
676
676
|
}
|
|
677
677
|
|
|
678
678
|
async getWifiVideoAutoPlayAsync() {
|
|
679
679
|
this.info.sysInfo['wifiVideoAutoPlay'] = false
|
|
680
680
|
if (!isJdApp) {
|
|
681
681
|
return
|
|
682
682
|
}
|
|
683
683
|
const videoPlayStatus = await getWifiVideoAutoPlay().catch(e => {
|
|
684
684
|
return 0
|
|
685
685
|
})
|
|
686
686
|
if (Number(videoPlayStatus) === 1) {
|
|
687
687
|
this.info.sysInfo['wifiVideoAutoPlay'] = true
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
690
|
|
|
691
691
|
async getMPaasConfigAsync() {
|
|
692
692
|
this.info.sysInfo.dynamicConfig = {}
|
|
693
693
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = {}
|
|
694
694
|
this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = {}
|
|
695
695
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false
|
|
696
696
|
return this.updateMPaasConfigAsync(true)
|
|
697
697
|
}
|
|
698
698
|
|
|
699
699
|
getDynamicConfig(key: string){
|
|
700
700
|
return this.info.sysInfo.dynamicConfig[key]
|
|
701
701
|
}
|
|
702
702
|
async updateMPaasConfig() {
|
|
703
703
|
console.log('updateMPaasConfig')
|
|
704
704
|
if (
|
|
705
705
|
isIosDevice &&
|
|
706
706
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
|
|
707
707
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
|
|
708
708
|
) {
|
|
709
709
|
try {
|
|
710
710
|
await this.updateMPaasConfigAsync(false)
|
|
711
711
|
} catch (e) {
|
|
712
712
|
console.log('updateMPaasConfigAsync:', e)
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
716
|
|
|
717
717
|
toLogin(options) {
|
|
718
718
|
return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
|
|
719
719
|
? this.toWxAppLogin(options)
|
|
720
720
|
: this.toWebLogin(options)
|
|
721
721
|
}
|
|
722
722
|
|
|
723
723
|
doLogin(options) {
|
|
724
724
|
return this.toLogin(options)
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
doLoginForJdPin(options = {}) {
|
|
728
728
|
return this.doLogin({
|
|
729
729
|
loginColor: {
|
|
730
730
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
731
731
|
dpin: 0,
|
|
732
732
|
},
|
|
733
733
|
...options,
|
|
734
734
|
})
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
toWebLogin(options) {
|
|
738
738
|
let params: {
|
|
739
739
|
returnurl: string
|
|
740
740
|
} = {
|
|
741
741
|
returnurl: '',
|
|
742
742
|
}
|
|
743
743
|
const loginUrl = isPc
|
|
744
744
|
? `//passport.jd.com/new/login.aspx`
|
|
745
745
|
: `${domain.mobileLogin}/user/login.action`
|
|
746
746
|
const defaultParams = {
|
|
747
747
|
appid: '100',
|
|
748
748
|
returnurl: window.location.href,
|
|
749
749
|
}
|
|
750
750
|
if (isString(options)) {
|
|
751
751
|
params = Object.assign({}, defaultParams, {
|
|
752
752
|
returnurl: options,
|
|
753
753
|
})
|
|
754
754
|
} else if (isObject(options)) {
|
|
755
755
|
const { loginColor, ...otherOptions } = options
|
|
756
756
|
params = Object.assign({}, defaultParams, otherOptions)
|
|
757
757
|
} else {
|
|
758
758
|
params = defaultParams
|
|
759
759
|
}
|
|
760
760
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
761
761
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
762
762
|
if (isPc) {
|
|
763
763
|
getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
|
|
764
764
|
}
|
|
765
765
|
return Promise.resolve({
|
|
766
766
|
h5ToUrl: true,
|
|
767
767
|
url: getFullUrl,
|
|
768
768
|
}).then(() => {
|
|
769
769
|
window.location.href = getFullUrl
|
|
770
770
|
})
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
toWxAppLogin(options = {}) {
|
|
774
774
|
console.log('微信京购小程序中h5登录跳转', options)
|
|
775
775
|
return Promise.resolve(true).then(() => {
|
|
776
776
|
const { loginColor } = Object.assign(
|
|
777
777
|
{},
|
|
778
778
|
{
|
|
779
779
|
loginColor: {
|
|
780
780
|
biz: WXAPP_BIZ_KEY,
|
|
781
781
|
dpin: 1,
|
|
782
782
|
},
|
|
783
783
|
},
|
|
784
784
|
options,
|
|
785
785
|
)
|
|
786
786
|
window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
|
|
787
787
|
loginColor.biz
|
|
788
788
|
}&url=${encodeURIComponent(window.location.href)}`
|
|
789
789
|
})
|
|
790
790
|
}
|
|
791
791
|
|
|
792
792
|
getLoginCookie() {
|
|
793
793
|
return Promise.resolve({
|
|
794
794
|
pin: cookie.get('pin') || '',
|
|
795
795
|
})
|
|
796
796
|
}
|
|
797
797
|
|
|
798
798
|
clearLoginCookie() {
|
|
799
799
|
cookie.remove('pin')
|
|
800
800
|
}
|
|
801
801
|
|
|
802
802
|
checkStatusAndLogin(options = {}) {
|
|
803
803
|
if (!this.checkStatusAndLoginPromise) {
|
|
804
804
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
805
805
|
try {
|
|
806
806
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(
|
|
807
807
|
options,
|
|
808
808
|
)
|
|
809
809
|
if (getLoginState) {
|
|
810
810
|
resolve(true)
|
|
811
811
|
} else {
|
|
812
812
|
this.toLogin(options)
|
|
813
813
|
reject(false)
|
|
814
814
|
}
|
|
815
815
|
} catch (e) {
|
|
816
816
|
this.toLogin(options)
|
|
817
817
|
reject(false)
|
|
818
818
|
}
|
|
819
819
|
})
|
|
820
820
|
return this.checkStatusAndLoginPromise
|
|
821
821
|
} else {
|
|
822
822
|
return this.checkStatusAndLoginPromise
|
|
823
823
|
.then(() => {
|
|
824
824
|
return Promise.resolve(true)
|
|
825
825
|
})
|
|
826
826
|
.catch(() => {
|
|
827
827
|
this.toLogin(options)
|
|
828
828
|
return Promise.reject(true)
|
|
829
829
|
})
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
|
|
833
833
|
checkJdStatusAndLogin(
|
|
834
834
|
options = {
|
|
835
835
|
loginColor: {
|
|
836
836
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
837
837
|
dpin: 0,
|
|
838
838
|
},
|
|
839
839
|
},
|
|
840
840
|
) {
|
|
841
841
|
return this.checkStatusAndLogin(options)
|
|
842
842
|
}
|
|
843
843
|
|
|
844
844
|
doCheckLoginStateAndForApiCheck(options) {
|
|
845
845
|
if (this.info.loginState) {
|
|
846
846
|
return Promise.resolve(true)
|
|
847
847
|
} else {
|
|
848
848
|
return new Promise((resolve, reject) => {
|
|
849
849
|
if (
|
|
850
850
|
this.info.isJingGouMiniViewState ||
|
|
851
851
|
this.info.isJingxiMiniViewState
|
|
852
852
|
) {
|
|
853
853
|
const getWqAuthToken = cookie.get('wq_auth_token')
|
|
854
854
|
const getWqSkey = cookie.get('wq_skey')
|
|
855
855
|
const getWqUin = cookie.get('wq_uin')
|
|
856
856
|
const isLoginState =
|
|
857
857
|
options?.loginColor?.dpin === 0
|
|
858
858
|
? getWqAuthToken
|
|
859
859
|
: getWqSkey && getWqUin
|
|
860
860
|
if (isLoginState) {
|
|
861
861
|
this.info.loginState = true
|
|
862
862
|
resolve(true)
|
|
863
863
|
} else {
|
|
864
864
|
reject(false)
|
|
865
865
|
}
|
|
866
866
|
} else {
|
|
867
867
|
Taro.request({
|
|
868
868
|
url: api.isLogin,
|
|
869
869
|
jsonp: true,
|
|
870
870
|
timeout: 3000,
|
|
871
871
|
success: res => {
|
|
872
872
|
const { statusCode, data } = res
|
|
873
873
|
if (
|
|
874
874
|
statusCode === 200 &&
|
|
875
875
|
data?.islogin &&
|
|
876
876
|
Number(data.islogin) === 1
|
|
877
877
|
) {
|
|
878
878
|
this.info.loginState = true
|
|
879
879
|
resolve(true)
|
|
880
880
|
} else {
|
|
881
881
|
reject(false)
|
|
882
882
|
}
|
|
883
883
|
},
|
|
884
884
|
fail: err => {
|
|
885
885
|
console.log('登录检查异常', err)
|
|
886
886
|
reject(false)
|
|
887
887
|
},
|
|
888
888
|
})
|
|
889
889
|
}
|
|
890
890
|
})
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
893
|
|
|
894
894
|
checkLoginStatus(options) {
|
|
895
895
|
return new Promise(async (resolve, reject) => {
|
|
896
896
|
try {
|
|
897
897
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(
|
|
898
898
|
options,
|
|
899
899
|
)
|
|
900
900
|
if (getLoginState) {
|
|
901
901
|
const { pin } = await this.getLoginCookie()
|
|
902
902
|
this.info.userInfo = {
|
|
903
903
|
pin,
|
|
904
904
|
encodePin: encodeURIComponent(pin),
|
|
905
905
|
ptkey: '',
|
|
906
906
|
}
|
|
907
907
|
resolve(true)
|
|
908
908
|
} else {
|
|
909
909
|
reject(false)
|
|
910
910
|
}
|
|
911
911
|
} catch (e) {
|
|
912
912
|
reject(false)
|
|
913
913
|
}
|
|
914
914
|
})
|
|
915
915
|
}
|
|
916
916
|
|
|
917
917
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
918
918
|
const createUpdateQueryInfo: {
|
|
919
919
|
query: {
|
|
920
920
|
shopId?: string | number
|
|
921
921
|
venderId?: string | number
|
|
922
922
|
}
|
|
923
923
|
updateShopInfoState: boolean
|
|
924
924
|
} = Object.assign(
|
|
925
925
|
{},
|
|
926
926
|
{
|
|
927
927
|
query: {},
|
|
928
928
|
updateShopInfoState: false,
|
|
929
929
|
},
|
|
930
930
|
updateQuery,
|
|
931
931
|
)
|
|
932
932
|
console.log(
|
|
933
933
|
'获取当前下发的店铺查询参数',
|
|
934
934
|
updateQuery,
|
|
935
935
|
'获取之前保存的shopInfo店铺查询参数',
|
|
936
936
|
this.info?.shopInfo,
|
|
937
937
|
)
|
|
938
938
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
939
939
|
const { shopId, venderId, un_area } = query
|
|
940
940
|
if (updateShopInfoState) {
|
|
941
941
|
this.info.queryInfo = {
|
|
942
942
|
...this.info.queryInfo,
|
|
943
943
|
...query,
|
|
944
944
|
}
|
|
945
945
|
if (shopId && venderId) {
|
|
946
946
|
this.info.shopInfo = {
|
|
947
947
|
shopId: `${shopId}`,
|
|
948
948
|
venderId: `${venderId}`,
|
|
949
949
|
}
|
|
950
950
|
}
|
|
951
951
|
} else {
|
|
952
952
|
this.info.queryInfo = {
|
|
953
953
|
...query,
|
|
954
954
|
}
|
|
955
955
|
if (
|
|
956
956
|
this.info.shopInfo?.shopId &&
|
|
957
957
|
this.info.shopInfo?.venderId &&
|
|
958
958
|
(this.info.shopInfo.shopId == shopId ||
|
|
959
959
|
this.info.shopInfo.venderId == venderId)
|
|
960
960
|
) {
|
|
961
961
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
962
962
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
963
963
|
console.log(
|
|
964
964
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
965
965
|
this.info.queryInfo,
|
|
966
966
|
)
|
|
967
967
|
}
|
|
968
968
|
}
|
|
969
969
|
this.info.queryInfo['shopId'] &&
|
|
970
970
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
971
971
|
this.info.queryInfo['venderId'] &&
|
|
972
972
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
973
973
|
console.log(
|
|
974
974
|
'h5==获取店铺下发查询参数\n',
|
|
975
975
|
query,
|
|
976
976
|
'\n获取店铺最后查询参数\n',
|
|
977
977
|
this.info.queryInfo,
|
|
978
978
|
'\n是否为更新店铺状态\n',
|
|
979
979
|
updateShopInfoState,
|
|
980
980
|
)
|
|
981
981
|
const changeArea =
|
|
982
982
|
un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
|
|
983
983
|
if (changeArea) {
|
|
984
984
|
this.info.pageInfo.address = changeArea
|
|
985
985
|
this.info.pageInfo.un_area = changeArea
|
|
986
986
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
987
987
|
}
|
|
988
988
|
}
|
|
989
989
|
|
|
990
990
|
dealLoadSdkList(){
|
|
991
991
|
const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
|
|
992
992
|
const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? []
|
|
993
993
|
const concatLoadJsList = [].concat(globalLoadJsList,businessLoadJsList)
|
|
994
994
|
let mergeLoadJsList = globalLoadJsList
|
|
995
995
|
try {
|
|
996
996
|
mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
|
|
997
997
|
const getFindIndex = accArr.findIndex(item => item?.fileName === current?.fileName);
|
|
998
998
|
getFindIndex !== -1 ? (accArr[getFindIndex] = {...accArr[getFindIndex],...current }) : accArr.push(current);
|
|
999
999
|
return accArr;
|
|
1000
1000
|
}, []);
|
|
1001
1001
|
}catch (e) {
|
|
1002
1002
|
console.log("LoadJsList合并错误", e)
|
|
1003
1003
|
}
|
|
1004
1004
|
console.log("globalLoadJsList",globalLoadJsList,"businessLoadJsList",businessLoadJsList,"两个加载jsList集合合并完成", mergeLoadJsList)
|
|
1005
1005
|
this.loadJsSdkList = mergeLoadJsList
|
|
1006
1006
|
return this.loadJsSdkList
|
|
1007
1007
|
}
|
|
1008
1008
|
|
|
1009
1009
|
renderNextTickLoadSdk(){
|
|
1010
1010
|
Taro.nextTick(() => {
|
|
1011
1011
|
console.log("页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======")
|
|
1012
1012
|
setTimeout(() => {
|
|
1013
1013
|
this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK,this.loadJsSdkList)
|
|
1014
1014
|
},1000)
|
|
1015
1015
|
})
|
|
1016
1016
|
}
|
|
1017
1017
|
|
|
1018
1018
|
loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW,loadJsList:any[] = [] ) {
|
|
1019
1019
|
const getLoadJsList = Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList()
|
|
1020
1020
|
const getLoadFilterList = getLoadJsList.filter(item => {
|
|
1021
1021
|
const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL
|
|
1022
1022
|
let getLoastLoadEventState = true
|
|
1023
1023
|
if(getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP){
|
|
1024
1024
|
getLoastLoadEventState = isJdApp
|
|
1025
1025
|
}
|
|
1026
1026
|
else if(getInitLoadEnvType === LoadJsInitLoadEnvType.M){
|
|
1027
1027
|
getLoastLoadEventState = !isJdApp
|
|
1028
1028
|
}
|
|
1029
1029
|
const getInitTriggerType = isJdApp && item?.initJdAppTriggerType ? item?.initTriggerType : item?.initTriggerType || LoadJsInitTriggerType.NOW
|
|
1030
1030
|
const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false
|
|
1031
1031
|
return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay
|
|
1032
1032
|
})
|
|
1033
1033
|
console.log("获取当前触发方式",triggerType,"获取当前最后加载的js集合",getLoadFilterList,"过滤前的加载集合",getLoadJsList)
|
|
1034
1034
|
getLoadFilterList.length > 0 && getLoadFilterList.forEach((item) => {
|
|
1035
1035
|
const isLoadState = /sgm/.test(item?.fileName) ? window?.shopGlobalSwitch?.openSgm === "true" : true
|
|
1036
1036
|
isLoadState && this.loadItemSdkPromise(item)
|
|
1037
1037
|
.then((res) => {
|
|
1038
1038
|
console.info('当前js地址' + item?.src, '加载状态', res)
|
|
1039
1039
|
const isFileNameNewDraSdkJs = res?.fileName === 'newDraSdkJs'
|
|
1040
1040
|
if (isFileNameNewDraSdkJs && window?.dra?.run) {
|
|
1041
1041
|
window.dra.run('init', { aid: res?.aid })
|
|
1042
1042
|
window.dra.run('start')
|
|
1043
1043
|
}
|
|
1044
1044
|
})
|
|
1045
1045
|
.catch((err) => {
|
|
1046
1046
|
console.info('当前js地址加载异常', item?.src)
|
|
1047
1047
|
window?.fetchErrorData &&
|
|
1048
1048
|
window.fetchErrorData({
|
|
1049
1049
|
title: '公共js加载异常',
|
|
1050
1050
|
type: "jsLoad",
|
|
1051
1051
|
data: err,
|
|
1052
1052
|
})
|
|
1053
1053
|
})
|
|
1054
1054
|
})
|
|
1055
1055
|
}
|
|
1056
1056
|
loadScriptEle(jsInfo,resolve,reject){
|
|
1057
1057
|
const getFileName = jsInfo?.fileName;
|
|
1058
1058
|
if(getFileName){
|
|
1059
1059
|
const getEleId = `J_loadJs_${getFileName}`
|
|
1060
1060
|
const getEle = document.getElementById(getEleId)
|
|
1061
1061
|
if (!getEle) {
|
|
1062
1062
|
const jsLoadErrorSgmCode = `jsLoadError_${
|
|
1063
1063
|
jsInfo?.fileName || 'customJs'
|
|
1064
1064
|
}`
|
|
1065
1065
|
const _sgmEle = document.createElement('script')
|
|
1066
1066
|
_sgmEle.id = getEleId
|
|
1067
1067
|
_sgmEle.onload = function () {
|
|
1068
1068
|
resolve({
|
|
1069
1069
|
...jsInfo,
|
|
1070
1070
|
jsTip: "js加载成功",
|
|
1071
1071
|
})
|
|
1072
1072
|
}
|
|
1073
1073
|
_sgmEle.onerror = function () {
|
|
1074
1074
|
reject({
|
|
1075
1075
|
...jsInfo,
|
|
1076
1076
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1077
1077
|
jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
|
|
1078
1078
|
})
|
|
1079
1079
|
}
|
|
1080
1080
|
const dataAttrList = ['timeout','fileName',"env"]
|
|
1081
1081
|
const getJsInfoKeyList = Object.keys(jsInfo)
|
|
1082
1082
|
getJsInfoKeyList.forEach(key => {
|
|
1083
1083
|
if(key === "async"){
|
|
1084
1084
|
_sgmEle.async = jsInfo[key]
|
|
1085
1085
|
}else if(key === "crossOrigin"){
|
|
1086
1086
|
_sgmEle.crossOrigin = jsInfo[key]
|
|
1087
1087
|
}else if(key === "src"){
|
|
1088
1088
|
_sgmEle.src = `${jsInfo[key]}`
|
|
1089
1089
|
}else if(dataAttrList.includes(key) || /init/.test(key)) {
|
|
1090
1090
|
_sgmEle.setAttribute(`data-${key}`, jsInfo[key])
|
|
1091
1091
|
}else {
|
|
1092
1092
|
_sgmEle.setAttribute(key, jsInfo[key])
|
|
1093
1093
|
}
|
|
1094
1094
|
})
|
|
1095
1095
|
document.head.appendChild(_sgmEle)
|
|
1096
1096
|
}else {
|
|
1097
1097
|
console.log(`当前${jsInfo?.fileName || "js"}已经存在页面中,可以直接调用相关方法`,jsInfo)
|
|
1098
1098
|
resolve({
|
|
1099
1099
|
...jsInfo,
|
|
1100
1100
|
jsTip: "js本身已存在页面中",
|
|
1101
1101
|
})
|
|
1102
1102
|
}
|
|
1103
1103
|
}else {
|
|
1104
1104
|
console.warn("当前js资源信息缺少必要的参数fileName,请关注",jsInfo)
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
1107
|
|
|
1108
1108
|
loadItemSdkPromise(jsInfo = {}){
|
|
1109
1109
|
if(jsInfo?.src){
|
|
1110
1110
|
const getInitLoadType = isJdApp && jsInfo?.initJdAppLoadType ? jsInfo?.initJdAppLoadType : jsInfo?.initLoadType || LoadJsInitLoadType.ALL
|
|
1111
1111
|
if(getInitLoadType !== LoadJsInitLoadType.NONE){
|
|
1112
1112
|
const getFileKeyName = jsInfo?.fileName || jsInfo?.src
|
|
1113
1113
|
if (!this.loadJsSdkListCachePromise[getFileKeyName]){
|
|
1114
1114
|
if(getInitLoadType !== LoadJsInitLoadType.INSERT_ELE){
|
|
1115
1115
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
|
|
1116
1116
|
const jsLoadErrorSgmCode = `jsLoadError_${
|
|
1117
1117
|
jsInfo?.fileName || 'customJs'
|
|
1118
1118
|
}`
|
|
1119
1119
|
try {
|
|
1120
1120
|
const jsXhrRequest = new XMLHttpRequest();
|
|
1121
1121
|
jsXhrRequest.timeout = jsInfo?.timeout ?? 2000
|
|
1122
1122
|
const jsUrl = `${jsInfo?.src}`
|
|
1123
1123
|
jsXhrRequest.open('GET', jsUrl, true);
|
|
1124
1124
|
jsXhrRequest.onreadystatechange = () => {
|
|
1125
1125
|
if (jsXhrRequest.readyState === 4){
|
|
1126
1126
|
const getReqStatus = jsXhrRequest.status
|
|
1127
1127
|
if (getReqStatus >= 200 && getReqStatus < 300 || getReqStatus === 304){
|
|
1128
1128
|
const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL
|
|
1129
1129
|
if(getInsetHeadState){
|
|
1130
1130
|
this.loadScriptEle(jsInfo,resolve,reject)
|
|
1131
1131
|
}else {
|
|
1132
1132
|
resolve({
|
|
1133
1133
|
...jsInfo,
|
|
1134
1134
|
jsTip: "js请求成功,暂未插入head节点,业务自行单独插入",
|
|
1135
1135
|
})
|
|
1136
1136
|
}
|
|
1137
1137
|
getReqStatus !== 200 && sgmCustomReport({
|
|
1138
1138
|
type: 3,
|
|
1139
1139
|
code: "js_load_special_code",
|
|
1140
1140
|
msg: {
|
|
1141
1141
|
msg: "当前js加载成功,状态非200,特殊上报观察",
|
|
1142
1142
|
jsReqState: getReqStatus,
|
|
1143
1143
|
env: getSgmCustomCode("js_load_special_code"),
|
|
1144
1144
|
data: jsInfo
|
|
1145
1145
|
}
|
|
1146
1146
|
})
|
|
1147
1147
|
}else {
|
|
1148
1148
|
const getRes = {
|
|
1149
1149
|
...jsInfo,
|
|
1150
1150
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1151
1151
|
jsReqError: `请求状态异常,状态码为${getReqStatus}`,
|
|
1152
1152
|
jsReqState: getReqStatus,
|
|
1153
1153
|
}
|
|
1154
1154
|
console.log("当前js请求状态异常,具体信息见", getRes)
|
|
1155
1155
|
reject(getRes)
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
1158
|
};
|
|
1159
1159
|
jsXhrRequest.onerror = () => {
|
|
1160
1160
|
const getRes = {
|
|
1161
1161
|
...jsInfo,
|
|
1162
1162
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1163
1163
|
jsReqError: '请求错误',
|
|
1164
1164
|
}
|
|
1165
1165
|
console.log("当前js请求错误", getRes)
|
|
1166
1166
|
jsXhrRequest.abort()
|
|
1167
1167
|
reject(getRes)
|
|
1168
1168
|
}
|
|
1169
1169
|
jsXhrRequest.ontimeout = () => {
|
|
1170
1170
|
const getRes = {
|
|
1171
1171
|
...jsInfo,
|
|
1172
1172
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1173
1173
|
jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
|
|
1174
1174
|
jsReqState: jsXhrRequest.status,
|
|
1175
1175
|
}
|
|
1176
1176
|
console.log("当前js请求超时异常", getRes)
|
|
1177
1177
|
jsXhrRequest.abort()
|
|
1178
1178
|
reject(getRes)
|
|
1179
1179
|
}
|
|
1180
1180
|
jsXhrRequest.send();
|
|
1181
1181
|
}catch (e) {
|
|
1182
1182
|
console.log("执行js请求异常",e)
|
|
1183
1183
|
reject({
|
|
1184
1184
|
...jsInfo,
|
|
1185
1185
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1186
1186
|
jsReqError: '未知异常',
|
|
1187
1187
|
error: e,
|
|
1188
1188
|
})
|
|
1189
1189
|
}
|
|
1190
1190
|
})
|
|
1191
1191
|
}else {
|
|
1192
1192
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
|
|
1193
1193
|
return this.loadScriptEle(jsInfo,resolve,reject)
|
|
1194
1194
|
})
|
|
1195
1195
|
}
|
|
1196
1196
|
}
|
|
1197
1197
|
return this.loadJsSdkListCachePromise[getFileKeyName]
|
|
1198
1198
|
}else {
|
|
1199
1199
|
return Promise.resolve({
|
|
1200
1200
|
...jsInfo,
|
|
1201
1201
|
jsTip: "js加载方式设置为不加载,当前不做处理",
|
|
1202
1202
|
})
|
|
1203
1203
|
}
|
|
1204
1204
|
}else {
|
|
1205
1205
|
return Promise.reject(jsInfo)
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|