@conecli/cone-render 0.8.19 → 0.8.20-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -1
- package/dist/api/index.ts +1 -1
- package/dist/assets/icon_blue_info.svg +1 -0
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.ts +1 -0
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/isvStorage/index.h5.ts +1 -0
- package/dist/common/isvStorage/index.ts +1 -0
- 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/const.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -0
- package/dist/common/token/index.ts +1 -0
- package/dist/common/token/token.jd.ts +1 -0
- package/dist/common/token/token.ts +1 -0
- package/dist/common/token/token.wxapp.ts +1 -0
- package/dist/common/wxappApi.jd.ts +1 -0
- package/dist/common/wxappApi.ts +1 -1
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CountDown/index.module.scss +49 -44
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index.jd.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.module.scss +7 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/const.ts +1 -0
- package/dist/components/base/CustomVideo/index.module.scss +40 -64
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +22 -2
- package/dist/components/base/Dialog/index.tsx +1 -1
- package/dist/components/base/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/const.ts +1 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +30 -6
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.module.scss +20 -9
- 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/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +8 -0
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -0
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +24 -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 +128 -69
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/{const.ts → Base/const.ts} +0 -0
- package/dist/components/base/Price/Base/index.module.scss +148 -0
- package/dist/components/base/Price/Base/index.tsx +1 -0
- package/dist/components/base/Price/Double/index.module.scss +190 -0
- package/dist/components/base/Price/Double/index.tsx +1 -0
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/base/ShopLeGaoTag/index.h5.module.scss +35 -0
- package/dist/components/base/ShopLeGaoTag/index.h5.tsx +1 -0
- package/dist/components/base/ShopLeGaoTag/index.module.scss +33 -0
- package/dist/components/base/ShopLeGaoTag/index.tsx +1 -0
- package/dist/components/base/Skeleton/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +32 -2
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -0
- 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 -0
- 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.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 -0
- package/dist/jumpEventReport/web.jdjch.ts +1 -0
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -0
- package/dist/jumpEventReport/web.pc.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/language/en_US.json +231 -0
- package/dist/language/zh_CN.json +231 -0
- package/dist/language/zh_HK.json +231 -0
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -27
- 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/business.ts +1 -0
- package/dist/open/api/jump/index.ts +1 -0
- package/dist/open/api/jump/minPath.ts +1 -0
- package/dist/open/api/jump/side.ts +1 -0
- package/dist/open/api/jump/webUrl.ts +1 -0
- package/dist/open/api/jump copy.ts +1 -0
- package/dist/open/api/moduleUtil.ts +1 -1
- package/dist/open/api/request.ts +1 -0
- package/dist/open/api/shopMember.ts +1 -0
- package/dist/open/api/track.ts +1 -1
- package/dist/open/api/userToken.ts +1 -0
- package/dist/open/api/util.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +294 -212
- package/dist/sass/base.scss +195 -137
- package/dist/service/bMallConst.ts +1 -0
- package/dist/service/bMallConst.weapp.ts +1 -0
- package/dist/service/fetchGateway.ts +1 -0
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/fetchJsonp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -0
- package/dist/service/http/colorSign.weapp.ts +1 -0
- package/dist/service/http/const.ts +1 -0
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/http.ts +1 -0
- package/dist/service/http/httpInterceptors.jd.ts +1 -0
- package/dist/service/http/httpInterceptors.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/http/index.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -0
- package/dist/service/requestServer.weapp.ts +1 -0
- 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/intersectionObserver.ts +1 -1
- package/dist/utils/jm-common.js +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/priceUtils.js +1 -0
- package/dist/utils/ready.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/sgmCodeUtils.ts +1 -0
- package/dist/utils/taroRenderUtil.ts +1 -0
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/api/helper.js +1 -0
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/dist/wxapp/components/launch-app/index.js +1 -0
- package/dist/wxapp/components/launch-app/index.json +5 -0
- package/dist/wxapp/components/launch-app/index.wxml +0 -0
- package/dist/wxapp/components/launch-app/index.wxss +0 -0
- package/dist/wxapp/components/subscribe-guider/helper.js +1 -0
- package/dist/wxapp/components/subscribe-guider/index.js +1 -0
- package/dist/wxapp/components/subscribe-guider/index.json +5 -0
- package/dist/wxapp/components/subscribe-guider/index.wxml +0 -0
- package/dist/wxapp/components/subscribe-guider/index.wxss +0 -0
- package/package.json +145 -114
- package/dist/components/base/Price/index.module.scss +0 -136
- package/dist/components/base/Skeleton/old.tsx +0 -1
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
- package/dist/open/api/jump.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
|
pin: cookie.get('pin') || ''
|
|
9
8
|
})
|
|
10
9
|
if(!this.checkStatusAndLoginPromise){
|
|
11
10
|
this.checkStatusAndLoginPromise = new Promise((resolve) => {
|
|
12
11
|
!this.info.loginState && this.toLogin(options)
|
|
13
12
|
resolve(true)
|
|
14
13
|
})
|
|
15
14
|
}
|
|
16
15
|
const { pin } = await this.getLoginCookie();
|
|
17
16
|
this.info.userInfo = {
|
|
18
17
|
pin,
|
|
19
18
|
encodePin: encodeURIComponent(pin),
|
|
20
19
|
ptkey: '',
|
|
21
20
|
}
|
|
22
21
|
resolve(this.info.userInfo)
|
|
23
22
|
})
|
|
23
|
+
import Taro from '@tarojs/taro';
|
|
24
24
|
dealNativePixelToCssPixel,
|
|
25
25
|
isAndroidDevice,
|
|
26
26
|
isIosDevice,
|
|
27
27
|
isJdAndAndroidDevice,
|
|
28
28
|
isJdAndHarmonyDevice,
|
|
29
29
|
isObject,
|
|
30
30
|
isPc,
|
|
31
31
|
isString,
|
|
32
32
|
jdAppVersion,
|
|
33
33
|
jdAppVersionStr,
|
|
34
34
|
serialize,
|
|
35
35
|
draBusinessCustomReport,
|
|
36
36
|
isH5AndJingGouMini,
|
|
37
37
|
languageNowType,
|
|
38
38
|
urlCookie,
|
|
39
39
|
BUSINESS_TYPE,
|
|
40
40
|
LoadJsInitLoadEnvType,
|
|
41
41
|
LoadJsInitLoadType,
|
|
42
42
|
LoadJsInitTriggerType,
|
|
43
43
|
MPAAS_CONFIG_APP_LOW_VERSION,
|
|
44
44
|
MPAAS_CONFIG_APP_VERSION,
|
|
45
45
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
46
46
|
SECTION_HOME_TAB_TYPE,
|
|
47
47
|
TaroEventType,
|
|
48
48
|
WX_BUSINESS_TYPE,
|
|
49
49
|
WXAPP_BIZ_KEY,
|
|
50
50
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
51
51
|
JSSDK_APP_WEBVIEW_CODE,
|
|
52
52
|
cacheH5LbsAddressKey,
|
|
53
53
|
languageTypeList,
|
|
54
54
|
getSystemInfos,
|
|
55
55
|
getTaroStorageKeyValue,
|
|
56
56
|
ipLoc_djd,
|
|
57
57
|
setTaroStorage,
|
|
58
58
|
sgmCustomReport,
|
|
59
59
|
getMPaasConfigByBussinessKey,
|
|
60
60
|
callRouterAndroid,
|
|
61
61
|
callRouterIOS,
|
|
62
62
|
const designWidth = 750;
|
|
63
63
|
return (
|
|
64
64
|
Math.ceil((((parseInt(String(size), 10) / 40) * 750) / designWidth) * 10000) / 10000 + 'rem'
|
|
65
65
|
);
|
|
66
66
|
abTestLabels: {},
|
|
67
67
|
nonSellableSkuids: {},
|
|
68
68
|
loginState: false,
|
|
69
69
|
cookiesStr: '',
|
|
70
70
|
userInfo: userPinKey,
|
|
71
71
|
isImmersive: false,
|
|
72
72
|
isJingGouMiniViewState: false,
|
|
73
73
|
isJingxiMiniViewState: false,
|
|
74
74
|
pageInfo: {
|
|
75
75
|
wxBusinessType: WX_BUSINESS_TYPE.NO,
|
|
76
76
|
address: '',
|
|
77
77
|
addressCommaStr: '',
|
|
78
78
|
fullAddress: '',
|
|
79
79
|
un_area: '',
|
|
80
80
|
userLbsAddress: '',
|
|
81
81
|
vapptype: '1',
|
|
82
82
|
pageType: 'home',
|
|
83
83
|
isExposureState: false,
|
|
84
84
|
moduleId: '',
|
|
85
85
|
entrance: '',
|
|
86
86
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
87
87
|
floorExposureInfo: {},
|
|
88
88
|
floorVideInfo: {},
|
|
89
89
|
productVideInfo: {},
|
|
90
90
|
tabsLoadAllDataInfo: {
|
|
91
91
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
|
|
92
92
|
},
|
|
93
93
|
updateShopInfosAllState: false,
|
|
94
94
|
isVipShop: false,
|
|
95
95
|
isJdShowNativeImmersivePlayer: false,
|
|
96
96
|
...shopConfig,
|
|
97
97
|
pageScrollTop: 0,
|
|
98
98
|
pageIdxHeightInfo: {
|
|
99
99
|
list: [],
|
|
100
100
|
},
|
|
101
101
|
shopNavBarHeight: 0,
|
|
102
102
|
},
|
|
103
103
|
defaultQueryLogInfo: {
|
|
104
104
|
sourceType: 'JDshop',
|
|
105
105
|
sourceValue: '',
|
|
106
106
|
moduleId: 'none',
|
|
107
107
|
entrance: 'none',
|
|
108
108
|
},
|
|
109
109
|
sysInfo: {
|
|
110
110
|
windowWidth: isPc ? 375 : 0,
|
|
111
111
|
containerWidth: isPc ? 375 : 0,
|
|
112
112
|
windowHeight: 0,
|
|
113
113
|
netWorkType: '4g',
|
|
114
114
|
jdBottomBarHeight: 0,
|
|
115
115
|
jdNativeHeaderHeight: 0,
|
|
116
116
|
isJdTabletDevice: false,
|
|
117
117
|
isJdTabletLandscape: false,
|
|
118
118
|
},
|
|
119
119
|
queryInfo: {},
|
|
120
120
|
shopInfo: {},
|
|
121
121
|
openAppData: {},
|
|
122
122
|
public info: CommonInterFace.BaseConfigInfo;
|
|
123
123
|
public config: {
|
|
124
124
|
[key: string]: any;
|
|
125
125
|
};
|
|
126
126
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
127
127
|
public renderedIsvComponents: CommonInterFace.renderedIsvComponents;
|
|
128
128
|
public rootEleNode: HTMLElement | null;
|
|
129
129
|
public checkStatusAndLoginPromise: object | null;
|
|
130
130
|
private jmfeRegisterStatePromise: Promise<any> | null;
|
|
131
131
|
private jdScreenSizeInfoPromise: Promise<any> | null;
|
|
132
132
|
private rootEleWidthRegisterPromise: Promise<any> | null;
|
|
133
133
|
private jmfeRegisterState: boolean;
|
|
134
134
|
public loadJsSdkList: Array<any>;
|
|
135
135
|
public loadJsSdkListCachePromise: any;
|
|
136
136
|
public rootEleInitWidth: number;
|
|
137
137
|
public lbsAddressCachePromise: Promise<any> | null;
|
|
138
138
|
public languageCacheProimse: Promise<any> | null;
|
|
139
139
|
public languageJsonData: any | null;
|
|
140
140
|
constructor(opt) {
|
|
141
141
|
this.info = this._getConfig(opt);
|
|
142
142
|
this.config = {};
|
|
143
143
|
this.loadJsSdkList = [];
|
|
144
144
|
this.loadJsSdkListCachePromise = {};
|
|
145
145
|
this.lazyContainer = {
|
|
146
146
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
147
147
|
appLazyContainerList: [],
|
|
148
148
|
appLazyFinishContainerList: [],
|
|
149
149
|
},
|
|
150
150
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
151
151
|
appLazyContainerList: [],
|
|
152
152
|
appLazyFinishContainerList: [],
|
|
153
153
|
},
|
|
154
154
|
};
|
|
155
155
|
this.renderedIsvComponents = {};
|
|
156
156
|
this.rootEleNode = document.querySelector('body');
|
|
157
157
|
this.checkStatusAndLoginPromise = null;
|
|
158
158
|
this.jmfeRegisterStatePromise = null;
|
|
159
159
|
this.jdScreenSizeInfoPromise = null;
|
|
160
160
|
this.rootEleWidthRegisterPromise = null;
|
|
161
161
|
this.lbsAddressCachePromise = null;
|
|
162
162
|
this.languageCacheProimse = null;
|
|
163
163
|
this.languageJsonData = langeJsonDataForCn;
|
|
164
164
|
this.rootEleInitWidth = this.getRootEleWindowWidthInfo().getRootEleWidth || -1;
|
|
165
165
|
this.loadOtherSdk();
|
|
166
166
|
if (isJdApp) {
|
|
167
167
|
this.jmfeReayPromise();
|
|
168
168
|
this._getJdPadMinWidthForListen() && this.getPadWindowRootEleWidthPromise();
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
_getConfig(opt) {
|
|
172
172
|
return Object.assign({}, DefaultConfig, opt);
|
|
173
173
|
}
|
|
174
174
|
_getJdPadMinWidthForListen() {
|
|
175
175
|
return (
|
|
176
176
|
isJdApp &&
|
|
177
177
|
Math.min(window.screen.width, window.screen.height) >
|
|
178
178
|
(window?.shopGlobalSwitch?.checkPadRootEleMinWidth || 600)
|
|
179
179
|
);
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
jmfeReayPromise(): Promise<any> {
|
|
183
183
|
if (isJdApp) {
|
|
184
184
|
if (this.jmfeRegisterState) {
|
|
185
185
|
return Promise.resolve(true);
|
|
186
186
|
} else {
|
|
187
187
|
!this.jmfeRegisterStatePromise &&
|
|
188
188
|
(this.jmfeRegisterStatePromise = new Promise((resolve, reject) => {
|
|
189
189
|
ready('jmfe', 3000)
|
|
190
190
|
.then(() => {
|
|
191
191
|
window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE);
|
|
192
192
|
this.jmfeRegisterState = true;
|
|
193
193
|
resolve(true);
|
|
194
194
|
console.log(
|
|
195
195
|
'松果app内初始化注册jmfe认证完成',
|
|
196
196
|
window?.jmfe,
|
|
197
197
|
'当前版本',
|
|
198
198
|
window?.jmfe?.VERSION,
|
|
199
199
|
);
|
|
200
200
|
})
|
|
201
201
|
.catch((err) => {
|
|
202
202
|
console.error('jmfe ready error', err);
|
|
203
203
|
reject(false);
|
|
204
204
|
});
|
|
205
205
|
}));
|
|
206
206
|
return this.jmfeRegisterStatePromise;
|
|
207
207
|
}
|
|
208
208
|
} else {
|
|
209
209
|
return Promise.reject(false);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
getJdScreenSizeInfoPromise() {
|
|
214
214
|
!this.jdScreenSizeInfoPromise &&
|
|
215
215
|
(this.jdScreenSizeInfoPromise = new Promise((resolve) => {
|
|
216
216
|
const getThisTime = Date.now();
|
|
217
217
|
this.jmfeReayPromise().then(() => {
|
|
218
218
|
return Promise.race([
|
|
219
219
|
window.jmfe.getScreenSize(),
|
|
220
220
|
this.taskTimeoutPromise(() => {
|
|
221
221
|
return {
|
|
222
222
|
status: '-10',
|
|
223
223
|
msg: '获取大屏信息2s超时',
|
|
224
224
|
};
|
|
225
225
|
}),
|
|
226
226
|
])
|
|
227
227
|
.then((res) => {
|
|
228
228
|
console.warn('===获取app大屏信息====', res);
|
|
229
229
|
const { status, data } = res;
|
|
230
230
|
if (status === '0' && data) {
|
|
231
231
|
const { sizeType, isLandscape, pageHeight, pageWidth } = data;
|
|
232
232
|
const getPageInfo = dealNativePixelToCssPixel({
|
|
233
233
|
pageWidth,
|
|
234
234
|
pageHeight,
|
|
235
235
|
});
|
|
236
236
|
this.info.sysInfo.jdScreenSizeType = sizeType;
|
|
237
237
|
const getUseTime = Date.now() - getThisTime;
|
|
238
238
|
console.warn(
|
|
239
239
|
'===计算是否是app大屏信息,需满足宽度最新720===',
|
|
240
240
|
getPageInfo,
|
|
241
241
|
'原始数据',
|
|
242
242
|
data,
|
|
243
243
|
'是否是横屏isLandscape为1=',
|
|
244
244
|
isLandscape,
|
|
245
245
|
'用时',
|
|
246
246
|
getUseTime,
|
|
247
247
|
);
|
|
248
248
|
if (getPageInfo?.pageWidth > 0) {
|
|
249
249
|
this.rootEleInitWidth = getPageInfo?.pageWidth;
|
|
250
250
|
draBusinessCustomReport({
|
|
251
251
|
type: 'rootEle_width_getJdScreenSizeInfo',
|
|
252
252
|
errMsg: `根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果,用时${getUseTime}`,
|
|
253
253
|
originReqDataStr: JSON.stringify({
|
|
254
254
|
isJdApp,
|
|
255
255
|
getPageInfo,
|
|
256
256
|
originData: res,
|
|
257
257
|
}),
|
|
258
258
|
});
|
|
259
259
|
resolve(getPageInfo);
|
|
260
260
|
} else {
|
|
261
261
|
resolve({
|
|
262
262
|
pageWidth: 0,
|
|
263
263
|
pageHeight: 0,
|
|
264
264
|
msg: '转换异常',
|
|
265
265
|
});
|
|
266
266
|
}
|
|
267
267
|
} else {
|
|
268
268
|
resolve({
|
|
269
269
|
pageWidth: 0,
|
|
270
270
|
pageHeight: 0,
|
|
271
271
|
msg: '获取大屏信息异常或者超时',
|
|
272
272
|
});
|
|
273
273
|
}
|
|
274
274
|
})
|
|
275
275
|
.catch((err) => {
|
|
276
276
|
console.log('获取大屏信息异常', err);
|
|
277
277
|
resolve({
|
|
278
278
|
pageWidth: 0,
|
|
279
279
|
pageHeight: 0,
|
|
280
280
|
msg: '获取大屏信息异常',
|
|
281
281
|
});
|
|
282
282
|
});
|
|
283
283
|
});
|
|
284
284
|
}));
|
|
285
285
|
return this.jdScreenSizeInfoPromise;
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
listenJdTabletScreenChange() {
|
|
289
289
|
this.jmfeReayPromise().then(() => {
|
|
290
290
|
try {
|
|
291
291
|
console.log('初始化监听大屏信息变化', window.jmfe.listenDeviceScreenChange);
|
|
292
292
|
window.jmfe.listenDeviceScreenChange((event) => {
|
|
293
293
|
console.log(
|
|
294
294
|
'监听app大屏信息变化,orientation为landscape表示横屏,multiScreen为1表示android端分屏',
|
|
295
295
|
event,
|
|
296
296
|
'通过前端判断是不是横屏',
|
|
297
297
|
window.matchMedia('(orientation: landscape)')?.matches,
|
|
298
298
|
);
|
|
299
299
|
const { orientation } = event?.data;
|
|
300
300
|
if (orientation) {
|
|
301
301
|
this.info.sysInfo.isJdTabletLandscape = orientation === 'landscape';
|
|
302
302
|
Taro.eventCenter.trigger(
|
|
303
303
|
TaroEventType.TABLE_SCREEN_CHANGE,
|
|
304
304
|
this.info.sysInfo.isJdTabletLandscape,
|
|
305
305
|
orientation,
|
|
306
306
|
);
|
|
307
307
|
}
|
|
308
308
|
});
|
|
309
309
|
} catch (error) {
|
|
310
310
|
console.log('listenScreenChange的打印error:', error);
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
314
|
|
|
315
315
|
updateBusinessDomainAndApi(domain, api) {
|
|
316
316
|
}
|
|
317
317
|
|
|
318
318
|
formatNativeScreenPageData(action) {
|
|
319
319
|
let getChangePageInfo: any = null;
|
|
320
320
|
try {
|
|
321
321
|
const getNativeScreenPageInfoStr = window.XWebView?._callNative(
|
|
322
322
|
JSON.stringify({
|
|
323
323
|
plugin: 'JDHybridScreenPlugin',
|
|
324
324
|
action,
|
|
325
325
|
sync: '1',
|
|
326
326
|
}),
|
|
327
327
|
);
|
|
328
328
|
const getChangePageInfoData =
|
|
329
329
|
typeof getNativeScreenPageInfoStr === 'string'
|
|
330
330
|
? JSON.parse(getNativeScreenPageInfoStr)
|
|
331
331
|
: null;
|
|
332
332
|
if (getChangePageInfoData && typeof getChangePageInfoData === 'object') {
|
|
333
333
|
const { code, data } = getChangePageInfoData;
|
|
334
334
|
getChangePageInfo = code && code === '0' ? data : null;
|
|
335
335
|
}
|
|
336
336
|
} catch (e) {
|
|
337
337
|
console.log('JDHybridScreenPlugin转换异常', e);
|
|
338
338
|
}
|
|
339
339
|
return getChangePageInfo;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
342
|
isAndroidFoldScreen() {
|
|
343
343
|
return this.formatNativeScreenPageData('isFoldScreen') === '1';
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
getJdAndroidPageChangeScreenInfo() {
|
|
347
347
|
const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize');
|
|
348
348
|
if (getPageScreenInfo && getPageScreenInfo?.pageWidth && getPageScreenInfo?.pageHeight) {
|
|
349
349
|
const { pageWidth, pageHeight } = dealNativePixelToCssPixel({
|
|
350
350
|
pageWidth: getPageScreenInfo.pageWidth,
|
|
351
351
|
pageHeight: getPageScreenInfo.pageHeight,
|
|
352
352
|
});
|
|
353
353
|
getPageScreenInfo.pageWidth = pageWidth;
|
|
354
354
|
getPageScreenInfo.pageHeight = pageHeight;
|
|
355
355
|
}
|
|
356
356
|
return getPageScreenInfo;
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
getRootEleWindowWidthInfo() {
|
|
360
360
|
const getRootEleWidth = document.documentElement.getBoundingClientRect().width;
|
|
361
361
|
const getWindowWidth = window.innerWidth;
|
|
362
362
|
const getScreenWidth = window.screen.width;
|
|
363
363
|
return {
|
|
364
364
|
getRootEleWidth,
|
|
365
365
|
getWindowWidth,
|
|
366
366
|
getScreenWidth,
|
|
367
367
|
};
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
dealRootEleWidthFn(reportParam = {}, timeout = 0) {
|
|
371
371
|
const { getRootEleWidth, getWindowWidth, getScreenWidth } = this.getRootEleWindowWidthInfo();
|
|
372
372
|
console.log(
|
|
373
373
|
'当前获取根元素的宽度',
|
|
374
374
|
getRootEleWidth,
|
|
375
375
|
'getWindowWidth',
|
|
376
376
|
getWindowWidth,
|
|
377
377
|
'getScreenWidth',
|
|
378
378
|
getScreenWidth,
|
|
379
379
|
);
|
|
380
380
|
const getLastWidth =
|
|
381
381
|
getRootEleWidth > 0
|
|
382
382
|
? Math.round(getRootEleWidth)
|
|
383
383
|
: Math.round(getWindowWidth > 0 ? getWindowWidth : getScreenWidth);
|
|
384
384
|
console.warn(
|
|
385
385
|
`根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果超时,超时时间超时时间${timeout}ms,最终兜底再获取一次根元素宽度${getLastWidth}`,
|
|
386
386
|
);
|
|
387
387
|
timeout > 0 &&
|
|
388
388
|
draBusinessCustomReport({
|
|
389
389
|
type: 'rootEle_width_timeout_getJdScreenSizeInfo',
|
|
390
390
|
errMsg: `根元素获取宽度初始化为0,通过getJdScreenSizeInfo获取结果超时,超时时间${timeout}ms,最终兜底再获取一次根元素宽度${getLastWidth}`,
|
|
391
391
|
originReqDataStr: JSON.stringify({
|
|
392
392
|
isJdApp,
|
|
393
393
|
getRootEleWidth,
|
|
394
394
|
getWindowWidth,
|
|
395
395
|
getScreenWidth,
|
|
396
396
|
...reportParam,
|
|
397
397
|
}),
|
|
398
398
|
});
|
|
399
399
|
return getLastWidth;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
getPadWindowRootEleWidthPromise() {
|
|
403
403
|
if (this.rootEleInitWidth > 0) {
|
|
404
404
|
return Promise.resolve(this.rootEleInitWidth);
|
|
405
405
|
} else {
|
|
406
406
|
!this.rootEleWidthRegisterPromise &&
|
|
407
407
|
(this.rootEleWidthRegisterPromise = new Promise((resolve) => {
|
|
408
408
|
const getRootEleInitWidth = this.getRootEleWindowWidthInfo().getRootEleWidth;
|
|
409
409
|
if (getRootEleInitWidth > 0) {
|
|
410
410
|
console.log('初始化获取根元素宽度正常,为', getRootEleInitWidth);
|
|
411
411
|
this.rootEleInitWidth = Math.round(getRootEleInitWidth);
|
|
412
412
|
resolve(this.rootEleInitWidth);
|
|
413
413
|
} else {
|
|
414
414
|
const timerPromise = () => {
|
|
415
415
|
return new Promise((resolve2) => {
|
|
416
416
|
window.setTimeout(() => {
|
|
417
417
|
const { getRootEleWidth, getWindowWidth, getScreenWidth } =
|
|
418
418
|
this.getRootEleWindowWidthInfo();
|
|
419
419
|
if (getRootEleWidth > 0 || getWindowWidth > 0) {
|
|
420
420
|
console.warn(
|
|
421
421
|
`根元素获取宽度初始化为0,200ms后尝试获取最新结果,getRootEleWidth为${getRootEleWidth},getWindowWidth为${getWindowWidth},getScreenWidth为${getScreenWidth}`,
|
|
422
422
|
);
|
|
423
423
|
draBusinessCustomReport({
|
|
424
424
|
type: 'rootEle_width_200_timeout_info',
|
|
425
425
|
errMsg: `根元素获取宽度初始化为0,200ms后尝试获取最新结果,getRootEleWidth为${getRootEleWidth},getWindowWidth为${getWindowWidth}`,
|
|
426
426
|
originReqDataStr: JSON.stringify({
|
|
427
427
|
isJdApp,
|
|
428
428
|
getRootEleWidth,
|
|
429
429
|
getWindowWidth,
|
|
430
430
|
getScreenWidth,
|
|
431
431
|
}),
|
|
432
432
|
});
|
|
433
433
|
const getRes =
|
|
434
434
|
getRootEleWidth > 0 && getWindowWidth > 0
|
|
435
435
|
? Math.min(getRootEleWidth, getWindowWidth)
|
|
436
436
|
: Math.max(getRootEleWidth, getWindowWidth);
|
|
437
437
|
resolve2({
|
|
438
438
|
pageWidth: Math.round(getRes),
|
|
439
439
|
});
|
|
440
440
|
}
|
|
441
441
|
}, 200);
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
Promise.race([timerPromise(), this.getJdScreenSizeInfoPromise()]).then((res) => {
|
|
445
445
|
const { pageWidth } = res;
|
|
446
446
|
console.log('获取结果Promise.race getJdScreenSizeInfo', res);
|
|
447
447
|
pageWidth > 0 ? resolve(pageWidth) : resolve(this.dealRootEleWidthFn(res, 2000));
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
450
|
}));
|
|
451
451
|
return this.rootEleWidthRegisterPromise;
|
|
452
452
|
}
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
async getSystemInfo(params) {
|
|
456
456
|
const getParams = Object.assign({}, params || {});
|
|
457
457
|
if (this.rootEleInitWidth > 0) {
|
|
458
458
|
getParams['rootEleInitWidth'] = this.rootEleInitWidth;
|
|
459
459
|
console.log('获取当前系统信息的时候已经获取到根元素宽度,值为', this.rootEleInitWidth);
|
|
460
460
|
} else {
|
|
461
461
|
if (this._getJdPadMinWidthForListen()) {
|
|
462
462
|
getParams['rootEleInitWidth'] = await this.getPadWindowRootEleWidthPromise();
|
|
463
463
|
getParams['replaceSystemWidth'] = true;
|
|
464
464
|
}
|
|
465
465
|
}
|
|
466
466
|
isJdApp && this.createLanguagePromise();
|
|
467
467
|
let info: UtilsInterFace.taroGetSystemInfoSyncRes | any = getSystemInfos(getParams);
|
|
468
468
|
if (isJdAndAndroidDevice && info?.initWindowWidth <= 0) {
|
|
469
469
|
let _isfoldScreen = false;
|
|
470
470
|
const getStorageData = getTaroStorageKeyValue('jd_shopx_androidIsFoldScreen');
|
|
471
471
|
console.info(
|
|
472
472
|
'获取当前本地存储是否有jd_shopx_androidIsFoldScreen',
|
|
473
473
|
getStorageData,
|
|
474
474
|
'通过缓存值第一次判断是否是折叠屏',
|
|
475
475
|
getStorageData === 'true',
|
|
476
476
|
);
|
|
477
477
|
if (!getStorageData) {
|
|
478
478
|
_isfoldScreen = this.isAndroidFoldScreen();
|
|
479
479
|
setTaroStorage('jd_shopx_androidIsFoldScreen', `${_isfoldScreen}`);
|
|
480
480
|
} else {
|
|
481
481
|
_isfoldScreen = getStorageData === 'true';
|
|
482
482
|
}
|
|
483
483
|
if (_isfoldScreen) {
|
|
484
484
|
const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo();
|
|
485
485
|
if (getJdAndroidPageInfo) {
|
|
486
486
|
info = getSystemInfos(getJdAndroidPageInfo);
|
|
487
487
|
console.warn(
|
|
488
488
|
'当前为松果安卓折叠屏app,获取折叠屏信息',
|
|
489
489
|
getJdAndroidPageInfo,
|
|
490
490
|
'获取转换后的系统信息',
|
|
491
491
|
info,
|
|
492
492
|
);
|
|
493
493
|
sgmCustomReport({
|
|
494
494
|
type: 2,
|
|
495
495
|
code: 'android_jdapp_foldScreen_info',
|
|
496
496
|
msg: {
|
|
497
497
|
title: `松果安卓app为折叠屏,重置获取的系统宽高信息,因为获取宽高度信息初始化内部可能存在横竖屏差异`,
|
|
498
498
|
androidPageInfo: getJdAndroidPageInfo,
|
|
499
499
|
jdAppVersionStr,
|
|
500
500
|
taroSysInfo: info,
|
|
501
501
|
},
|
|
502
502
|
});
|
|
503
503
|
}
|
|
504
504
|
}
|
|
505
505
|
}
|
|
506
506
|
if (isJdApp) {
|
|
507
507
|
info?.isJdTabletDevice && this.listenJdTabletScreenChange();
|
|
508
508
|
}
|
|
509
509
|
this.info.sysInfo = {
|
|
510
510
|
actualNavBarHeight: 0,
|
|
511
511
|
...this.info.sysInfo,
|
|
512
512
|
...info,
|
|
513
513
|
safeContentHeight: info?.screenHeight,
|
|
514
514
|
headerHeight: 0,
|
|
515
515
|
tabBarHeight: 0,
|
|
516
516
|
languageType: languageNowType,
|
|
517
517
|
};
|
|
518
518
|
if (isJdApp || isH5AndJingGouMini) {
|
|
519
519
|
this.getAddressCachePromise();
|
|
520
520
|
this.getLbsAddressCachePromise();
|
|
521
521
|
}
|
|
522
522
|
if (isJdApp) {
|
|
523
523
|
this.info.sysInfo['hostVersionName'] = jdAppVersionStr;
|
|
524
524
|
this.info.sysInfo['hostAppVersion'] = jdAppVersion;
|
|
525
525
|
this.getElderModePromise();
|
|
526
526
|
this.getJDAppearanceStatePromise();
|
|
527
527
|
this.createJdAndroidRquestEventForTouchStart();
|
|
528
528
|
}
|
|
529
529
|
this.getWifiVideoAutoPlayAsync();
|
|
530
530
|
this.getMPaasConfigAsync();
|
|
531
531
|
this.getNetWorkType();
|
|
532
532
|
}
|
|
533
533
|
|
|
534
534
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
535
535
|
return new Promise((resolve) => {
|
|
536
536
|
setTimeout(() => {
|
|
537
537
|
const getCallBackRes = typeof callBack === 'function' && callBack();
|
|
538
538
|
return resolve(getCallBackRes || false);
|
|
539
539
|
}, timeout);
|
|
540
540
|
});
|
|
541
541
|
}
|
|
542
542
|
|
|
543
543
|
getElderModePromise() {
|
|
544
544
|
if (this.info.sysInfo.hasOwnProperty('jdAppModeType')) {
|
|
545
545
|
return Promise.resolve(this.info.sysInfo.jdAppModeType);
|
|
546
546
|
} else {
|
|
547
547
|
if (isJdAndAndroidDevice) {
|
|
548
548
|
this.info.sysInfo.jdAppModeType = '0';
|
|
549
549
|
return Promise.resolve(this.info.sysInfo.jdAppModeType);
|
|
550
550
|
} else {
|
|
551
551
|
return Promise.race([
|
|
552
552
|
this.taskTimeoutPromise(() => {
|
|
553
553
|
this.info.sysInfo.jdAppModeType = '0';
|
|
554
554
|
return this.info.sysInfo.jdAppModeType;
|
|
555
555
|
}),
|
|
556
556
|
new Promise((resolve) => {
|
|
557
557
|
const getCallBackName = `getJdCurrentModeType${Date.now()}`;
|
|
558
558
|
if (!window[getCallBackName]) {
|
|
559
559
|
window[getCallBackName] = (res) => {
|
|
560
560
|
try {
|
|
561
561
|
const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
|
|
562
562
|
const { status, data, msg } = getResJson;
|
|
563
563
|
console.log(`获取松果app展示模式成功,返回结果${data}`);
|
|
564
564
|
if (status === '0') {
|
|
565
565
|
this.info.sysInfo.jdAppModeType = data;
|
|
566
566
|
resolve(data);
|
|
567
567
|
} else {
|
|
568
568
|
resolve('0');
|
|
569
569
|
}
|
|
570
570
|
} catch (e) {
|
|
571
571
|
resolve('0');
|
|
572
572
|
}
|
|
573
573
|
window[getCallBackName] = null;
|
|
574
574
|
};
|
|
575
575
|
}
|
|
576
576
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
577
577
|
method: 'callSyncRouterModuleWithParams',
|
|
578
578
|
params: JSON.stringify({
|
|
579
579
|
routerURL: 'router://JDBModeModule/getCurrentMode',
|
|
580
580
|
routerParam: {},
|
|
581
581
|
callBackName: `window.${getCallBackName}`,
|
|
582
582
|
callBackId: `${getCallBackName}Ios`,
|
|
583
583
|
}),
|
|
584
584
|
});
|
|
585
585
|
}),
|
|
586
586
|
]);
|
|
587
587
|
}
|
|
588
588
|
}
|
|
589
589
|
}
|
|
590
590
|
getAPPUseStraightCorner() {
|
|
591
591
|
const routerURL = 'router://JDBaseUtilsModule/isUI14Enable';
|
|
592
592
|
const params = {
|
|
593
593
|
routerURL,
|
|
594
594
|
routerParam: {},
|
|
595
595
|
jdRouter: '1',
|
|
596
596
|
};
|
|
597
597
|
if (this.info.sysInfo.hasOwnProperty('jdStraightCorner')) {
|
|
598
598
|
return Promise.resolve(this.info.sysInfo.jdStraightCorner);
|
|
599
599
|
} else {
|
|
600
600
|
return this.jmfeReayPromise()
|
|
601
601
|
.then(() => {
|
|
602
602
|
if (isJdAndHarmonyDevice || !isJdApp) {
|
|
603
603
|
console.log('not APP or is Harmony');
|
|
604
604
|
return Promise.resolve(false);
|
|
605
605
|
}
|
|
606
606
|
console.log('jmfe setShareInfo', params);
|
|
607
607
|
return Promise.race([
|
|
608
608
|
window.jmfe.callRouter(params),
|
|
609
609
|
this.taskTimeoutPromise(() => {
|
|
610
610
|
return false;
|
|
611
611
|
}),
|
|
612
612
|
]).then(({ status, data }) => {
|
|
613
613
|
console.log('004 ~ file: index.tsx:133 ~ .then ~ data:', data);
|
|
614
614
|
console.log('004 ~ file: index.tsx:133 ~ .then ~ status:', status);
|
|
615
615
|
this.info.sysInfo.jdStraightCorner = status === '0' && Number(data) === 1;
|
|
616
616
|
return Promise.resolve(status === '0' && Number(data) === 1);
|
|
617
617
|
});
|
|
618
618
|
})
|
|
619
619
|
.catch((e) => {
|
|
620
620
|
console.log('jmfe error', e);
|
|
621
621
|
return Promise.resolve(false);
|
|
622
622
|
});
|
|
623
623
|
}
|
|
624
624
|
}
|
|
625
625
|
|
|
626
626
|
getJDAppearanceStatePromise() {
|
|
627
627
|
if (this.info.sysInfo.hasOwnProperty('jdAppearanceState')) {
|
|
628
628
|
return Promise.resolve(this.info.sysInfo.jdAppearanceState);
|
|
629
629
|
} else {
|
|
630
630
|
return Promise.race([
|
|
631
631
|
this.taskTimeoutPromise(() => {
|
|
632
632
|
this.info.sysInfo.jdAppearanceState = '0';
|
|
633
633
|
return this.info.sysInfo.jdAppearanceState;
|
|
634
634
|
}),
|
|
635
635
|
new Promise((resolve) => {
|
|
636
636
|
const getCallBackName = `getJdCurrentAppearanceState${Date.now()}`;
|
|
637
637
|
if (!window[getCallBackName]) {
|
|
638
638
|
window[getCallBackName] = (res) => {
|
|
639
639
|
try {
|
|
640
640
|
console.log('getJDAppearanceStatePromise', res);
|
|
641
641
|
const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
|
|
642
642
|
const { status, data, msg } = getResJson;
|
|
643
643
|
console.log(`获取松果app是否开启黑暗模式成功,返回结果${data}`);
|
|
644
644
|
if (status === '0') {
|
|
645
645
|
this.info.sysInfo.jdAppearanceState = data;
|
|
646
646
|
resolve(data);
|
|
647
647
|
} else {
|
|
648
648
|
resolve('0');
|
|
649
649
|
}
|
|
650
650
|
} catch (e) {
|
|
651
651
|
resolve('0');
|
|
652
652
|
}
|
|
653
653
|
window[getCallBackName] = null;
|
|
654
654
|
};
|
|
655
655
|
}
|
|
656
656
|
if (isAndroidDevice) {
|
|
657
657
|
const jsonString = JSON.stringify({
|
|
658
658
|
callBackName: `window.${getCallBackName}`,
|
|
659
659
|
});
|
|
660
660
|
console.log('window.JDAppearance', window?.JDAppearance);
|
|
661
661
|
window?.JDAppearance &&
|
|
662
662
|
window?.JDAppearance?.getUiState &&
|
|
663
663
|
window.JDAppearance.getUiState(jsonString);
|
|
664
664
|
} else {
|
|
665
665
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
666
666
|
method: 'callSyncRouterModuleWithParams',
|
|
667
667
|
params: JSON.stringify({
|
|
668
668
|
routerURL: 'router://JDWebViewBusinessModule/getJDAppearanceState',
|
|
669
669
|
routerParam: {},
|
|
670
670
|
callBackName: `window.${getCallBackName}`,
|
|
671
671
|
callBackId: `${getCallBackName}Ios`,
|
|
672
672
|
}),
|
|
673
673
|
});
|
|
674
674
|
}
|
|
675
675
|
}),
|
|
676
676
|
]);
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
679
|
|
|
680
680
|
createJdAndroidRquestEventForTouchStart() {
|
|
681
681
|
if (isJdAndAndroidDevice && window?.JdAndroid) {
|
|
682
682
|
const rootEleNode = document.querySelector('body');
|
|
683
683
|
if (rootEleNode) {
|
|
684
684
|
rootEleNode.addEventListener('touchstart', this.jdAndroidAddEventListenerTouchStart, false);
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
jdAndroidAddEventListenerTouchStart(e) {
|
|
689
689
|
const isH5SwiperCustomEle = e?.target?.closest('.J_h5SwiperCustom');
|
|
690
690
|
if (!isH5SwiperCustomEle && window?.JdAndroid) {
|
|
691
691
|
const hasCustomEle = e
|
|
692
692
|
? e?.target?.closest('.J_customScroll') || e?.target?.closest('.J_customLayout')
|
|
693
693
|
: false;
|
|
694
694
|
if (!hasCustomEle) {
|
|
695
695
|
window?.JdAndroid?.requestEvent && window.JdAndroid.requestEvent(false);
|
|
696
696
|
console.log(
|
|
697
697
|
'createJdAndroidRquestEvent 所有松果安卓APP内的document touch start事件执行检测requestEvent并重置为false',
|
|
698
698
|
);
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
}
|
|
702
702
|
removeJdAndroidRquestEventForTouchStart() {
|
|
703
703
|
if (isJdAndAndroidDevice && window.JdAndroid) {
|
|
704
704
|
const rootEleNode = document.querySelector('body');
|
|
705
705
|
if (rootEleNode) {
|
|
706
706
|
rootEleNode.removeEventListener(
|
|
707
707
|
'touchstart',
|
|
708
708
|
this.jdAndroidAddEventListenerTouchStart,
|
|
709
709
|
false,
|
|
710
710
|
);
|
|
711
711
|
}
|
|
712
712
|
}
|
|
713
713
|
}
|
|
714
714
|
|
|
715
715
|
getNetWorkType() {
|
|
716
716
|
if (isJdApp) {
|
|
717
717
|
this.jmfeReayPromise().then(() => {
|
|
718
718
|
window.jmfe
|
|
719
719
|
.getNetworkStatus()
|
|
720
720
|
.then(({ status, data }) => {
|
|
721
721
|
console.log('在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====', data);
|
|
722
722
|
if (status === '0') {
|
|
723
723
|
this.info.sysInfo['netWorkType'] = data;
|
|
724
724
|
} else {
|
|
725
725
|
this._taroGetNetworkType();
|
|
726
726
|
}
|
|
727
727
|
})
|
|
728
728
|
.catch((err) => {
|
|
729
729
|
console.log('在app内初始化通过jmfe对象获取网络状态异常====', err);
|
|
730
730
|
this._taroGetNetworkType();
|
|
731
731
|
});
|
|
732
732
|
});
|
|
733
733
|
} else {
|
|
734
734
|
this._taroGetNetworkType();
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
737
|
_taroGetNetworkType() {
|
|
738
738
|
Taro.getNetworkType().then((getRes) => {
|
|
739
739
|
if (getRes && getRes.networkType) {
|
|
740
740
|
this.info.sysInfo['netWorkType'] = getRes.networkType;
|
|
741
741
|
console.log(
|
|
742
742
|
'在app内通过taro对象获取网络状态完成,当前网络状态',
|
|
743
743
|
this.info.sysInfo['netWorkType'],
|
|
744
744
|
);
|
|
745
745
|
}
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
getCacheAddressRouter() {
|
|
750
750
|
if (isJdApp) {
|
|
751
751
|
if (!isJdAndHarmonyDevice) {
|
|
752
752
|
return Promise.race([
|
|
753
753
|
new Promise((resolve) => {
|
|
754
754
|
const getCallBackName = `getJdCacheAddress${Date.now()}`;
|
|
755
755
|
if (!window[getCallBackName]) {
|
|
756
756
|
window[getCallBackName] = (res) => {
|
|
757
757
|
console.warn(`获取松果appGetJdCacheAddressRes,返回结果`, res);
|
|
758
758
|
try {
|
|
759
759
|
const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
|
|
760
760
|
resolve(getResJson);
|
|
761
761
|
} catch (e) {
|
|
762
762
|
resolve({
|
|
763
763
|
status: '-1002',
|
|
764
764
|
msg: '地址信息解析json异常',
|
|
765
765
|
res,
|
|
766
766
|
});
|
|
767
767
|
}
|
|
768
768
|
window[getCallBackName] = null;
|
|
769
769
|
};
|
|
770
770
|
}
|
|
771
771
|
const getRouterParam = {
|
|
772
772
|
sceneId: 'basicShoppingProcess',
|
|
773
773
|
};
|
|
774
774
|
if (isAndroidDevice) {
|
|
775
775
|
return callRouterAndroid({
|
|
776
776
|
routerURL: 'router://JDAddressModule/getCacheAddress',
|
|
777
777
|
routerParam: getRouterParam,
|
|
778
778
|
callBackName: getCallBackName,
|
|
779
779
|
isSync: true,
|
|
780
780
|
});
|
|
781
781
|
} else {
|
|
782
782
|
return callRouterIOS({
|
|
783
783
|
routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
|
|
784
784
|
routerParam: getRouterParam,
|
|
785
785
|
callBackName: getCallBackName,
|
|
786
786
|
});
|
|
787
787
|
}
|
|
788
788
|
}),
|
|
789
789
|
this.taskTimeoutPromise(() => {
|
|
790
790
|
return {
|
|
791
791
|
status: '-1000',
|
|
792
792
|
msg: '原生router协议获取地址信息超时',
|
|
793
793
|
};
|
|
794
794
|
}, 3000),
|
|
795
795
|
]);
|
|
796
796
|
} else {
|
|
797
797
|
return Promise.resolve({
|
|
798
798
|
status: '-1001',
|
|
799
799
|
msg: '鸿蒙系统调用jmfe异常,获取失败',
|
|
800
800
|
});
|
|
801
801
|
}
|
|
802
802
|
} else if (isH5AndJingGouMini) {
|
|
803
803
|
const { areaId, addressName } = this.getJingGouMiniInh5Address();
|
|
804
804
|
if (areaId && areaId !== '' && addressName && addressName !== '') {
|
|
805
805
|
return Promise.resolve({
|
|
806
806
|
status: '0',
|
|
807
807
|
data: {
|
|
808
808
|
areaId,
|
|
809
809
|
fullAddress: addressName,
|
|
810
810
|
},
|
|
811
811
|
});
|
|
812
812
|
} else {
|
|
813
813
|
return Promise.resolve({
|
|
814
814
|
status: '-1002',
|
|
815
815
|
msg: '京购内嵌h5h5暂无业务需要,未实现,获取失败',
|
|
816
816
|
});
|
|
817
817
|
}
|
|
818
818
|
} else {
|
|
819
819
|
return Promise.resolve({
|
|
820
820
|
status: '-1002',
|
|
821
821
|
msg: '普通h5暂无业务需要,未实现,获取失败',
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
824
|
}
|
|
825
825
|
|
|
826
826
|
getJingGouMiniInh5Address() {
|
|
827
827
|
let getRes: any = {
|
|
828
828
|
areaId: '',
|
|
829
829
|
addressName: '',
|
|
830
830
|
};
|
|
831
831
|
try {
|
|
832
832
|
const getUrlHast = decodeURIComponent(window.location.hash);
|
|
833
833
|
const sensMatch = getUrlHast ? getUrlHast.match(/sens=({.*?})/) : null;
|
|
834
834
|
if (sensMatch && sensMatch[1]) {
|
|
835
835
|
const sensData = JSON.parse(sensMatch[1]);
|
|
836
836
|
const getWqAddr = sensData?.wq_addr || '';
|
|
837
837
|
if (getWqAddr && /\|/.test(getWqAddr)) {
|
|
838
838
|
const addressList = getWqAddr.split(/\|/);
|
|
839
839
|
const [addressId, areaId, areaName, addressName, coordinate] = addressList;
|
|
840
840
|
getRes = {
|
|
841
841
|
addressId,
|
|
842
842
|
areaId,
|
|
843
843
|
areaName,
|
|
844
844
|
addressName,
|
|
845
845
|
coordinate,
|
|
846
846
|
};
|
|
847
847
|
}
|
|
848
848
|
}
|
|
849
849
|
} catch (e) {
|
|
850
850
|
console.log('获取hash转换异常', e);
|
|
851
851
|
}
|
|
852
852
|
return getRes;
|
|
853
853
|
}
|
|
854
854
|
|
|
855
855
|
getAddressCachePromise() {
|
|
856
856
|
return new Promise((resolve) => {
|
|
857
857
|
if (this?.info?.sysInfo?.lat && this?.info?.sysInfo?.lng && this?.info?.sysInfo?.area) {
|
|
858
858
|
resolve({
|
|
859
859
|
lat: this.info.sysInfo.lat,
|
|
860
860
|
lng: this.info.sysInfo.lng,
|
|
861
861
|
area: this?.info?.sysInfo?.area,
|
|
862
862
|
fullAddress: this?.info?.pageInfo?.fullAddress,
|
|
863
863
|
});
|
|
864
864
|
} else {
|
|
865
865
|
this.getCacheAddressRouter()
|
|
866
866
|
.then((res) => {
|
|
867
867
|
const { status, data } = res;
|
|
868
868
|
console.log('原生端获取经纬度及四级地址原始数据结果', status, data, res);
|
|
869
869
|
if (status === '0' && data) {
|
|
870
870
|
const {
|
|
871
871
|
lat,
|
|
872
872
|
latitude,
|
|
873
873
|
lng,
|
|
874
874
|
longitude,
|
|
875
875
|
provinceId,
|
|
876
876
|
cityId,
|
|
877
877
|
countyId,
|
|
878
878
|
townId,
|
|
879
879
|
fullAddress,
|
|
880
880
|
areaId,
|
|
881
881
|
} = data || {};
|
|
882
882
|
const getAreaIdsEnable = areaId && areaId !== '';
|
|
883
883
|
const getEncodeFullAddress = fullAddress ? encodeURIComponent(fullAddress) : '';
|
|
884
884
|
let area = getAreaIdsEnable ? areaId : '';
|
|
885
885
|
this.info.sysInfo['lat'] = `${lat || latitude || ''}`;
|
|
886
886
|
this.info.sysInfo['lng'] = `${lng || longitude || ''}`;
|
|
887
887
|
const getProvinceIdNum = provinceId ? Number(provinceId) : 0;
|
|
888
888
|
if ((getProvinceIdNum && getProvinceIdNum > 0) || getAreaIdsEnable) {
|
|
889
889
|
area = getAreaIdsEnable
|
|
890
890
|
? areaId
|
|
891
891
|
: `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
|
|
892
892
|
this.info.pageInfo['address'] = area;
|
|
893
893
|
this.info.pageInfo['addressCommaStr'] = area.replace(/_/g, ',');
|
|
894
894
|
this.info.sysInfo['area'] = area;
|
|
895
895
|
const getUpdateData = {
|
|
896
896
|
area: this.info.pageInfo.address,
|
|
897
897
|
};
|
|
898
898
|
if (fullAddress && fullAddress.length > 0) {
|
|
899
899
|
getUpdateData['fullAddress'] = getEncodeFullAddress;
|
|
900
900
|
this.info.pageInfo['fullAddress'] = getEncodeFullAddress;
|
|
901
901
|
}
|
|
902
902
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, getUpdateData);
|
|
903
903
|
}
|
|
904
904
|
resolve({
|
|
905
905
|
lat: this.info.sysInfo['lat'],
|
|
906
906
|
lng: this.info.sysInfo['lng'],
|
|
907
907
|
fullAddress: getEncodeFullAddress,
|
|
908
908
|
area: area,
|
|
909
909
|
});
|
|
910
910
|
} else {
|
|
911
911
|
if (typeof res === 'object') {
|
|
912
912
|
draBusinessCustomReport({
|
|
913
913
|
type: 'jdapp_getCacheAddress_info_err',
|
|
914
914
|
errMsg: '松果app内通过router协议获取用户地址及经纬度信息异常',
|
|
915
915
|
originReqDataStr: JSON.stringify({
|
|
916
916
|
isJdApp,
|
|
917
917
|
jdAppVersion: jdAppVersionStr,
|
|
918
918
|
...res,
|
|
919
919
|
}),
|
|
920
920
|
});
|
|
921
921
|
}
|
|
922
922
|
resolve({ lat: '', lng: '', area: '', fullAddress: '' });
|
|
923
923
|
}
|
|
924
924
|
})
|
|
925
925
|
.catch((e) => {
|
|
926
926
|
console.log('getCacheAddressRouter catch e,获取经纬度信息异常e', e);
|
|
927
927
|
draBusinessCustomReport({
|
|
928
928
|
type: 'jdapp_getCacheAddress_info_catch_err',
|
|
929
929
|
errMsg: '松果app内通过router协议获取用户地址及经纬度信息catch异常',
|
|
930
930
|
originReqDataStr: JSON.stringify({
|
|
931
931
|
isJdApp,
|
|
932
932
|
jdAppVersion: jdAppVersionStr,
|
|
933
933
|
}),
|
|
934
934
|
});
|
|
935
935
|
resolve({ lat: '', lng: '', area: '', fullAddress: '' });
|
|
936
936
|
});
|
|
937
937
|
}
|
|
938
938
|
});
|
|
939
939
|
}
|
|
940
940
|
|
|
941
941
|
getLbsCacheAddressRouter() {
|
|
942
942
|
if (isJdApp) {
|
|
943
943
|
if (!isJdAndHarmonyDevice) {
|
|
944
944
|
return Promise.race([
|
|
945
945
|
new Promise((resolve) => {
|
|
946
946
|
const getCallBackName = `getJdLbsCacheAddress${Date.now()}`;
|
|
947
947
|
if (!window[getCallBackName]) {
|
|
948
948
|
window[getCallBackName] = (res) => {
|
|
949
949
|
console.warn(`获取松果appGetJdLbsCacheAddressRes,返回结果`, res);
|
|
950
950
|
try {
|
|
951
951
|
const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
|
|
952
952
|
resolve(getResJson);
|
|
953
953
|
} catch (e) {
|
|
954
954
|
resolve({
|
|
955
955
|
status: '-1002',
|
|
956
956
|
msg: '地址信息解析json异常',
|
|
957
957
|
res,
|
|
958
958
|
});
|
|
959
959
|
}
|
|
960
960
|
window[getCallBackName] = null;
|
|
961
961
|
};
|
|
962
962
|
}
|
|
963
963
|
const getRouterParam = {
|
|
964
964
|
appid: '219f70bbbf7e4ede7968bedaa1beafb4',
|
|
965
965
|
sceneId: 'basicShoppingProcess',
|
|
966
966
|
};
|
|
967
967
|
if (isAndroidDevice) {
|
|
968
968
|
return callRouterAndroid({
|
|
969
969
|
routerURL: 'router://com.jingdong.app.mall.location.JSLocationManager/getLocation',
|
|
970
970
|
routerParam: getRouterParam,
|
|
971
971
|
callBackName: getCallBackName,
|
|
972
972
|
isSync: true,
|
|
973
973
|
hasJdRouter: false,
|
|
974
974
|
});
|
|
975
975
|
} else {
|
|
976
976
|
return callRouterIOS({
|
|
977
977
|
routerURL: 'router://JDBLBSKitModule/getCacheAddressInfo',
|
|
978
978
|
routerParam: getRouterParam,
|
|
979
979
|
callBackName: getCallBackName,
|
|
980
980
|
isSync: true,
|
|
981
981
|
});
|
|
982
982
|
}
|
|
983
983
|
}),
|
|
984
984
|
this.taskTimeoutPromise(() => {
|
|
985
985
|
return {
|
|
986
986
|
status: '-1000',
|
|
987
987
|
msg: '原生router协议获取lbs地址信息3s超时',
|
|
988
988
|
};
|
|
989
989
|
}, 3000),
|
|
990
990
|
]);
|
|
991
991
|
} else {
|
|
992
992
|
return Promise.resolve({
|
|
993
993
|
status: '-1001',
|
|
994
994
|
msg: '鸿蒙系统调用未实现,获取失败',
|
|
995
995
|
});
|
|
996
996
|
}
|
|
997
997
|
} else if (isH5AndJingGouMini) {
|
|
998
998
|
return this.getLocationForGpsPromise();
|
|
999
999
|
} else {
|
|
1000
1000
|
return Promise.resolve({
|
|
1001
1001
|
status: '-1002',
|
|
1002
1002
|
msg: '普通h5暂无业务需要,未实现,获取失败',
|
|
1003
1003
|
});
|
|
1004
1004
|
}
|
|
1005
1005
|
}
|
|
1006
1006
|
getLocationForGpsPromise() {
|
|
1007
1007
|
return new Promise((resolve) => {
|
|
1008
1008
|
let hasGetLocationForGps = true;
|
|
1009
1009
|
if (urlCookie && urlCookie['loc']) {
|
|
1010
1010
|
const [provinceid = 0, cityid = 0, districtid = 0, townid = 0] =
|
|
1011
1011
|
urlCookie['loc'].split('_');
|
|
1012
1012
|
const getProvinceIdNum = provinceid ? Number(provinceid) : 0;
|
|
1013
1013
|
if (getProvinceIdNum && getProvinceIdNum > 0) {
|
|
1014
1014
|
hasGetLocationForGps = false;
|
|
1015
1015
|
resolve({
|
|
1016
1016
|
status: '0',
|
|
1017
1017
|
data: {
|
|
1018
1018
|
provinceid,
|
|
1019
1019
|
cityid,
|
|
1020
1020
|
districtid,
|
|
1021
1021
|
townid,
|
|
1022
1022
|
origin: 'wxapp',
|
|
1023
1023
|
},
|
|
1024
1024
|
});
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
if (hasGetLocationForGps && window?.navigator?.geolocation) {
|
|
1028
1028
|
window.navigator.geolocation.getCurrentPosition(
|
|
1029
1029
|
(position) => {
|
|
1030
1030
|
console.log('h5 浏览器通过原生geolocation获取经纬度结果', position?.coords);
|
|
1031
1031
|
if (position?.coords) {
|
|
1032
1032
|
resolve({
|
|
1033
1033
|
status: '0',
|
|
1034
1034
|
data: {
|
|
1035
1035
|
srclat: position.coords?.latitude,
|
|
1036
1036
|
srclng: position.coords.longitude,
|
|
1037
1037
|
origin: 'h5',
|
|
1038
1038
|
},
|
|
1039
1039
|
});
|
|
1040
1040
|
} else {
|
|
1041
1041
|
resolve({
|
|
1042
1042
|
status: '-1001',
|
|
1043
1043
|
msg: 'h5 浏览器通过原生geolocation获取经纬度结果异常,详情见position',
|
|
1044
1044
|
position,
|
|
1045
1045
|
});
|
|
1046
1046
|
}
|
|
1047
1047
|
},
|
|
1048
1048
|
(error) => {
|
|
1049
1049
|
resolve({
|
|
1050
1050
|
status: '-1001',
|
|
1051
1051
|
msg: 'h5 浏览器通过原生geolocation获取经纬度结果定位异常,详情见error',
|
|
1052
1052
|
error,
|
|
1053
1053
|
});
|
|
1054
1054
|
},
|
|
1055
1055
|
{
|
|
1056
1056
|
enableHighAccuracy: false,
|
|
1057
1057
|
timeout: 3 * 1000,
|
|
1058
1058
|
maximumAge: 10 * 60 * 1000,
|
|
1059
1059
|
},
|
|
1060
1060
|
);
|
|
1061
1061
|
} else {
|
|
1062
1062
|
resolve({
|
|
1063
1063
|
status: '-1001',
|
|
1064
1064
|
msg: '您的浏览器不支持地理定位',
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
1067
|
});
|
|
1068
1068
|
}
|
|
1069
1069
|
|
|
1070
1070
|
createLbsCacheAddress(realTimeArea) {
|
|
1071
1071
|
const getLbsAddressCacheMinuteTime = Number(
|
|
1072
1072
|
window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime || 0,
|
|
1073
1073
|
);
|
|
1074
1074
|
console.log(
|
|
1075
1075
|
'获取lbs缓存到cookie的时间,分钟',
|
|
1076
1076
|
getLbsAddressCacheMinuteTime,
|
|
1077
1077
|
'lbsAddressCacheToCookieMinuteTime',
|
|
1078
1078
|
window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime,
|
|
1079
1079
|
);
|
|
1080
1080
|
if (getLbsAddressCacheMinuteTime > 0) {
|
|
1081
1081
|
const expires = new Date(Date.now() + getLbsAddressCacheMinuteTime * 60 * 1000);
|
|
1082
1082
|
realTimeArea &&
|
|
1083
1083
|
cookie.set(cacheH5LbsAddressKey, realTimeArea, {
|
|
1084
1084
|
path: '/',
|
|
1085
1085
|
expires,
|
|
1086
1086
|
});
|
|
1087
1087
|
}
|
|
1088
1088
|
}
|
|
1089
1089
|
|
|
1090
1090
|
getLbsAddressCachePromise() {
|
|
1091
1091
|
if (!this.lbsAddressCachePromise) {
|
|
1092
1092
|
this.lbsAddressCachePromise = new Promise((resolve) => {
|
|
1093
1093
|
const getCookieForLbsAddress = window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime
|
|
1094
1094
|
? cookie.get(cacheH5LbsAddressKey)
|
|
1095
1095
|
: '';
|
|
1096
1096
|
const getUserLbsAddress = this?.info?.pageInfo?.userLbsAddress;
|
|
1097
1097
|
if (getUserLbsAddress && getUserLbsAddress !== '') {
|
|
1098
1098
|
resolve({
|
|
1099
1099
|
ok: true,
|
|
1100
1100
|
realTimeArea: getUserLbsAddress,
|
|
1101
1101
|
});
|
|
1102
1102
|
} else if (getCookieForLbsAddress && getCookieForLbsAddress !== '') {
|
|
1103
1103
|
console.info(
|
|
1104
1104
|
`通过cookie获取缓存的userLbsAddress,${window?.shopGlobalSwitch?.lbsAddressCacheToCookieMinuteTime}分钟内有效`,
|
|
1105
1105
|
getCookieForLbsAddress,
|
|
1106
1106
|
);
|
|
1107
1107
|
this.info.pageInfo['userLbsAddress'] = getCookieForLbsAddress;
|
|
1108
1108
|
this.info.sysInfo['realTimeArea'] = getCookieForLbsAddress;
|
|
1109
1109
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
1110
1110
|
realTimeArea: getCookieForLbsAddress,
|
|
1111
1111
|
});
|
|
1112
1112
|
resolve({
|
|
1113
1113
|
ok: true,
|
|
1114
1114
|
realTimeArea: getCookieForLbsAddress,
|
|
1115
1115
|
});
|
|
1116
1116
|
} else {
|
|
1117
1117
|
this.getLbsCacheAddressRouter()
|
|
1118
1118
|
.then((res) => {
|
|
1119
1119
|
const { status, data } = res;
|
|
1120
1120
|
console.log(
|
|
1121
1121
|
'原生或者内嵌京购端获取基于lbs的经纬度及四级地址原始数据结果',
|
|
1122
1122
|
status,
|
|
1123
1123
|
data,
|
|
1124
1124
|
res,
|
|
1125
1125
|
);
|
|
1126
1126
|
if (status === '0' && data) {
|
|
1127
1127
|
const { srclat, srclng, provinceid, cityid, districtid, townid, origin } =
|
|
1128
1128
|
data || {};
|
|
1129
1129
|
let realTimeArea = '';
|
|
1130
1130
|
this.info.sysInfo['srclat'] = `${srclat || ''}`;
|
|
1131
1131
|
this.info.sysInfo['srclng'] = `${srclng || ''}`;
|
|
1132
1132
|
const getProvinceIdNum = provinceid ? Number(provinceid) : 0;
|
|
1133
1133
|
if (getProvinceIdNum && getProvinceIdNum > 0) {
|
|
1134
1134
|
realTimeArea = `${provinceid}_${cityid || 0}_${districtid || 0}_${townid || 0}`;
|
|
1135
1135
|
this.info.pageInfo['userLbsAddress'] = realTimeArea;
|
|
1136
1136
|
this.info.sysInfo['realTimeArea'] = realTimeArea;
|
|
1137
1137
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
1138
1138
|
realTimeArea: this.info.pageInfo.userLbsAddress,
|
|
1139
1139
|
});
|
|
1140
1140
|
this.createLbsCacheAddress(realTimeArea);
|
|
1141
1141
|
} else {
|
|
1142
1142
|
!origin && (this.lbsAddressCachePromise = null);
|
|
1143
1143
|
}
|
|
1144
1144
|
const getValidRealTimeArea = realTimeArea !== '';
|
|
1145
1145
|
resolve({
|
|
1146
1146
|
lat: this.info.sysInfo['srclat'],
|
|
1147
1147
|
lng: this.info.sysInfo['srclng'],
|
|
1148
1148
|
realTimeArea: realTimeArea,
|
|
1149
1149
|
ok: getValidRealTimeArea,
|
|
1150
1150
|
msg: getValidRealTimeArea
|
|
1151
1151
|
? '成功'
|
|
1152
1152
|
: origin
|
|
1153
1153
|
? origin
|
|
1154
1154
|
: '根据router底层获取lbs地址信息异常,详情见data',
|
|
1155
1155
|
data: getValidRealTimeArea ? null : res,
|
|
1156
1156
|
});
|
|
1157
1157
|
if (!getValidRealTimeArea && !origin) {
|
|
1158
1158
|
draBusinessCustomReport({
|
|
1159
1159
|
type: 'h5_getLbsCacheAddress_info_err',
|
|
1160
1160
|
errMsg: '松果app内通过router协议获取基于lbs实时用户地址及经纬度信息catch异常',
|
|
1161
1161
|
originReqDataStr: JSON.stringify({
|
|
1162
1162
|
isJdApp,
|
|
1163
1163
|
jdAppVersion: jdAppVersionStr,
|
|
1164
1164
|
}),
|
|
1165
1165
|
});
|
|
1166
1166
|
}
|
|
1167
1167
|
} else {
|
|
1168
1168
|
typeof res === 'object' &&
|
|
1169
1169
|
draBusinessCustomReport({
|
|
1170
1170
|
type: 'h5_getLbsCacheAddress_info_err',
|
|
1171
1171
|
errMsg:
|
|
1172
1172
|
'h5通过router协议或者浏览器gps获取基于lbs实时用户缓存地址及经纬度信息异常',
|
|
1173
1173
|
originReqDataStr: JSON.stringify({
|
|
1174
1174
|
isJdApp,
|
|
1175
1175
|
jdAppVersion: jdAppVersionStr,
|
|
1176
1176
|
...res,
|
|
1177
1177
|
}),
|
|
1178
1178
|
});
|
|
1179
1179
|
this.lbsAddressCachePromise = null;
|
|
1180
1180
|
resolve({ realTimeArea: '', ok: false });
|
|
1181
1181
|
}
|
|
1182
1182
|
})
|
|
1183
1183
|
.catch((e) => {
|
|
1184
1184
|
console.log('getLbsAddressCachePromise catch e,获取经纬度信息异常e', e);
|
|
1185
1185
|
this.lbsAddressCachePromise = null;
|
|
1186
1186
|
draBusinessCustomReport({
|
|
1187
1187
|
type: 'h5_getLbsCacheAddress_info_err',
|
|
1188
1188
|
errMsg:
|
|
1189
1189
|
'h5内通过router协议获取浏览器gps获取基于lbs实时用户地址及经纬度信息catch异常',
|
|
1190
1190
|
originReqDataStr: JSON.stringify({
|
|
1191
1191
|
isJdApp,
|
|
1192
1192
|
jdAppVersion: jdAppVersionStr,
|
|
1193
1193
|
}),
|
|
1194
1194
|
});
|
|
1195
1195
|
resolve({ realTimeArea: '', ok: false });
|
|
1196
1196
|
});
|
|
1197
1197
|
}
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
1200
|
return this.lbsAddressCachePromise;
|
|
1201
1201
|
}
|
|
1202
1202
|
|
|
1203
1203
|
async updateMPaasConfigAsync(isBeforePageReady: boolean) {
|
|
1204
1204
|
console.log('updateMPaasConfigAsync isBeforePageReady:', isBeforePageReady);
|
|
1205
1205
|
if (!isJdApp) {
|
|
1206
1206
|
return;
|
|
1207
1207
|
}
|
|
1208
1208
|
const avifSwitch = await getMPaasConfigByBussinessKey('avifSwitch', isBeforePageReady);
|
|
1209
1209
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = avifSwitch;
|
|
1210
1210
|
const hybridHttpSwitch = await getMPaasConfigByBussinessKey(
|
|
1211
1211
|
'hybridHttpSwitch',
|
|
1212
1212
|
isBeforePageReady,
|
|
1213
1213
|
);
|
|
1214
1214
|
const jshopIsVipShopSwitch = await getMPaasConfigByBussinessKey(
|
|
1215
1215
|
'jshopIsVipShop',
|
|
1216
1216
|
isBeforePageReady,
|
|
1217
1217
|
);
|
|
1218
1218
|
this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = hybridHttpSwitch;
|
|
1219
1219
|
this.info.sysInfo.dynamicConfig['jshopIsVipShopSwitch'] = jshopIsVipShopSwitch;
|
|
1220
1220
|
const isFollowAppVideoPlayStatus = await getMPaasConfigByBussinessKey(
|
|
1221
1221
|
'isFollowAppVideoPlayStatus',
|
|
1222
1222
|
isBeforePageReady,
|
|
1223
1223
|
);
|
|
1224
1224
|
console.log(
|
|
1225
1225
|
'isBeforePageReady:',
|
|
1226
1226
|
isBeforePageReady,
|
|
1227
1227
|
'isFollowAppVideoPlayStatus:',
|
|
1228
1228
|
isFollowAppVideoPlayStatus,
|
|
1229
1229
|
);
|
|
1230
1230
|
if (isFollowAppVideoPlayStatus === true || isFollowAppVideoPlayStatus === 'true') {
|
|
1231
1231
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = true;
|
|
1232
1232
|
}
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
1235
|
async getWifiVideoAutoPlayAsync() {
|
|
1236
1236
|
this.info.sysInfo['wifiVideoAutoPlay'] = false;
|
|
1237
1237
|
if (!isJdApp) {
|
|
1238
1238
|
return;
|
|
1239
1239
|
}
|
|
1240
1240
|
const videoPlayStatus = await getWifiVideoAutoPlay().catch((e) => {
|
|
1241
1241
|
return 0;
|
|
1242
1242
|
});
|
|
1243
1243
|
if (Number(videoPlayStatus) === 1) {
|
|
1244
1244
|
this.info.sysInfo['wifiVideoAutoPlay'] = true;
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
|
|
1248
1248
|
async getMPaasConfigAsync() {
|
|
1249
1249
|
this.info.sysInfo.dynamicConfig = {};
|
|
1250
1250
|
this.info.sysInfo.dynamicConfig['avifSwitch'] = {};
|
|
1251
1251
|
this.info.sysInfo.dynamicConfig['hybridHttpSwitch'] = {};
|
|
1252
1252
|
this.info.sysInfo.dynamicConfig['jshopIsVipShopSwitch'] = {};
|
|
1253
1253
|
this.info.sysInfo.dynamicConfig['isFollowAppVideoPlayStatus'] = false;
|
|
1254
1254
|
return this.updateMPaasConfigAsync(true);
|
|
1255
1255
|
}
|
|
1256
1256
|
|
|
1257
1257
|
getDynamicConfig(key: string) {
|
|
1258
1258
|
return this.info.sysInfo?.dynamicConfig?.[key];
|
|
1259
1259
|
}
|
|
1260
1260
|
async updateMPaasConfig() {
|
|
1261
1261
|
console.log('updateMPaasConfig');
|
|
1262
1262
|
if (
|
|
1263
1263
|
isIosDevice &&
|
|
1264
1264
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_VERSION) < 0 &&
|
|
1265
1265
|
versionCompare(jdAppVersionStr, MPAAS_CONFIG_APP_LOW_VERSION) >= 0
|
|
1266
1266
|
) {
|
|
1267
1267
|
try {
|
|
1268
1268
|
await this.updateMPaasConfigAsync(false);
|
|
1269
1269
|
} catch (e) {
|
|
1270
1270
|
console.log('updateMPaasConfigAsync:', e);
|
|
1271
1271
|
}
|
|
1272
1272
|
}
|
|
1273
1273
|
}
|
|
1274
1274
|
|
|
1275
1275
|
toLogin(options) {
|
|
1276
1276
|
return this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState
|
|
1277
1277
|
? this.toWxAppLogin(options)
|
|
1278
1278
|
: this.toWebLogin(options);
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
1281
|
doLogin(options) {
|
|
1282
1282
|
return this.toLogin(options);
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
1285
|
doLoginForJdPin(options = {}) {
|
|
1286
1286
|
return this.doLogin({
|
|
1287
1287
|
loginColor: {
|
|
1288
1288
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
1289
1289
|
dpin: 0,
|
|
1290
1290
|
},
|
|
1291
1291
|
...options,
|
|
1292
1292
|
});
|
|
1293
1293
|
}
|
|
1294
1294
|
|
|
1295
1295
|
toWebLogin(options) {
|
|
1296
1296
|
let params: {
|
|
1297
1297
|
returnurl: string;
|
|
1298
1298
|
} = {
|
|
1299
1299
|
returnurl: '',
|
|
1300
1300
|
};
|
|
1301
1301
|
const checkToPcLogin = options ? options?.isPc : isPc;
|
|
1302
1302
|
const loginUrl = checkToPcLogin
|
|
1303
1303
|
? `//passport.jd.com/new/login.aspx`
|
|
1304
1304
|
: `${domain.mobileLogin}/user/login.action`;
|
|
1305
1305
|
const defaultParams = {
|
|
1306
1306
|
appid: '100',
|
|
1307
1307
|
returnurl: window.location.href,
|
|
1308
1308
|
};
|
|
1309
1309
|
if (isString(options)) {
|
|
1310
1310
|
params = Object.assign({}, defaultParams, {
|
|
1311
1311
|
returnurl: options,
|
|
1312
1312
|
});
|
|
1313
1313
|
} else if (isObject(options)) {
|
|
1314
1314
|
const { loginColor, ...otherOptions } = options;
|
|
1315
1315
|
params = Object.assign({}, defaultParams, otherOptions);
|
|
1316
1316
|
} else {
|
|
1317
1317
|
params = defaultParams;
|
|
1318
1318
|
}
|
|
1319
1319
|
params.returnurl = encodeURIComponent(params.returnurl);
|
|
1320
1320
|
let getFullUrl = loginUrl + '?' + serialize(params);
|
|
1321
1321
|
if (checkToPcLogin) {
|
|
1322
1322
|
getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl');
|
|
1323
1323
|
}
|
|
1324
1324
|
return Promise.resolve({
|
|
1325
1325
|
h5ToUrl: true,
|
|
1326
1326
|
url: getFullUrl,
|
|
1327
1327
|
}).then(() => {
|
|
1328
1328
|
window.location.href = getFullUrl;
|
|
1329
1329
|
});
|
|
1330
1330
|
}
|
|
1331
1331
|
|
|
1332
1332
|
toWxAppLogin(options = {}) {
|
|
1333
1333
|
console.log('微信京购小程序中h5登录跳转', options);
|
|
1334
1334
|
return Promise.resolve(true).then(() => {
|
|
1335
1335
|
const { loginColor } = Object.assign(
|
|
1336
1336
|
{},
|
|
1337
1337
|
{
|
|
1338
1338
|
loginColor: {
|
|
1339
1339
|
biz: WXAPP_BIZ_KEY,
|
|
1340
1340
|
dpin: 1,
|
|
1341
1341
|
},
|
|
1342
1342
|
},
|
|
1343
1343
|
options,
|
|
1344
1344
|
);
|
|
1345
1345
|
window.location.href = `${domain.wq}/pinbind/pintokenredirect?biz=${
|
|
1346
1346
|
loginColor.biz
|
|
1347
1347
|
}&url=${encodeURIComponent(window.location.href)}`;
|
|
1348
1348
|
});
|
|
1349
1349
|
}
|
|
1350
1350
|
|
|
1351
1351
|
getLoginCookie() {
|
|
1352
1352
|
return Promise.resolve({
|
|
1353
1353
|
pin: cookie.get('pin') || '',
|
|
1354
1354
|
});
|
|
1355
1355
|
}
|
|
1356
1356
|
|
|
1357
1357
|
clearLoginCookie() {
|
|
1358
1358
|
cookie.remove('pin');
|
|
1359
1359
|
}
|
|
1360
1360
|
|
|
1361
1361
|
checkStatusAndLogin(options = {}) {
|
|
1362
1362
|
if (!this.checkStatusAndLoginPromise) {
|
|
1363
1363
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
1364
1364
|
try {
|
|
1365
1365
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(options);
|
|
1366
1366
|
if (getLoginState) {
|
|
1367
1367
|
resolve(true);
|
|
1368
1368
|
} else {
|
|
1369
1369
|
this.toLogin(options);
|
|
1370
1370
|
reject(false);
|
|
1371
1371
|
}
|
|
1372
1372
|
} catch (e) {
|
|
1373
1373
|
this.toLogin(options);
|
|
1374
1374
|
reject(false);
|
|
1375
1375
|
}
|
|
1376
1376
|
});
|
|
1377
1377
|
return this.checkStatusAndLoginPromise;
|
|
1378
1378
|
} else {
|
|
1379
1379
|
return this.checkStatusAndLoginPromise
|
|
1380
1380
|
.then(() => {
|
|
1381
1381
|
return Promise.resolve(true);
|
|
1382
1382
|
})
|
|
1383
1383
|
.catch(() => {
|
|
1384
1384
|
this.toLogin(options);
|
|
1385
1385
|
return Promise.reject(true);
|
|
1386
1386
|
});
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
1389
|
|
|
1390
1390
|
checkJdStatusAndLogin(
|
|
1391
1391
|
options = {
|
|
1392
1392
|
loginColor: {
|
|
1393
1393
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
1394
1394
|
dpin: 0,
|
|
1395
1395
|
},
|
|
1396
1396
|
},
|
|
1397
1397
|
) {
|
|
1398
1398
|
return this.checkStatusAndLogin(options);
|
|
1399
1399
|
}
|
|
1400
1400
|
|
|
1401
1401
|
doCheckLoginStateAndForApiCheck(options) {
|
|
1402
1402
|
if (this.info.loginState) {
|
|
1403
1403
|
return Promise.resolve(true);
|
|
1404
1404
|
} else {
|
|
1405
1405
|
return new Promise((resolve, reject) => {
|
|
1406
1406
|
if (this.info.isJingGouMiniViewState || this.info.isJingxiMiniViewState) {
|
|
1407
1407
|
const getWqAuthToken = cookie.get('wq_auth_token');
|
|
1408
1408
|
const getWqSkey = cookie.get('wq_skey');
|
|
1409
1409
|
const getWqUin = cookie.get('wq_uin');
|
|
1410
1410
|
const isLoginState =
|
|
1411
1411
|
options?.loginColor?.dpin === 0 ? getWqAuthToken : getWqSkey && getWqUin;
|
|
1412
1412
|
if (isLoginState) {
|
|
1413
1413
|
this.info.loginState = true;
|
|
1414
1414
|
resolve(true);
|
|
1415
1415
|
} else {
|
|
1416
1416
|
reject(false);
|
|
1417
1417
|
}
|
|
1418
1418
|
} else {
|
|
1419
1419
|
Taro.request({
|
|
1420
1420
|
url: api.isLogin,
|
|
1421
1421
|
jsonp: true,
|
|
1422
1422
|
timeout: 3000,
|
|
1423
1423
|
success: (res) => {
|
|
1424
1424
|
const { statusCode, data } = res;
|
|
1425
1425
|
if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
|
|
1426
1426
|
this.info.loginState = true;
|
|
1427
1427
|
resolve(true);
|
|
1428
1428
|
} else {
|
|
1429
1429
|
reject(false);
|
|
1430
1430
|
}
|
|
1431
1431
|
},
|
|
1432
1432
|
fail: (err) => {
|
|
1433
1433
|
console.log('登录检查异常', err);
|
|
1434
1434
|
reject(false);
|
|
1435
1435
|
},
|
|
1436
1436
|
});
|
|
1437
1437
|
}
|
|
1438
1438
|
});
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
1442
|
checkLoginStatus(options) {
|
|
1443
1443
|
return new Promise(async (resolve, reject) => {
|
|
1444
1444
|
try {
|
|
1445
1445
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck(options);
|
|
1446
1446
|
if (getLoginState) {
|
|
1447
1447
|
const { pin } = await this.getLoginCookie();
|
|
1448
1448
|
this.info.userInfo = {
|
|
1449
1449
|
pin,
|
|
1450
1450
|
encodePin: encodeURIComponent(pin),
|
|
1451
1451
|
ptkey: '',
|
|
1452
1452
|
};
|
|
1453
1453
|
resolve(true);
|
|
1454
1454
|
} else {
|
|
1455
1455
|
reject(false);
|
|
1456
1456
|
}
|
|
1457
1457
|
} catch (e) {
|
|
1458
1458
|
reject(false);
|
|
1459
1459
|
}
|
|
1460
1460
|
});
|
|
1461
1461
|
}
|
|
1462
1462
|
|
|
1463
1463
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
1464
1464
|
const createUpdateQueryInfo: {
|
|
1465
1465
|
query: {
|
|
1466
1466
|
shopId?: string | number;
|
|
1467
1467
|
venderId?: string | number;
|
|
1468
1468
|
};
|
|
1469
1469
|
updateShopInfoState: boolean;
|
|
1470
1470
|
} = Object.assign(
|
|
1471
1471
|
{},
|
|
1472
1472
|
{
|
|
1473
1473
|
query: {},
|
|
1474
1474
|
updateShopInfoState: false,
|
|
1475
1475
|
},
|
|
1476
1476
|
updateQuery,
|
|
1477
1477
|
);
|
|
1478
1478
|
console.log(
|
|
1479
1479
|
'获取当前下发的店铺查询参数',
|
|
1480
1480
|
updateQuery,
|
|
1481
1481
|
'获取之前保存的shopInfo店铺查询参数',
|
|
1482
1482
|
this.info?.shopInfo,
|
|
1483
1483
|
);
|
|
1484
1484
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
1485
1485
|
const { shopId, venderId, un_area } = query;
|
|
1486
1486
|
if (updateShopInfoState) {
|
|
1487
1487
|
this.info.queryInfo = {
|
|
1488
1488
|
...this.info.queryInfo,
|
|
1489
1489
|
...query,
|
|
1490
1490
|
};
|
|
1491
1491
|
if (shopId && venderId) {
|
|
1492
1492
|
this.info.shopInfo = {
|
|
1493
1493
|
shopId: `${shopId}`,
|
|
1494
1494
|
venderId: `${venderId}`,
|
|
1495
1495
|
};
|
|
1496
1496
|
}
|
|
1497
1497
|
} else {
|
|
1498
1498
|
this.info.queryInfo = {
|
|
1499
1499
|
...query,
|
|
1500
1500
|
};
|
|
1501
1501
|
if (
|
|
1502
1502
|
this.info.shopInfo?.shopId &&
|
|
1503
1503
|
this.info.shopInfo?.venderId &&
|
|
1504
1504
|
(this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
|
|
1505
1505
|
) {
|
|
1506
1506
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
1507
1507
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
1508
1508
|
console.log(
|
|
1509
1509
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
1510
1510
|
this.info.queryInfo,
|
|
1511
1511
|
);
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
1514
|
this.info.queryInfo['shopId'] &&
|
|
1515
1515
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
|
|
1516
1516
|
this.info.queryInfo['venderId'] &&
|
|
1517
1517
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
|
|
1518
1518
|
console.log(
|
|
1519
1519
|
'h5==获取店铺下发查询参数\n',
|
|
1520
1520
|
query,
|
|
1521
1521
|
'\n获取店铺最后查询参数\n',
|
|
1522
1522
|
this.info.queryInfo,
|
|
1523
1523
|
'\n是否为更新店铺状态\n',
|
|
1524
1524
|
updateShopInfoState,
|
|
1525
1525
|
);
|
|
1526
1526
|
const changeArea = un_area && un_area.length > 0 ? un_area : isPc && ipLoc_djd ? ipLoc_djd : '';
|
|
1527
1527
|
if (changeArea) {
|
|
1528
1528
|
const getBottomAreaStr = changeArea.replace(/-/g, '_');
|
|
1529
1529
|
this.info.pageInfo.address = getBottomAreaStr;
|
|
1530
1530
|
this.info.pageInfo.un_area = getBottomAreaStr;
|
|
1531
1531
|
this.info.pageInfo.addressCommaStr = getBottomAreaStr.replace(/_/g, ',');
|
|
1532
1532
|
}
|
|
1533
1533
|
}
|
|
1534
1534
|
|
|
1535
1535
|
dealLoadSdkList() {
|
|
1536
1536
|
const globalLoadJsList = window?.shopGlobalSwitch?.asyncLoadJsList ?? [];
|
|
1537
1537
|
const businessLoadJsList = window?.PAGE_DATA?.businessData?.asyncLoadJsList ?? [];
|
|
1538
1538
|
const concatLoadJsList = [].concat(globalLoadJsList, businessLoadJsList);
|
|
1539
1539
|
let mergeLoadJsList = globalLoadJsList;
|
|
1540
1540
|
try {
|
|
1541
1541
|
mergeLoadJsList = concatLoadJsList.reduce((accArr: any[], current: any) => {
|
|
1542
1542
|
const getFindIndex = accArr.findIndex((item) => item?.fileName === current?.fileName);
|
|
1543
1543
|
getFindIndex !== -1
|
|
1544
1544
|
? (accArr[getFindIndex] = { ...accArr[getFindIndex], ...current })
|
|
1545
1545
|
: accArr.push(current);
|
|
1546
1546
|
return accArr;
|
|
1547
1547
|
}, []);
|
|
1548
1548
|
} catch (e) {
|
|
1549
1549
|
console.log('LoadJsList合并错误', e);
|
|
1550
1550
|
}
|
|
1551
1551
|
console.log(
|
|
1552
1552
|
'globalLoadJsList',
|
|
1553
1553
|
globalLoadJsList,
|
|
1554
1554
|
'businessLoadJsList',
|
|
1555
1555
|
businessLoadJsList,
|
|
1556
1556
|
'两个加载jsList集合合并完成',
|
|
1557
1557
|
mergeLoadJsList,
|
|
1558
1558
|
);
|
|
1559
1559
|
this.loadJsSdkList = mergeLoadJsList;
|
|
1560
1560
|
return this.loadJsSdkList;
|
|
1561
1561
|
}
|
|
1562
1562
|
|
|
1563
1563
|
renderNextTickLoadSdk() {
|
|
1564
1564
|
Taro.nextTick(() => {
|
|
1565
1565
|
console.log(
|
|
1566
1566
|
'页面渲染的下一帧执行的js加载方法,当前nextTick存在state的渲染问题,先延迟1s=======',
|
|
1567
1567
|
);
|
|
1568
1568
|
setTimeout(() => {
|
|
1569
1569
|
this.loadOtherSdk(LoadJsInitTriggerType.NRXT_TICK, this.loadJsSdkList);
|
|
1570
1570
|
}, 1000);
|
|
1571
1571
|
});
|
|
1572
1572
|
}
|
|
1573
1573
|
|
|
1574
1574
|
loadOtherSdk(triggerType = LoadJsInitTriggerType.NOW, loadJsList: any[] = []) {
|
|
1575
1575
|
const getLoadJsList =
|
|
1576
1576
|
Array.isArray(loadJsList) && loadJsList.length > 0 ? loadJsList : this.dealLoadSdkList();
|
|
1577
1577
|
const getLoadFilterList = getLoadJsList.filter((item) => {
|
|
1578
1578
|
const getInitLoadEnvType = item?.initLoadEnvType || LoadJsInitLoadEnvType.ALL;
|
|
1579
1579
|
let getLoastLoadEventState = true;
|
|
1580
1580
|
if (getInitLoadEnvType === LoadJsInitLoadEnvType.JD_APP) {
|
|
1581
1581
|
getLoastLoadEventState = isJdApp;
|
|
1582
1582
|
}
|
|
1583
1583
|
else if (getInitLoadEnvType === LoadJsInitLoadEnvType.M) {
|
|
1584
1584
|
getLoastLoadEventState = !isJdApp || !!isJdAndHarmonyDevice;
|
|
1585
1585
|
}
|
|
1586
1586
|
const getInitTriggerType =
|
|
1587
1587
|
isJdApp && item?.initJdAppTriggerType
|
|
1588
1588
|
? item?.initTriggerType
|
|
1589
1589
|
: item?.initTriggerType || LoadJsInitTriggerType.NOW;
|
|
1590
1590
|
const getInitLinkTriggerWay = window?.PAGE_DATA[item?.initLinkTriggerWay] || false;
|
|
1591
1591
|
return getLoastLoadEventState && getInitTriggerType === triggerType && getInitLinkTriggerWay;
|
|
1592
1592
|
});
|
|
1593
1593
|
console.log(
|
|
1594
1594
|
'获取当前触发方式',
|
|
1595
1595
|
triggerType,
|
|
1596
1596
|
'获取当前最后加载的js集合',
|
|
1597
1597
|
getLoadFilterList,
|
|
1598
1598
|
'过滤前的加载集合',
|
|
1599
1599
|
getLoadJsList,
|
|
1600
1600
|
);
|
|
1601
1601
|
getLoadFilterList.length > 0 &&
|
|
1602
1602
|
getLoadFilterList.forEach((item) => {
|
|
1603
1603
|
const isLoadState = /sgm/.test(item?.fileName)
|
|
1604
1604
|
? window?.shopGlobalSwitch?.openSgm === 'true'
|
|
1605
1605
|
: true;
|
|
1606
1606
|
isLoadState &&
|
|
1607
1607
|
this.loadItemSdkPromise(item)
|
|
1608
1608
|
.then((res) => {
|
|
1609
1609
|
console.info('当前js地址' + item?.src, '加载状态', res);
|
|
1610
1610
|
const isFileNameNewDraSdkJs = res?.fileName === 'newDraSdkJs';
|
|
1611
1611
|
if (isFileNameNewDraSdkJs && window?.dra?.run) {
|
|
1612
1612
|
window.dra.run('init', { aid: res?.aid });
|
|
1613
1613
|
window.dra.run('start');
|
|
1614
1614
|
}
|
|
1615
1615
|
})
|
|
1616
1616
|
.catch((err) => {
|
|
1617
1617
|
console.info('当前js地址加载异常', item?.src);
|
|
1618
1618
|
window?.fetchErrorData &&
|
|
1619
1619
|
window.fetchErrorData({
|
|
1620
1620
|
title: '公共js加载异常',
|
|
1621
1621
|
type: 'jsLoad',
|
|
1622
1622
|
data: err,
|
|
1623
1623
|
});
|
|
1624
1624
|
});
|
|
1625
1625
|
});
|
|
1626
1626
|
}
|
|
1627
1627
|
loadScriptEle(jsInfo, resolve, reject) {
|
|
1628
1628
|
const getFileName = jsInfo?.fileName;
|
|
1629
1629
|
if (getFileName) {
|
|
1630
1630
|
const getEleId = `J_loadJs_${getFileName}`;
|
|
1631
1631
|
const getEle = document.getElementById(getEleId);
|
|
1632
1632
|
if (!getEle) {
|
|
1633
1633
|
const jsLoadErrorSgmCode = `jsLoadError_${jsInfo?.fileName || 'customJs'}`;
|
|
1634
1634
|
const _sgmEle = document.createElement('script');
|
|
1635
1635
|
_sgmEle.id = getEleId;
|
|
1636
1636
|
_sgmEle.onload = function () {
|
|
1637
1637
|
resolve({
|
|
1638
1638
|
...jsInfo,
|
|
1639
1639
|
jsTip: 'js加载成功',
|
|
1640
1640
|
});
|
|
1641
1641
|
};
|
|
1642
1642
|
_sgmEle.onerror = function () {
|
|
1643
1643
|
reject({
|
|
1644
1644
|
...jsInfo,
|
|
1645
1645
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1646
1646
|
jsReqError: '当前js创建标签触发onerror异常回调,请排查网络络错误或语法错误或运行时错误',
|
|
1647
1647
|
});
|
|
1648
1648
|
};
|
|
1649
1649
|
const dataAttrList = ['timeout', 'fileName', 'env'];
|
|
1650
1650
|
const getJsInfoKeyList = Object.keys(jsInfo);
|
|
1651
1651
|
getJsInfoKeyList.forEach((key) => {
|
|
1652
1652
|
if (key === 'async') {
|
|
1653
1653
|
_sgmEle.async = jsInfo[key];
|
|
1654
1654
|
} else if (key === 'crossOrigin') {
|
|
1655
1655
|
_sgmEle.crossOrigin = jsInfo[key];
|
|
1656
1656
|
} else if (key === 'src') {
|
|
1657
1657
|
_sgmEle.src = `${jsInfo[key]}`;
|
|
1658
1658
|
} else if (dataAttrList.includes(key) || /init/.test(key)) {
|
|
1659
1659
|
_sgmEle.setAttribute(`data-${key}`, jsInfo[key]);
|
|
1660
1660
|
} else {
|
|
1661
1661
|
_sgmEle.setAttribute(key, jsInfo[key]);
|
|
1662
1662
|
}
|
|
1663
1663
|
});
|
|
1664
1664
|
document.head.appendChild(_sgmEle);
|
|
1665
1665
|
} else {
|
|
1666
1666
|
console.log(`当前${jsInfo?.fileName || 'js'}已经存在页面中,可以直接调用相关方法`, jsInfo);
|
|
1667
1667
|
resolve({
|
|
1668
1668
|
...jsInfo,
|
|
1669
1669
|
jsTip: 'js本身已存在页面中',
|
|
1670
1670
|
});
|
|
1671
1671
|
}
|
|
1672
1672
|
} else {
|
|
1673
1673
|
console.warn('当前js资源信息缺少必要的参数fileName,请关注', jsInfo);
|
|
1674
1674
|
}
|
|
1675
1675
|
}
|
|
1676
1676
|
|
|
1677
1677
|
loadItemSdkPromise(jsInfo = {}) {
|
|
1678
1678
|
if (jsInfo?.src) {
|
|
1679
1679
|
const getInitLoadType =
|
|
1680
1680
|
isJdApp && jsInfo?.initJdAppLoadType
|
|
1681
1681
|
? jsInfo?.initJdAppLoadType
|
|
1682
1682
|
: jsInfo?.initLoadType || LoadJsInitLoadType.ALL;
|
|
1683
1683
|
if (getInitLoadType !== LoadJsInitLoadType.NONE) {
|
|
1684
1684
|
const getFileKeyName = jsInfo?.fileName || jsInfo?.src;
|
|
1685
1685
|
if (!this.loadJsSdkListCachePromise[getFileKeyName]) {
|
|
1686
1686
|
if (getInitLoadType !== LoadJsInitLoadType.INSERT_ELE) {
|
|
1687
1687
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve, reject) => {
|
|
1688
1688
|
const jsLoadErrorSgmCode = `jsLoadError_${jsInfo?.fileName || 'customJs'}`;
|
|
1689
1689
|
try {
|
|
1690
1690
|
const jsXhrRequest = new XMLHttpRequest();
|
|
1691
1691
|
jsXhrRequest.timeout = jsInfo?.timeout ?? 2000;
|
|
1692
1692
|
const jsUrl = `${jsInfo?.src}`;
|
|
1693
1693
|
jsXhrRequest.open('GET', jsUrl, true);
|
|
1694
1694
|
jsXhrRequest.onreadystatechange = () => {
|
|
1695
1695
|
if (jsXhrRequest.readyState === 4) {
|
|
1696
1696
|
const getReqStatus = jsXhrRequest.status;
|
|
1697
1697
|
if ((getReqStatus >= 200 && getReqStatus < 300) || getReqStatus === 304) {
|
|
1698
1698
|
const getInsetHeadState = getInitLoadType === LoadJsInitLoadType.ALL;
|
|
1699
1699
|
if (getInsetHeadState) {
|
|
1700
1700
|
this.loadScriptEle(jsInfo, resolve, reject);
|
|
1701
1701
|
} else {
|
|
1702
1702
|
resolve({
|
|
1703
1703
|
...jsInfo,
|
|
1704
1704
|
jsTip: 'js请求成功,暂未插入head节点,业务自行单独插入',
|
|
1705
1705
|
});
|
|
1706
1706
|
}
|
|
1707
1707
|
getReqStatus !== 200 &&
|
|
1708
1708
|
sgmCustomReport({
|
|
1709
1709
|
type: 3,
|
|
1710
1710
|
code: 'js_load_special_code',
|
|
1711
1711
|
msg: {
|
|
1712
1712
|
msg: '当前js加载成功,状态非200,特殊上报观察',
|
|
1713
1713
|
jsReqState: getReqStatus,
|
|
1714
1714
|
env: getSgmCustomCode('js_load_special_code'),
|
|
1715
1715
|
data: jsInfo,
|
|
1716
1716
|
},
|
|
1717
1717
|
});
|
|
1718
1718
|
} else {
|
|
1719
1719
|
const getRes = {
|
|
1720
1720
|
...jsInfo,
|
|
1721
1721
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1722
1722
|
jsReqError: `请求状态异常,状态码为${getReqStatus}`,
|
|
1723
1723
|
jsReqState: getReqStatus,
|
|
1724
1724
|
};
|
|
1725
1725
|
console.log('当前js请求状态异常,具体信息见', getRes);
|
|
1726
1726
|
reject(getRes);
|
|
1727
1727
|
}
|
|
1728
1728
|
}
|
|
1729
1729
|
};
|
|
1730
1730
|
jsXhrRequest.onerror = () => {
|
|
1731
1731
|
const getRes = {
|
|
1732
1732
|
...jsInfo,
|
|
1733
1733
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1734
1734
|
jsReqError: '请求错误',
|
|
1735
1735
|
};
|
|
1736
1736
|
console.log('当前js请求错误', getRes);
|
|
1737
1737
|
jsXhrRequest.abort();
|
|
1738
1738
|
reject(getRes);
|
|
1739
1739
|
};
|
|
1740
1740
|
jsXhrRequest.ontimeout = () => {
|
|
1741
1741
|
const getRes = {
|
|
1742
1742
|
...jsInfo,
|
|
1743
1743
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1744
1744
|
jsReqError: `请求${jsXhrRequest.timeout}ms超时异常`,
|
|
1745
1745
|
jsReqState: jsXhrRequest.status,
|
|
1746
1746
|
};
|
|
1747
1747
|
console.log('当前js请求超时异常', getRes);
|
|
1748
1748
|
jsXhrRequest.abort();
|
|
1749
1749
|
reject(getRes);
|
|
1750
1750
|
};
|
|
1751
1751
|
jsXhrRequest.send();
|
|
1752
1752
|
} catch (e) {
|
|
1753
1753
|
console.log('执行js请求异常', e);
|
|
1754
1754
|
reject({
|
|
1755
1755
|
...jsInfo,
|
|
1756
1756
|
env: getSgmCustomCode(jsLoadErrorSgmCode),
|
|
1757
1757
|
jsReqError: '未知异常',
|
|
1758
1758
|
error: e,
|
|
1759
1759
|
});
|
|
1760
1760
|
}
|
|
1761
1761
|
});
|
|
1762
1762
|
} else {
|
|
1763
1763
|
this.loadJsSdkListCachePromise[getFileKeyName] = new Promise((resolve, reject) => {
|
|
1764
1764
|
return this.loadScriptEle(jsInfo, resolve, reject);
|
|
1765
1765
|
});
|
|
1766
1766
|
}
|
|
1767
1767
|
}
|
|
1768
1768
|
return this.loadJsSdkListCachePromise[getFileKeyName];
|
|
1769
1769
|
} else {
|
|
1770
1770
|
return Promise.resolve({
|
|
1771
1771
|
...jsInfo,
|
|
1772
1772
|
jsTip: 'js加载方式设置为不加载,当前不做处理',
|
|
1773
1773
|
});
|
|
1774
1774
|
}
|
|
1775
1775
|
} else {
|
|
1776
1776
|
return Promise.reject(jsInfo);
|
|
1777
1777
|
}
|
|
1778
1778
|
}
|
|
1779
1779
|
|
|
1780
1780
|
createLanguagePromise() {
|
|
1781
1781
|
const getLanguageConfig = window?.shopGlobalSwitch?.language || {};
|
|
1782
1782
|
if (!this.languageCacheProimse) {
|
|
1783
1783
|
this.languageCacheProimse = new Promise((resolve, reject) => {
|
|
1784
1784
|
const { fileName, prefixUrl } = getLanguageConfig;
|
|
1785
1785
|
console.log('getLanguageConfig', getLanguageConfig, 'languageNowType', languageNowType);
|
|
1786
1786
|
const dealLanguageFile = () => {
|
|
1787
1787
|
this.getLanguageFilePromise(getLanguageConfig, languageNowType)
|
|
1788
1788
|
.then((res) => {
|
|
1789
1789
|
if (res && res?.data) {
|
|
1790
1790
|
this.languageJsonData = res.data;
|
|
1791
1791
|
|
|
1792
1792
|
setTimeout(() => {
|
|
1793
1793
|
const getOtherLanguageList = languageTypeList.filter(
|
|
1794
1794
|
(item) => item !== languageNowType,
|
|
1795
1795
|
);
|
|
1796
1796
|
getOtherLanguageList.length > 0 &&
|
|
1797
1797
|
getOtherLanguageList.map((languageTypeKey) => {
|
|
1798
1798
|
this.getLanguageFilePromise(getLanguageConfig, languageTypeKey);
|
|
1799
1799
|
});
|
|
1800
1800
|
}, 3000);
|
|
1801
1801
|
resolve(res);
|
|
1802
1802
|
} else {
|
|
1803
1803
|
reject(res);
|
|
1804
1804
|
}
|
|
1805
1805
|
})
|
|
1806
1806
|
.catch((err) => {
|
|
1807
1807
|
reject(err);
|
|
1808
1808
|
});
|
|
1809
1809
|
};
|
|
1810
1810
|
if (fileName && prefixUrl) {
|
|
1811
1811
|
const getLangStorageKey = `jshopx_lang_${languageNowType}`;
|
|
1812
1812
|
const getLocalLangRes = getTaroStorageKeyValue(getLangStorageKey);
|
|
1813
1813
|
if (getLocalLangRes) {
|
|
1814
1814
|
try {
|
|
1815
1815
|
const getLocalLangJsonData =
|
|
1816
1816
|
typeof getLocalLangRes === 'string' ? JSON.parse(getLocalLangRes) : getLocalLangRes;
|
|
1817
1817
|
if (getLocalLangJsonData?.fileName && getLocalLangJsonData?.data) {
|
|
1818
1818
|
if (getLocalLangJsonData?.fileName === fileName) {
|
|
1819
1819
|
const geThisLangData = getLocalLangJsonData.data;
|
|
1820
1820
|
this.languageJsonData = geThisLangData;
|
|
1821
1821
|
return resolve({
|
|
1822
1822
|
...getLanguageConfig,
|
|
1823
1823
|
languageNowType,
|
|
1824
1824
|
data: geThisLangData,
|
|
1825
1825
|
});
|
|
1826
1826
|
} else {
|
|
1827
1827
|
dealLanguageFile();
|
|
1828
1828
|
}
|
|
1829
1829
|
} else {
|
|
1830
1830
|
dealLanguageFile();
|
|
1831
1831
|
}
|
|
1832
1832
|
} catch (e) {
|
|
1833
1833
|
return reject({
|
|
1834
1834
|
languageNowType,
|
|
1835
1835
|
msg: '转换错误',
|
|
1836
1836
|
...getLanguageConfig,
|
|
1837
1837
|
});
|
|
1838
1838
|
}
|
|
1839
1839
|
} else {
|
|
1840
1840
|
dealLanguageFile();
|
|
1841
1841
|
}
|
|
1842
1842
|
} else {
|
|
1843
1843
|
return reject({
|
|
1844
1844
|
languageNowType,
|
|
1845
1845
|
msg: '文件对象下发异常',
|
|
1846
1846
|
...getLanguageConfig,
|
|
1847
1847
|
});
|
|
1848
1848
|
}
|
|
1849
1849
|
});
|
|
1850
1850
|
}
|
|
1851
1851
|
return this.languageCacheProimse;
|
|
1852
1852
|
}
|
|
1853
1853
|
|
|
1854
1854
|
getLanguageFilePromise(info, languageTypeKey) {
|
|
1855
1855
|
const { fileName, prefixUrl, timeout } = info || {};
|
|
1856
1856
|
const getUrl = `${prefixUrl}${fileName}_${languageTypeKey}.json`;
|
|
1857
1857
|
return new Promise((resolve, reject) => {
|
|
1858
1858
|
const langLoadErrorSgmCode = `languageLoadError_${fileName || 'lang.json'}`;
|
|
1859
1859
|
try {
|
|
1860
1860
|
const langXhrRequest = new XMLHttpRequest();
|
|
1861
1861
|
langXhrRequest.timeout = timeout || 2000;
|
|
1862
1862
|
langXhrRequest.open('GET', getUrl, true);
|
|
1863
1863
|
langXhrRequest.responseType = 'json';
|
|
1864
1864
|
langXhrRequest.onreadystatechange = () => {
|
|
1865
1865
|
if (langXhrRequest.readyState === 4) {
|
|
1866
1866
|
const getReqStatus = langXhrRequest.status;
|
|
1867
1867
|
const statusText = langXhrRequest.statusText;
|
|
1868
1868
|
if ((getReqStatus >= 200 && getReqStatus < 300) || getReqStatus === 304) {
|
|
1869
1869
|
const getData = langXhrRequest?.response || false;
|
|
1870
1870
|
if (getData) {
|
|
1871
1871
|
setTaroStorage(`jshopx_lang_${languageTypeKey}`, {
|
|
1872
1872
|
fileName,
|
|
1873
1873
|
data: getData,
|
|
1874
1874
|
});
|
|
1875
1875
|
resolve({
|
|
1876
1876
|
...info,
|
|
1877
1877
|
languageTypeKey,
|
|
1878
1878
|
data: getData,
|
|
1879
1879
|
});
|
|
1880
1880
|
} else {
|
|
1881
1881
|
reject({
|
|
1882
1882
|
...info,
|
|
1883
1883
|
languageTypeKey,
|
|
1884
1884
|
msg: '数据获取异常',
|
|
1885
1885
|
});
|
|
1886
1886
|
}
|
|
1887
1887
|
} else {
|
|
1888
1888
|
const getRes = {
|
|
1889
1889
|
...info,
|
|
1890
1890
|
languageTypeKey,
|
|
1891
1891
|
env: getSgmCustomCode(langLoadErrorSgmCode),
|
|
1892
1892
|
msg: `请求状态异常,状态码为${getReqStatus},statusText:${statusText}`,
|
|
1893
1893
|
};
|
|
1894
1894
|
console.log('当前lang请求状态异常,具体信息见', getRes);
|
|
1895
1895
|
reject(getRes);
|
|
1896
1896
|
}
|
|
1897
1897
|
}
|
|
1898
1898
|
};
|
|
1899
1899
|
langXhrRequest.onerror = () => {
|
|
1900
1900
|
const getRes = {
|
|
1901
1901
|
...info,
|
|
1902
1902
|
env: getSgmCustomCode(langLoadErrorSgmCode),
|
|
1903
1903
|
msg: '请求错误',
|
|
1904
1904
|
};
|
|
1905
1905
|
console.log('当前lang请求错误', getRes);
|
|
1906
1906
|
langXhrRequest.abort();
|
|
1907
1907
|
reject(getRes);
|
|
1908
1908
|
};
|
|
1909
1909
|
langXhrRequest.ontimeout = () => {
|
|
1910
1910
|
const getRes = {
|
|
1911
1911
|
...info,
|
|
1912
1912
|
msg: `请求${langXhrRequest.timeout}ms超时异常,状态${langXhrRequest.status}`,
|
|
1913
1913
|
};
|
|
1914
1914
|
console.log('执行lang多语言请求超时异常', getRes);
|
|
1915
1915
|
langXhrRequest.abort();
|
|
1916
1916
|
reject(getRes);
|
|
1917
1917
|
};
|
|
1918
1918
|
langXhrRequest.send();
|
|
1919
1919
|
} catch (e) {
|
|
1920
1920
|
console.log('执行lang多语言请求异常', e);
|
|
1921
1921
|
reject({
|
|
1922
1922
|
...info,
|
|
1923
1923
|
env: getSgmCustomCode(langLoadErrorSgmCode),
|
|
1924
1924
|
msg: '未知异常',
|
|
1925
1925
|
error: e,
|
|
1926
1926
|
});
|
|
1927
1927
|
}
|
|
1928
1928
|
});
|
|
1929
1929
|
}
|