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