@conecli/cone-render 0.9.1-shop2.2 → 0.9.1-shop2.20
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/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/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/Double/index.tsx +1 -1
- package/dist/components/base/Price/index.tsx +1 -1
- 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/const.ts +1 -1
- 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(() => {
|
|
227
227
|
reject(false)
|
|
228
228
|
})
|
|
229
229
|
}))
|
|
230
230
|
return this.jmfeRegisterStatePromise
|
|
231
231
|
}
|
|
232
232
|
} else {
|
|
233
233
|
return Promise.reject(false)
|
|
234
234
|
}
|
|
235
235
|
}
|
|
236
236
|
|
|
237
237
|
updateBusinessDomainAndApi(domain, api) {
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
formatNativeScreenPageData(action) {
|
|
241
241
|
let getChangePageInfo: any = null
|
|
242
242
|
try {
|
|
243
243
|
const getNativeScreenPageInfoStr = window.XWebView?._callNative(
|
|
244
244
|
JSON.stringify({
|
|
245
245
|
plugin: 'JDHybridScreenPlugin',
|
|
246
246
|
action,
|
|
247
247
|
sync: '1',
|
|
248
248
|
}),
|
|
249
249
|
)
|
|
250
250
|
const getChangePageInfoData =
|
|
251
251
|
typeof getNativeScreenPageInfoStr === 'string'
|
|
252
252
|
? JSON.parse(getNativeScreenPageInfoStr)
|
|
253
253
|
: null
|
|
254
254
|
if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
|
|
255
255
|
const { code, data } = getChangePageInfoData
|
|
256
256
|
getChangePageInfo = code && code === '0' ? data : null
|
|
257
257
|
}
|
|
258
258
|
} catch (e) {
|
|
259
259
|
console.log('JDHybridScreenPlugin转换异常', e)
|
|
260
260
|
}
|
|
261
261
|
return getChangePageInfo
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
isAndroidFoldScreen() {
|
|
265
265
|
return this.formatNativeScreenPageData('isFoldScreen') === '1'
|
|
266
266
|
}
|
|
267
267
|
|
|
268
268
|
getJdAndroidPageChangeScreenInfo() {
|
|
269
269
|
const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize')
|
|
270
270
|
if (
|
|
271
271
|
getPageScreenInfo &&
|
|
272
272
|
getPageScreenInfo?.pageWidth &&
|
|
273
273
|
getPageScreenInfo?.pageHeight
|
|
274
274
|
) {
|
|
275
275
|
const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
|
|
276
276
|
pageWidth: getPageScreenInfo.pageWidth,
|
|
277
277
|
pageHeight: getPageScreenInfo.pageHeight,
|
|
278
278
|
})
|
|
279
279
|
getPageScreenInfo.pageWidth = pageWidth
|
|
280
280
|
getPageScreenInfo.pageHeight = pageHeight
|
|
281
281
|
}
|
|
282
282
|
return getPageScreenInfo
|
|
283
283
|
}
|
|
284
284
|
|
|
285
285
|
getSystemInfo(params) {
|
|
286
286
|
let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
|
|
287
287
|
? {}
|
|
288
288
|
: getSystemInfos(params)
|
|
289
289
|
if (isJdAndAndroidDevice && window.innerWidth <= 0) {
|
|
290
290
|
const isfoldScreen = this.isAndroidFoldScreen()
|
|
291
291
|
if (isfoldScreen) {
|
|
292
292
|
const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo()
|
|
293
293
|
getJdAndroidPageInfo && (info = getSystemInfos(getJdAndroidPageInfo))
|
|
294
294
|
console.info(
|
|
295
295
|
'安卓松果app折叠屏获取webview宽度为0,那么通过内部方法重置获取',
|
|
296
296
|
getJdAndroidPageInfo,
|
|
297
297
|
)
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
this.info.sysInfo = {
|
|
301
301
|
actualNavBarHeight: 0,
|
|
302
302
|
...this.info.sysInfo,
|
|
303
303
|
...info,
|
|
304
304
|
safeContentHeight: info?.screenHeight,
|
|
305
305
|
headerHeight: 0,
|
|
306
306
|
tabBarHeight: 0,
|
|
307
307
|
}
|
|
308
308
|
if (isJdApp) {
|
|
309
309
|
this.info.sysInfo['hostVersionName'] = jdAppVersionStr
|
|
310
310
|
this.info.sysInfo['hostAppVersion'] = jdAppVersion
|
|
311
311
|
this.getAddressCachePromise()
|
|
312
312
|
this.getElderModePromise()
|
|
313
313
|
this.getJDAppearanceStatePromise()
|
|
314
314
|
this.createJdAndroidRquestEventForTouchStart()
|
|
315
315
|
}
|
|
316
316
|
this.getWifiVideoAutoPlayAsync()
|
|
317
317
|
this.getMPaasConfigAsync()
|
|
318
318
|
this.getNetWorkType()
|
|
319
319
|
}
|
|
320
320
|
|
|
321
321
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
322
322
|
return new Promise(resolve => {
|
|
323
323
|
setTimeout(() => {
|
|
324
324
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
325
325
|
return resolve(getCallBackRes || false)
|
|
326
326
|
}, timeout)
|
|
327
327
|
})
|
|
328
328
|
}
|
|
329
329
|
|
|
330
330
|
getElderModePromise() {
|
|
331
331
|
if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
|
|
332
332
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
333
333
|
} else {
|
|
334
334
|
if (isJdAndAndroidDevice) {
|
|
335
335
|
this.info.sysInfo.jdAppModeType = '0'
|
|
336
336
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
337
337
|
} else {
|
|
338
338
|
return Promise.race([
|
|
339
339
|
this.taskTimeoutPromise(() => {
|
|
340
340
|
this.info.sysInfo.jdAppModeType = '0'
|
|
341
341
|
return this.info.sysInfo.jdAppModeType
|
|
342
342
|
}),
|
|
343
343
|
new Promise(resolve => {
|
|
344
344
|
const getCallBackName = `getJdCurrentModeType${Date.now()}`
|
|
345
345
|
if (!window[getCallBackName]) {
|
|
346
346
|
window[getCallBackName] = res => {
|
|
347
347
|
try {
|
|
348
348
|
const getResJson =
|
|
349
349
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
350
350
|
const { status, data, msg } = getResJson
|
|
351
351
|
console.log(`获取松果app展示模式成功,返回结果${data}`)
|
|
352
352
|
if (status === '0') {
|
|
353
353
|
this.info.sysInfo.jdAppModeType = data
|
|
354
354
|
resolve(data)
|
|
355
355
|
} else {
|
|
356
356
|
resolve('0')
|
|
357
357
|
}
|
|
358
358
|
} catch (e) {
|
|
359
359
|
resolve('0')
|
|
360
360
|
}
|
|
361
361
|
window[getCallBackName] = null
|
|
362
362
|
}
|
|
363
363
|
}
|
|
364
364
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
365
365
|
method: 'callSyncRouterModuleWithParams',
|
|
366
366
|
params: JSON.stringify({
|
|
367
367
|
routerURL: 'router://JDBModeModule/getCurrentMode',
|
|
368
368
|
routerParam: {},
|
|
369
369
|
callBackName: `window.${getCallBackName}`,
|
|
370
370
|
callBackId: `${getCallBackName}Ios`,
|
|
371
371
|
}),
|
|
372
372
|
})
|
|
373
373
|
}),
|
|
374
374
|
])
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
}
|
|
378
378
|
|
|
379
379
|
getJDAppearanceStatePromise() {
|
|
380
380
|
if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
|
|
381
381
|
return Promise.resolve(this.info.sysInfo.jdAppearanceState)
|
|
382
382
|
} else {
|
|
383
383
|
return Promise.race([
|
|
384
384
|
this.taskTimeoutPromise(() => {
|
|
385
385
|
this.info.sysInfo.jdAppearanceState = '0'
|
|
386
386
|
return this.info.sysInfo.jdAppearanceState
|
|
387
387
|
}),
|
|
388
388
|
new Promise(resolve => {
|
|
389
389
|
const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`
|
|
390
390
|
if (!window[getCallBackName]) {
|
|
391
391
|
window[getCallBackName] = res => {
|
|
392
392
|
try {
|
|
393
393
|
console.log('getJDAppearanceStatePromise', res)
|
|
394
394
|
const getResJson =
|
|
395
395
|
typeof res === 'string' ? JSON.parse(res) : res
|
|
396
396
|
const { status, data, msg } = getResJson
|
|
397
397
|
console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`)
|
|
398
398
|
if (status === '0') {
|
|
399
399
|
this.info.sysInfo.jdAppearanceState = data
|
|
400
400
|
resolve(data)
|
|
401
401
|
} else {
|
|
402
402
|
resolve('0')
|
|
403
403
|
}
|
|
404
404
|
} catch (e) {
|
|
405
405
|
resolve('0')
|
|
406
406
|
}
|
|
407
407
|
window[getCallBackName] = null
|
|
408
408
|
}
|
|
409
409
|
}
|
|
410
410
|
if (isAndroidDevice) {
|
|
411
411
|
const jsonString = JSON.stringify({
|
|
412
412
|
callBackName: `window.${getCallBackName}`,
|
|
413
413
|
})
|
|
414
414
|
console.log('window.JDAppearance', window.JDAppearance)
|
|
415
415
|
window.JDAppearance && window.JDAppearance.getUiState(jsonString)
|
|
416
416
|
} else {
|
|
417
417
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
418
418
|
method: 'callSyncRouterModuleWithParams',
|
|
419
419
|
params: JSON.stringify({
|
|
420
420
|
routerURL:
|
|
421
421
|
'router://JDWebViewBusinessModule/getJDAppearanceState',
|
|
422
422
|
routerParam: {},
|
|
423
423
|
callBackName: `window.${getCallBackName}`,
|
|
424
424
|
callBackId: `${getCallBackName}Ios`,
|
|
425
425
|
}),
|
|
426
426
|
})
|
|
427
427
|
}
|
|
428
428
|
}),
|
|
429
429
|
])
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
createJdAndroidRquestEventForTouchStart() {
|
|
434
434
|
if (isJdAndAndroidDevice && window.JdAndroid) {
|
|
435
435
|
const rootEleNode = document.querySelector('body')
|
|
436
436
|
if (rootEleNode) {
|
|
437
437
|
rootEleNode.addEventListener(
|
|
438
438
|
'touchstart',
|
|
439
439
|
this.jdAndroidAddEventListenerTouchStart,
|
|
440
440
|
false,
|
|
441
441
|
)
|
|
442
442
|
}
|
|
443
443
|
}
|
|
444
444
|
}
|
|
445
445
|
jdAndroidAddEventListenerTouchStart(e) {
|
|
446
446
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom')
|
|
447
447
|
if (!isH5SwiperCustomEle) {
|
|
448
448
|
const hasCustomEle = e
|
|
449
449
|
? e?.target?.closest('.J_customScroll') ||
|
|
450
450
|
e?.target?.closest('.J_customLayout')
|
|
451
451
|
: false
|
|
452
452
|
if (!hasCustomEle) {
|
|
453
453
|
window.JdAndroid.requestEvent(false)
|
|
454
454
|
console.log(
|
|
455
455
|
'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
|
|
456
456
|
)
|
|
457
457
|
}
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
460
|
removeJdAndroidRquestEventForTouchStart() {
|
|
461
461
|
if (isJdAndAndroidDevice && window.JdAndroid) {
|
|
462
462
|
const rootEleNode = document.querySelector('body')
|
|
463
463
|
if (rootEleNode) {
|
|
464
464
|
rootEleNode.removeEventListener(
|
|
465
465
|
'touchstart',
|
|
466
466
|
this.jdAndroidAddEventListenerTouchStart,
|
|
467
467
|
false,
|
|
468
468
|
)
|
|
469
469
|
}
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
472
|
|
|
473
473
|
getNetWorkType() {
|
|
474
474
|
if (isJdApp) {
|
|
475
475
|
this.jmfeReayPromise().then(() => {
|
|
476
476
|
window.jmfe
|
|
477
477
|
.getNetworkStatus()
|
|
478
478
|
.then(({ status, data }) => {
|
|
479
479
|
console.log(
|
|
480
480
|
'在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====',
|
|
481
481
|
data,
|
|
482
482
|
)
|
|
483
483
|
if (status === '0') {
|
|
484
484
|
this.info.sysInfo['netWorkType'] = data
|
|
485
485
|
} else {
|
|
486
486
|
this._taroGetNetworkType()
|
|
487
487
|
}
|
|
488
488
|
})
|
|
489
489
|
.catch(err => {
|
|
490
490
|
console.log('在app内初始化通过jmfe对象获取网络状态异常====', err)
|
|
491
491
|
this._taroGetNetworkType()
|
|
492
492
|
})
|
|
493
493
|
})
|
|
494
494
|
} else {
|
|
495
495
|
this._taroGetNetworkType()
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
_taroGetNetworkType() {
|
|
499
499
|
Taro.getNetworkType().then(getRes => {
|
|
500
500
|
if (getRes && getRes.networkType) {
|
|
501
501
|
this.info.sysInfo['netWorkType'] = getRes.networkType
|
|
502
502
|
console.log(
|
|
503
503
|
'在app内通过taro对象获取网络状态完成,当前网络状态',
|
|
504
504
|
this.info.sysInfo['netWorkType'],
|
|
505
505
|
)
|
|
506
506
|
}
|
|
507
507
|
})
|
|
508
508
|
}
|
|
509
509
|
getCacheAddressRouter() {
|
|
510
510
|
if (!window.jmfe) return
|
|
511
511
|
if (isAndroidDevice) {
|
|
512
512
|
return window.jmfe.callRouter({
|
|
513
513
|
jdRouter: '1',
|
|
514
514
|
routerURL: 'router://JDAddressModule/getCacheAddress',
|
|
515
515
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
516
516
|
})
|
|
517
517
|
} else if (isIosDevice) {
|
|
518
518
|
return window.jmfe.callRouter({
|
|
519
519
|
jdRouter: '1',
|
|
520
520
|
routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
|
|
521
521
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
522
522
|
})
|
|
523
523
|
} else if (isJdAndHarmonyDevice) {
|
|
524
524
|
return new Promise(resolve => {
|
|
525
525
|
resolve({})
|
|
526
526
|
})
|
|
527
527
|
} else {
|
|
528
528
|
throw Error(
|
|
529
529
|
'Unknown device type cannot obtain the address information through the route!',
|
|
530
530
|
)
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
getAddressCachePromise() {
|
|
535
535
|
return new Promise(resolve => {
|
|
536
536
|
if (
|
|
537
537
|
this?.info?.sysInfo?.lat &&
|
|
538
538
|
this?.info?.sysInfo?.lng &&
|
|
539
539
|
this?.info?.sysInfo?.area
|
|
540
540
|
) {
|
|
541
541
|
resolve({
|
|
542
542
|
lat: this.info.sysInfo.lat,
|
|
543
543
|
lng: this.info.sysInfo.lng,
|
|
544
544
|
area: this?.info?.sysInfo?.area,
|
|
545
545
|
})
|
|
546
546
|
} else {
|
|
547
547
|
this.jmfeReayPromise().then(() => {
|
|
548
548
|
this.getCacheAddressRouter()
|
|
549
549
|
.then(({ status, data }) => {
|
|
550
550
|
console.log("原生端获取经纬度原始数据结果",status,data)
|
|
551
551
|
if (status === '0' && data) {
|
|
552
552
|
const {
|
|
553
553
|
lat,
|
|
554
554
|
latitude,
|
|
555
555
|
lng,
|
|
556
556
|
longitude,
|
|
557
557
|
provinceId,
|
|
558
558
|
cityId,
|
|
559
559
|
countyId,
|
|
560
560
|
townId,
|
|
561
561
|
} = data || {}
|
|
562
562
|
let area = ''
|
|
563
563
|
this.info.sysInfo['lat'] = `${lat || latitude || ''}`
|
|
564
564
|
this.info.sysInfo['lng'] = `${lng || longitude || ''}`
|
|
565
565
|
if (provinceId) {
|
|
566
566
|
area = `${provinceId}_${cityId || 0}_${countyId ||
|
|
567
567
|
0}_${townId || 0}`
|
|
568
568
|
this.info.pageInfo['address'] = area
|
|
569
569
|
this.info.pageInfo['addressCommaStr'] = area.replace(
|
|
570
570
|
/_/g,
|
|
571
571
|
',',
|
|
572
572
|
)
|
|
573
573
|
}
|
|
574
574
|
})
|
|
575
575
|
.catch(e => {
|
|
576
576
|
console.log(' ~~ file: index.h5.ts:514 ~~ .catch ~~ e:', e)
|
|
577
577
|
resolve({ lat: '', lng: '', area: '' })
|
|
578
578
|
}
|
|
579
579
|
})
|
|
580
580
|
.catch(e => {
|
|
581
581
|
console.log(' ~~ file: index.h5.ts:518 ~~ .catch ~~ e:', e)
|
|
582
582
|
resolve({ lat: '', lng: '', area: '' })
|
|
583
583
|
console.log('判断jmfe不存在,获取经纬度信息异常')
|
|
584
584
|
})
|
|
585
585
|
})
|
|
586
586
|
}
|
|
587
587
|
})
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
async updateMPaasConfigAsync(isBeforePageReady: boolean) {
|
|
591
591
|
console.log("updateMPaasConfigAsync isBeforePageReady:", isBeforePageReady)
|
|
592
592
|
if (!isJdApp) {
|
|
593
593
|
return
|
|
594
594
|
}
|
|
595
595
|
const avifSwitch = await getMPaasConfigByBussinessKey(
|
|
596
596
|
'avifSwitch',
|
|
597
597
|
isBeforePageReady,
|
|
598
598
|
)
|
|
599
599
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch
|
|
600
600
|
const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
|
|
601
601
|
'isFollowAppVideoPlayStatus',
|
|
602
602
|
isBeforePageReady,
|
|
603
603
|
)
|
|
604
604
|
console.log(
|
|
605
605
|
'isBeforePageReady:',
|
|
606
606
|
isBeforePageReady,
|
|
607
607
|
'isFollowAppVideoPlayStatus:',
|
|
608
608
|
isFollowAppVideoPlayStatus,
|
|
609
609
|
)
|
|
610
610
|
if (
|
|
611
611
|
isFollowAppVideoPlayStatus === true ||
|
|
612
612
|
isFollowAppVideoPlayStatus === 'true'
|
|
613
613
|
) {
|
|
614
614
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true
|
|
615
615
|
}
|
|
616
616
|
}
|
|
617
617
|
|
|
618
618
|
async getWifiVideoAutoPlayAsync() {
|
|
619
619
|
this.info.sysInfo['wifiVideoAutoPlay'] = false
|
|
620
620
|
if (!isJdApp) {
|
|
621
621
|
return
|
|
622
622
|
}
|
|
623
623
|
const videoPlayStatus = await getWifiVideoAutoPlay().catch(e => {
|
|
624
624
|
return 0
|
|
625
625
|
})
|
|
626
626
|
if (Number(videoPlayStatus) === 1) {
|
|
627
627
|
this.info.sysInfo['wifiVideoAutoPlay'] = true
|
|
628
628
|
}
|
|
629
629
|
}
|
|
630
630
|
|
|
631
631
|
async getMPaasConfigAsync() {
|
|
632
632
|
this.info.sysInfo.dynamicConfig = {}
|
|
633
633
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = {}
|
|
634
634
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false
|
|
635
635
|
return this.updateMPaasConfigAsync(true)
|
|
636
636
|
}
|
|
637
637
|
|
|
638
638
|
getDynamicConfig(key: string){
|
|
639
639
|
return this.info.sysInfo.dynamicConfig[key]
|
|
640
640
|
}
|
|
641
641
|
async updateMPaasConfig() {
|
|
642
642
|
console.log('updateMPaasConfig')
|
|
643
643
|
if (
|
|
644
644
|
isIosDevice &&
|
|
645
645
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
|
|
646
646
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
|
|
647
647
|
) {
|
|
648
648
|
try {
|
|
649
649
|
await this.updateMPaasConfigAsync(false)
|
|
650
650
|
} catch (e) {
|
|
651
651
|
console.log('updateMPaasConfigAsync:', e)
|
|
652
652
|
}
|
|
653
653
|
}
|
|
654
654
|
}
|
|
655
655
|
|
|
656
656
|
toLogin(options) {
|
|
657
657
|
return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
|
|
658
658
|
? this.toWxAppLogin(options)
|
|
659
659
|
: this.toWebLogin(options)
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
doLogin(options) {
|
|
663
663
|
return this.toLogin(options)
|
|
664
664
|
}
|
|
665
665
|
|
|
666
666
|
doLoginForJdPin(options = {}) {
|
|
667
667
|
return this.doLogin({
|
|
668
668
|
loginColor: {
|
|
669
669
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
670
670
|
dpin: 0,
|
|
671
671
|
},
|
|
672
672
|
...options,
|
|
673
673
|
})
|
|
674
674
|
}
|
|
675
675
|
|
|
676
676
|
toWebLogin(options) {
|
|
677
677
|
let params: {
|
|
678
678
|
returnurl: string
|
|
679
679
|
} = {
|
|
680
680
|
returnurl: '',
|
|
681
681
|
}
|
|
682
682
|
const loginUrl = isPc
|
|
683
683
|
? `//passport.jd.com/new/login.aspx`
|
|
684
684
|
: `${domain.mobileLogin}/user/login.action`
|
|
685
685
|
const defaultParams = {
|
|
686
686
|
appid: '100',
|
|
687
687
|
returnurl: window.location.href,
|
|
688
688
|
}
|
|
689
689
|
if (isString(options)) {
|
|
690
690
|
params = Object.assign({}, defaultParams, {
|
|
691
691
|
returnurl: options,
|
|
692
692
|
})
|
|
693
693
|
} else if (isObject(options)) {
|
|
694
694
|
const { loginColor, ...otherOptions } = options
|
|
695
695
|
params = Object.assign({}, defaultParams, otherOptions)
|
|
696
696
|
} else {
|
|
697
697
|
params = defaultParams
|
|
698
698
|
}
|
|
699
699
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
700
700
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
701
701
|
if (isPc) {
|
|
702
702
|
getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
|
|
703
703
|
}
|
|
704
704
|
return Promise.resolve({
|
|
705
705
|
h5ToUrl: true,
|
|
706
706
|
url: getFullUrl,
|
|
707
707
|
}).then(() => {
|
|
708
708
|
window.location.href = getFullUrl
|
|
709
709
|
})
|
|
710
710
|
}
|
|
711
711
|
|
|
712
712
|
toWxAppLogin(options = {}) {
|
|
713
713
|
console.log('微信京购小程序中h5登录跳转', options)
|
|
714
714
|
return Promise.resolve(true).then(() => {
|
|
715
715
|
const { loginColor } = Object.assign(
|
|
716
716
|
{},
|
|
717
717
|
{
|
|
718
718
|
loginColor: {
|
|
719
719
|
biz: WXAPP_BIZ_KEY,
|
|
720
720
|
dpin: 1,
|
|
721
721
|
},
|
|
722
722
|
},
|
|
723
723
|
options,
|
|
724
724
|
)
|
|
725
725
|
window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
|
|
726
726
|
loginColor.biz
|
|
727
727
|
}&url=${encodeURIComponent(window.location.href)}`
|
|
728
728
|
})
|
|
729
729
|
}
|
|
730
730
|
|
|
731
731
|
getLoginCookie() {
|
|
732
732
|
return Promise.resolve({
|
|
733
733
|
pin: cookie.get('pin') || '',
|
|
734
734
|
})
|
|
735
735
|
}
|
|
736
736
|
|
|
737
737
|
clearLoginCookie() {
|
|
738
738
|
cookie.remove('pin')
|
|
739
739
|
}
|
|
740
740
|
|
|
741
741
|
checkStatusAndLogin(options = {}) {
|
|
742
742
|
if (!this.checkStatusAndLoginPromise) {
|
|
743
743
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
744
744
|
try {
|
|
745
745
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(
|
|
746
746
|
options,
|
|
747
747
|
)
|
|
748
748
|
if (getLoginState) {
|
|
749
749
|
resolve(true)
|
|
750
750
|
} else {
|
|
751
751
|
this.toLogin(options)
|
|
752
752
|
reject(false)
|
|
753
753
|
}
|
|
754
754
|
} catch (e) {
|
|
755
755
|
this.toLogin(options)
|
|
756
756
|
reject(false)
|
|
757
757
|
}
|
|
758
758
|
})
|
|
759
759
|
return this.checkStatusAndLoginPromise
|
|
760
760
|
} else {
|
|
761
761
|
return this.checkStatusAndLoginPromise
|
|
762
762
|
.then(() => {
|
|
763
763
|
return Promise.resolve(true)
|
|
764
764
|
})
|
|
765
765
|
.catch(() => {
|
|
766
766
|
this.toLogin(options)
|
|
767
767
|
return Promise.reject(true)
|
|
768
768
|
})
|
|
769
769
|
}
|
|
770
770
|
}
|
|
771
771
|
|
|
772
772
|
checkJdStatusAndLogin(
|
|
773
773
|
options = {
|
|
774
774
|
loginColor: {
|
|
775
775
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
776
776
|
dpin: 0,
|
|
777
777
|
},
|
|
778
778
|
},
|
|
779
779
|
) {
|
|
780
780
|
return this.checkStatusAndLogin(options)
|
|
781
781
|
}
|
|
782
782
|
|
|
783
783
|
doCheckLoginStateAndForApiCheck(options) {
|
|
784
784
|
if (this.info.loginState) {
|
|
785
785
|
return Promise.resolve(true)
|
|
786
786
|
} else {
|
|
787
787
|
return new Promise((resolve, reject) => {
|
|
788
788
|
if (
|
|
789
789
|
this.info.isJingGouMiniViewState ||
|
|
790
790
|
this.info.isJingxiMiniViewState
|
|
791
791
|
) {
|
|
792
792
|
const getWqAuthToken = cookie.get('wq_auth_token')
|
|
793
793
|
const getWqSkey = cookie.get('wq_skey')
|
|
794
794
|
const getWqUin = cookie.get('wq_uin')
|
|
795
795
|
const isLoginState =
|
|
796
796
|
options?.loginColor?.dpin === 0
|
|
797
797
|
? getWqAuthToken
|
|
798
798
|
: getWqSkey && getWqUin
|
|
799
799
|
if (isLoginState) {
|
|
800
800
|
this.info.loginState = true
|
|
801
801
|
resolve(true)
|
|
802
802
|
} else {
|
|
803
803
|
reject(false)
|
|
804
804
|
}
|
|
805
805
|
} else {
|
|
806
806
|
Taro.request({
|
|
807
807
|
url: api.isLogin,
|
|
808
808
|
jsonp: true,
|
|
809
809
|
timeout: 3000,
|
|
810
810
|
success: res => {
|
|
811
811
|
const { statusCode, data } = res
|
|
812
812
|
if (
|
|
813
813
|
statusCode === 200 &&
|
|
814
814
|
data?.islogin &&
|
|
815
815
|
Number(data.islogin) === 1
|
|
816
816
|
) {
|
|
817
817
|
this.info.loginState = true
|
|
818
818
|
resolve(true)
|
|
819
819
|
} else {
|
|
820
820
|
reject(false)
|
|
821
821
|
}
|
|
822
822
|
},
|
|
823
823
|
fail: err => {
|
|
824
824
|
console.log('登录检查异常', err)
|
|
825
825
|
reject(false)
|
|
826
826
|
},
|
|
827
827
|
})
|
|
828
828
|
}
|
|
829
829
|
})
|
|
830
830
|
}
|
|
831
831
|
}
|
|
832
832
|
|
|
833
833
|
checkLoginStatus(options) {
|
|
834
834
|
return new Promise(async (resolve, reject) => {
|
|
835
835
|
try {
|
|
836
836
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(
|
|
837
837
|
options,
|
|
838
838
|
)
|
|
839
839
|
if (getLoginState) {
|
|
840
840
|
const { pin } = await this.getLoginCookie()
|
|
841
841
|
this.info.userInfo = {
|
|
842
842
|
pin,
|
|
843
843
|
encodePin: encodeURIComponent(pin),
|
|
844
844
|
ptkey: '',
|
|
845
845
|
}
|
|
846
846
|
resolve(true)
|
|
847
847
|
} else {
|
|
848
848
|
reject(false)
|
|
849
849
|
}
|
|
850
850
|
} catch (e) {
|
|
851
851
|
reject(false)
|
|
852
852
|
}
|
|
853
853
|
})
|
|
854
854
|
}
|
|
855
855
|
|
|
856
856
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
857
857
|
const createUpdateQueryInfo: {
|
|
858
858
|
query: {
|
|
859
859
|
shopId?: string | number
|
|
860
860
|
venderId?: string | number
|
|
861
861
|
}
|
|
862
862
|
updateShopInfoState: boolean
|
|
863
863
|
} = Object.assign(
|
|
864
864
|
{},
|
|
865
865
|
{
|
|
866
866
|
query: {},
|
|
867
867
|
updateShopInfoState: false,
|
|
868
868
|
},
|
|
869
869
|
updateQuery,
|
|
870
870
|
)
|
|
871
871
|
console.log(
|
|
872
872
|
'获取当前下发的店铺查询参数',
|
|
873
873
|
updateQuery,
|
|
874
874
|
'获取之前保存的shopInfo店铺查询参数',
|
|
875
875
|
this.info?.shopInfo,
|
|
876
876
|
)
|
|
877
877
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
878
878
|
const { shopId, venderId, un_area } = query
|
|
879
879
|
if (updateShopInfoState) {
|
|
880
880
|
this.info.queryInfo = {
|
|
881
881
|
...this.info.queryInfo,
|
|
882
882
|
...query,
|
|
883
883
|
}
|
|
884
884
|
if (shopId && venderId) {
|
|
885
885
|
this.info.shopInfo = {
|
|
886
886
|
shopId: `${shopId}`,
|
|
887
887
|
venderId: `${venderId}`,
|
|
888
888
|
}
|
|
889
889
|
}
|
|
890
890
|
} else {
|
|
891
891
|
this.info.queryInfo = {
|
|
892
892
|
...query,
|
|
893
893
|
}
|
|
894
894
|
if (
|
|
895
895
|
this.info.shopInfo?.shopId &&
|
|
896
896
|
this.info.shopInfo?.venderId &&
|
|
897
897
|
(this.info.shopInfo.shopId == shopId ||
|
|
898
898
|
this.info.shopInfo.venderId == venderId)
|
|
899
899
|
) {
|
|
900
900
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
901
901
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
902
902
|
console.log(
|
|
903
903
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
904
904
|
this.info.queryInfo,
|
|
905
905
|
)
|
|
906
906
|
}
|
|
907
907
|
}
|
|
908
908
|
this.info.queryInfo['shopId'] &&
|
|
909
909
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
910
910
|
this.info.queryInfo['venderId'] &&
|
|
911
911
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
912
912
|
console.log(
|
|
913
913
|
'h5==获取店铺下发查询参数\n',
|
|
914
914
|
query,
|
|
915
915
|
'\n获取店铺最后查询参数\n',
|
|
916
916
|
this.info.queryInfo,
|
|
917
917
|
'\n是否为更新店铺状态\n',
|
|
918
918
|
updateShopInfoState,
|
|
919
919
|
)
|
|
920
920
|
const changeArea =
|
|
921
921
|
un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
|
|
922
922
|
if (changeArea) {
|
|
923
923
|
this.info.pageInfo.address = changeArea
|
|
924
924
|
this.info.pageInfo.un_area = changeArea
|
|
925
925
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
926
926
|
}
|
|
927
927
|
}
|
|
928
928
|
|
|
929
929
|
dealLoadSdkList(){
|
|
930
930
|
const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
|
|
931
931
|
const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? []
|
|
932
932
|
const concatLoadJsList = [].concat(globalLoadJsList,businessLoadJsList)
|
|
933
933
|
let mergeLoadJsList = globalLoadJsList
|
|
934
934
|
try {
|
|
935
935
|
mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
|
|
936
936
|
const getFindIndex = accArr.findIndex(item => item?.fileName === current?.fileName);
|
|
937
937
|
getFindIndex !== -1 ? (accArr[getFindIndex] = {...accArr[getFindIndex],...current }) : accArr.push(current);
|
|
938
938
|
return accArr;
|
|
939
939
|
}, []);
|
|
940
940
|
}catch (e) {
|
|
941
941
|
console.log("LoadJsList合并错误", e)
|
|
942
942
|
}
|
|
943
943
|
console.log("globalLoadJsList",globalLoadJsList,"businessLoadJsList",businessLoadJsList,"两个加载jsList集合合并完成", mergeLoadJsList)
|
|
944
944
|
this.loadJsSdkList = mergeLoadJsList
|
|
945
945
|
return this.loadJsSdkList
|
|
946
946
|
}
|
|
947
947
|
|
|
948
948
|
renderNextTickLoadSdk(){
|
|
949
949
|
Taro.nextTick(() => {
|
|
950
950
|
console.log("页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======")
|
|
951
951
|
setTimeout(() => {
|
|
952
952
|
this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK,this.loadJsSdkList)
|
|
953
953
|
},1000)
|
|
954
954
|
})
|
|
955
955
|
}
|
|
956
956
|
|
|
957
957
|
loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW,loadJsList:any[] = [] ) {
|
|
958
958
|
const getLoadJsList = Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList()
|
|
959
959
|
const getLoadFilterList = getLoadJsList.filter(item => {
|
|
960
960
|
const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL
|
|
961
961
|
let getLoastLoadEventState = true
|
|
962
962
|
if(getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP){
|
|
963
963
|
getLoastLoadEventState = isJdApp
|
|
964
964
|
}
|
|
965
965
|
else if(getInitLoadEnvType === LoadJsInitLoadEnvType.M){
|
|
966
966
|
getLoastLoadEventState = !isJdApp
|
|
967
967
|
}
|
|
968
968
|
const getInitTriggerType = isJdApp && item?.initJdAppTriggerType ? item?.initTriggerType : item?.initTriggerType || LoadJsInitTriggerType.NOW
|
|
969
969
|
const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false
|
|
970
970
|
return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay
|
|
971
971
|
})
|
|
972
972
|
console.log("获取当前触发方式",triggerType,"获取当前最后加载的js集合",getLoadFilterList,"过滤前的加载集合",getLoadJsList)
|
|
973
973
|
getLoadFilterList.length > 0 && getLoadFilterList.forEach((item) => {
|
|
974
974
|
const isLoadState = /sgm/.test(item?.fileName) ? window?.shopGlobalSwitch?.openSgm === "true" : true
|
|
975
975
|
isLoadState && this.loadItemSdkPromise(item)
|
|
976
976
|
.then((res) => {
|
|
977
977
|
console.info('当前js地址' + item?.src, '加载状态', res)
|
|
978
978
|
})
|
|
979
979
|
.catch((err) => {
|
|
980
980
|
console.info('当前js地址加载异常', item?.src)
|
|
981
981
|
window?.fetchErrorData &&
|
|
982
982
|
window.fetchErrorData({
|
|
983
983
|
title: '公共js加载异常',
|
|
984
984
|
type: "jsLoad",
|
|
985
985
|
data: err,
|
|
986
986
|
})
|
|
987
987
|
})
|
|
988
988
|
})
|
|
989
989
|
}
|
|
990
990
|
loadScriptEle(jsInfo,resolve,reject){
|
|
991
991
|
const getFileName = jsInfo?.fileName;
|
|
992
992
|
if(getFileName){
|
|
993
993
|
const getEleId = `J_loadJs_${getFileName}`
|
|
994
994
|
const getEle = document.getElementById(getEleId)
|
|
995
995
|
if (!getEle) {
|
|
996
996
|
const jsLoadErrorSgmCode = `jsLoadError_${
|
|
997
997
|
jsInfo?.fileName || 'customJs'
|
|
998
998
|
}`
|
|
999
999
|
const _sgmEle = document.createElement('script')
|
|
1000
1000
|
_sgmEle.id = getEleId
|
|
1001
1001
|
_sgmEle.onload = function () {
|
|
1002
1002
|
resolve({
|
|
1003
1003
|
...jsInfo,
|
|
1004
1004
|
jsTip: "js加载成功",
|
|
1005
1005
|
})
|
|
1006
1006
|
}
|
|
1007
1007
|
_sgmEle.onerror = function () {
|
|
1008
1008
|
reject({
|
|
1009
1009
|
...jsInfo,
|
|
1010
1010
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1011
1011
|
jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
|
|
1012
1012
|
})
|
|
1013
1013
|
}
|
|
1014
1014
|
const dataAttrList = ['timeout','fileName',"env"]
|
|
1015
1015
|
const getJsInfoKeyList = Object.keys(jsInfo)
|
|
1016
1016
|
getJsInfoKeyList.forEach(key => {
|
|
1017
1017
|
if(key === "async"){
|
|
1018
1018
|
_sgmEle.async = jsInfo[key]
|
|
1019
1019
|
}else if(key === "crossOrigin"){
|
|
1020
1020
|
_sgmEle.crossOrigin = jsInfo[key]
|
|
1021
1021
|
}else if(key === "src"){
|
|
1022
1022
|
_sgmEle.src = `${jsInfo[key]}`
|
|
1023
1023
|
}else if(dataAttrList.includes(key) || /init/.test(key)) {
|
|
1024
1024
|
_sgmEle.setAttribute(`data-${key}`, jsInfo[key])
|
|
1025
1025
|
}else {
|
|
1026
1026
|
_sgmEle.setAttribute(key, jsInfo[key])
|
|
1027
1027
|
}
|
|
1028
1028
|
})
|
|
1029
1029
|
document.head.appendChild(_sgmEle)
|
|
1030
1030
|
}else {
|
|
1031
1031
|
console.log(`当前${jsInfo?.fileName || "js"}已经存在页面中,可以直接调用相关方法`,jsInfo)
|
|
1032
1032
|
resolve({
|
|
1033
1033
|
...jsInfo,
|
|
1034
1034
|
jsTip: "js本身已存在页面中",
|
|
1035
1035
|
})
|
|
1036
1036
|
}
|
|
1037
1037
|
}else {
|
|
1038
1038
|
console.warn("当前js资源信息缺少必要的参数fileName,请关注",jsInfo)
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
1041
|
|
|
1042
1042
|
loadItemSdkPromise(jsInfo = {}){
|
|
1043
1043
|
if(jsInfo?.src){
|
|
1044
1044
|
const getInitLoadType = isJdApp && jsInfo?.initJdAppLoadType ? jsInfo?.initJdAppLoadType : jsInfo?.initLoadType || LoadJsInitLoadType.ALL
|
|
1045
1045
|
if(getInitLoadType !== LoadJsInitLoadType.NONE){
|
|
1046
1046
|
const getFileKeyName = jsInfo?.fileName || jsInfo?.src
|
|
1047
1047
|
if (!this.loadJsSdkListCachePromise[getFileKeyName]){
|
|
1048
1048
|
if(getInitLoadType !== LoadJsInitLoadType.INSERT_ELE){
|
|
1049
1049
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
|
|
1050
1050
|
const jsLoadErrorSgmCode = `jsLoadError_${
|
|
1051
1051
|
jsInfo?.fileName || 'customJs'
|
|
1052
1052
|
}`
|
|
1053
1053
|
try {
|
|
1054
1054
|
const jsXhrRequest = new XMLHttpRequest();
|
|
1055
1055
|
jsXhrRequest.timeout = jsInfo?.timeout ?? 2000
|
|
1056
1056
|
const jsUrl = `${jsInfo?.src}`
|
|
1057
1057
|
jsXhrRequest.open('GET', jsUrl, true);
|
|
1058
1058
|
jsXhrRequest.onload = () => {
|
|
1059
1059
|
if (jsXhrRequest.status === 200) {
|
|
1060
1060
|
const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL
|
|
1061
1061
|
if(getInsetHeadState){
|
|
1062
1062
|
this.loadScriptEle(jsInfo,resolve,reject)
|
|
1063
1063
|
}else {
|
|
1064
1064
|
resolve({
|
|
1065
1065
|
...jsInfo,
|
|
1066
1066
|
jsTip: "js请求成功,暂未插入head节点,业务自行单独插入",
|
|
1067
1067
|
})
|
|
1068
1068
|
}
|
|
1069
1069
|
}else {
|
|
1070
1070
|
const getRes = {
|
|
1071
1071
|
...jsInfo,
|
|
1072
1072
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1073
1073
|
jsReqError: `请求状态异常,状态为${jsXhrRequest?.status}`,
|
|
1074
1074
|
jsReqState: jsXhrRequest?.status,
|
|
1075
1075
|
}
|
|
1076
1076
|
console.log("当前js请求状态异常", getRes)
|
|
1077
1077
|
reject(getRes)
|
|
1078
1078
|
}
|
|
1079
1079
|
}
|
|
1080
1080
|
jsXhrRequest.onerror = () => {
|
|
1081
1081
|
const getRes = {
|
|
1082
1082
|
...jsInfo,
|
|
1083
1083
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1084
1084
|
jsReqError: '请求错误',
|
|
1085
1085
|
}
|
|
1086
1086
|
console.log("当前js请求错误", getRes)
|
|
1087
1087
|
jsXhrRequest.abort()
|
|
1088
1088
|
reject(getRes)
|
|
1089
1089
|
}
|
|
1090
1090
|
jsXhrRequest.ontimeout = () => {
|
|
1091
1091
|
const getRes = {
|
|
1092
1092
|
...jsInfo,
|
|
1093
1093
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1094
1094
|
jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
|
|
1095
1095
|
}
|
|
1096
1096
|
console.log("当前js请求超时异常", getRes)
|
|
1097
1097
|
jsXhrRequest.abort()
|
|
1098
1098
|
reject(getRes)
|
|
1099
1099
|
}
|
|
1100
1100
|
jsXhrRequest.send();
|
|
1101
1101
|
}catch (e) {
|
|
1102
1102
|
console.log("执行js请求异常",e)
|
|
1103
1103
|
reject({
|
|
1104
1104
|
...jsInfo,
|
|
1105
1105
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1106
1106
|
jsReqError: '未知异常',
|
|
1107
1107
|
error: e,
|
|
1108
1108
|
})
|
|
1109
1109
|
}
|
|
1110
1110
|
})
|
|
1111
1111
|
}else {
|
|
1112
1112
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve,reject) => {
|
|
1113
1113
|
return this.loadScriptEle(jsInfo,resolve,reject)
|
|
1114
1114
|
})
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
1117
|
return this.loadJsSdkListCachePromise[getFileKeyName]
|
|
1118
1118
|
}else {
|
|
1119
1119
|
return Promise.resolve({
|
|
1120
1120
|
...jsInfo,
|
|
1121
1121
|
jsTip: "js加载方式设置为不加载,当前不做处理",
|
|
1122
1122
|
})
|
|
1123
1123
|
}
|
|
1124
1124
|
}else {
|
|
1125
1125
|
return Promise.reject(jsInfo)
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|