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