@conecli/cone-render 0.9.1-shop2.2 → 0.9.1-shop2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/const.ts +1 -1
- package/dist/common/index.h5.ts +1 -1
- package/dist/common/index.jd.ts +1 -1
- package/dist/common/index.ts +1 -1
- package/dist/common/index.weapp.ts +1 -1
- package/dist/common/jssdk.ts +1 -0
- package/dist/common/pageType.ts +1 -0
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/Exposure/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/const.ts +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +9 -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 +4 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/base/Price/index.tsx +1 -1
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +21 -2
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.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/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/createReportFloorData.ts +1 -1
- package/dist/jumpEventReport/index.h5.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.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.wxapp.ts +1 -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/track.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/requestServer.ts +1 -1
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/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/utils.ts +1 -1
- package/package.json +1 -1
package/dist/common/index.h5.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
urlCookie
|
|
3
2
|
public config: {
|
|
4
3
|
[key: string]: any
|
|
5
4
|
}
|
|
6
5
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
7
6
|
this.config = {}
|
|
8
7
|
...info,
|
|
9
8
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
10
9
|
if(isPc) {
|
|
11
10
|
getFullUrl = getFullUrl.replace(/returnurl/,'ReturnUrl')
|
|
12
11
|
}
|
|
13
12
|
pin: cookie.get('pin') || ''
|
|
14
13
|
})
|
|
15
14
|
if(!this.checkStatusAndLoginPromise){
|
|
16
15
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
17
16
|
try {
|
|
18
17
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
19
18
|
if(getLoginState){
|
|
20
19
|
resolve(true)
|
|
21
20
|
}else {
|
|
22
21
|
this.toLogin(options)
|
|
23
22
|
reject(false)
|
|
24
23
|
}
|
|
25
24
|
}catch (e) {
|
|
26
25
|
this.toLogin(options)
|
|
27
26
|
reject(false)
|
|
28
27
|
}
|
|
29
28
|
})
|
|
30
29
|
return this.checkStatusAndLoginPromise
|
|
31
30
|
}else {
|
|
32
31
|
return this.checkStatusAndLoginPromise.then(() => {
|
|
33
32
|
return Promise.resolve(true)
|
|
34
33
|
}).catch (() => {
|
|
35
34
|
this.toLogin(options)
|
|
36
35
|
return Promise.reject(true)
|
|
37
36
|
})
|
|
38
37
|
}
|
|
39
38
|
|
|
40
39
|
doCheckLoginStateAndForApiCheck() {
|
|
41
40
|
if(this.info.loginState){
|
|
42
41
|
return Promise.resolve(true)
|
|
43
42
|
}else {
|
|
44
43
|
return new Promise((resolve, reject) => {
|
|
45
44
|
if(this.info.isJingGouMiniViewState){
|
|
46
45
|
const getWqAuthToken = cookie.get("wq_auth_token")
|
|
47
46
|
if(getWqAuthToken){
|
|
48
47
|
this.info.loginState = true
|
|
49
48
|
resolve(true)
|
|
50
49
|
}else {
|
|
51
50
|
reject(false)
|
|
52
51
|
}
|
|
53
52
|
}else{
|
|
54
53
|
Taro.request({
|
|
55
54
|
url: api.isLogin,
|
|
56
55
|
jsonp:true,
|
|
57
56
|
timeout: 3000,
|
|
58
57
|
success: (res) => {
|
|
59
58
|
const {statusCode,data} = res
|
|
60
59
|
if (statusCode === 200 && data?.islogin && Number(data.islogin) === 1) {
|
|
61
60
|
this.info.loginState = true
|
|
62
61
|
resolve(true);
|
|
63
62
|
} else {
|
|
64
63
|
reject(false)
|
|
65
64
|
}
|
|
66
65
|
},
|
|
67
66
|
fail:(err) => {
|
|
68
67
|
console.log("登录检查异常", err)
|
|
69
68
|
reject(false)
|
|
70
69
|
}
|
|
71
70
|
})
|
|
72
71
|
}
|
|
73
72
|
})
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
|
|
77
76
|
try {
|
|
78
77
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
79
78
|
if(getLoginState){
|
|
80
79
|
const { pin } = await this.getLoginCookie();
|
|
81
80
|
this.info.userInfo = {
|
|
82
81
|
pin,
|
|
83
82
|
encodePin: encodeURIComponent(pin),
|
|
84
83
|
ptkey: '',
|
|
85
84
|
}
|
|
86
85
|
resolve(true)
|
|
87
86
|
}else {
|
|
88
87
|
reject(false)
|
|
89
88
|
}
|
|
90
89
|
}catch (e) {
|
|
91
90
|
reject(false)
|
|
92
91
|
}
|
|
93
92
|
})
|
|
94
93
|
const changeArea = un_area && un_area.length > 0 ? un_area : (ipLoc_djd ? ipLoc_djd : '')
|
|
95
94
|
if(changeArea){
|
|
96
95
|
this.info.pageInfo.address = changeArea
|
|
97
96
|
this.info.pageInfo.un_area = changeArea
|
|
98
97
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
99
98
|
}
|
|
99
|
+
import Taro from '@tarojs/taro'
|
|
100
100
|
isJdApp,
|
|
101
101
|
isJdAndAndroidDevice,
|
|
102
102
|
jdAppVersion,
|
|
103
103
|
jdAppVersionStr,
|
|
104
104
|
isString,
|
|
105
105
|
isObject,
|
|
106
106
|
serialize,
|
|
107
107
|
urlCookie,
|
|
108
108
|
BUSINESS_TYPE,
|
|
109
109
|
SECTION_HOME_TAB_TYPE,
|
|
110
110
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
111
111
|
WXAPP_BIZ_KEY,
|
|
112
112
|
WX_BUSINESS_TYPE,
|
|
113
113
|
JSSDK_APP_WEBVIEW_CODE,
|
|
114
114
|
loginState: false,
|
|
115
115
|
cookiesStr: '',
|
|
116
116
|
userInfo: userPinKey,
|
|
117
117
|
isJingGouMiniViewState: false,
|
|
118
118
|
pageInfo: {
|
|
119
119
|
wxBusinessType: WX_BUSINESS_TYPE.NO,
|
|
120
120
|
address: '',
|
|
121
121
|
addressCommaStr: '',
|
|
122
122
|
un_area: '',
|
|
123
123
|
vapptype: '1',
|
|
124
124
|
pageType: 'home',
|
|
125
125
|
isExposureState: false,
|
|
126
126
|
moduleId: '',
|
|
127
127
|
entrance: '',
|
|
128
128
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
129
129
|
floorExposureInfo: {},
|
|
130
130
|
floorVideInfo: {},
|
|
131
131
|
tabsLoadAllDataInfo: {
|
|
132
132
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
|
|
133
133
|
false,
|
|
134
134
|
},
|
|
135
135
|
updateShopInfosAllState: false,
|
|
136
136
|
isVipShop: false,
|
|
137
137
|
...shopConfig,
|
|
138
138
|
pageScrollTop: 0,
|
|
139
139
|
pageIdxHeightInfo: {
|
|
140
140
|
list: []
|
|
141
141
|
},
|
|
142
142
|
shopNavBarHeight: 0,
|
|
143
143
|
},
|
|
144
144
|
defaultQueryLogInfo: {
|
|
145
145
|
sourceType: 'JDshop',
|
|
146
146
|
sourceValue: '',
|
|
147
147
|
moduleId: 'none',
|
|
148
148
|
entrance: 'none',
|
|
149
149
|
},
|
|
150
150
|
sysInfo: {
|
|
151
151
|
windowWidth: isPc ? 375 : 0,
|
|
152
152
|
containerWidth: isPc ? 375 : 0,
|
|
153
153
|
windowHeight: 0,
|
|
154
154
|
netWorkType: '4g',
|
|
155
155
|
},
|
|
156
156
|
queryInfo: {},
|
|
157
157
|
shopInfo: {},
|
|
158
158
|
openAppData: {}
|
|
159
159
|
public info: CommonInterFace.BaseConfigInfo
|
|
160
160
|
public config: {
|
|
161
161
|
[key: string]: any
|
|
162
162
|
}
|
|
163
163
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
164
164
|
public renderedIsvComponents: CommonInterFace.renderedIsvComponents
|
|
165
165
|
public rootEleNode: HTMLElement | null
|
|
166
166
|
public checkStatusAndLoginPromise: object | null
|
|
167
167
|
private jmfeRegisterState: boolean
|
|
168
168
|
constructor(opt) {
|
|
169
169
|
this.info = this._getConfig(opt)
|
|
170
170
|
this.config = {}
|
|
171
171
|
this.lazyContainer = {
|
|
172
172
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
173
173
|
appLazyContainerList: [],
|
|
174
174
|
appLazyFinishContainerList: [],
|
|
175
175
|
},
|
|
176
176
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
177
177
|
appLazyContainerList: [],
|
|
178
178
|
appLazyFinishContainerList: [],
|
|
179
179
|
},
|
|
180
180
|
}
|
|
181
181
|
this.renderedIsvComponents = {}
|
|
182
182
|
this.rootEleNode = document.querySelector('body')
|
|
183
183
|
this.checkStatusAndLoginPromise = null
|
|
184
184
|
isJdApp && this.jmfeReayPromise()
|
|
185
185
|
}
|
|
186
186
|
_getConfig(opt) {
|
|
187
187
|
return Object.assign({}, DefaultConfig, opt)
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
jmfeReayPromise() {
|
|
191
191
|
return this.jmfeRegisterState ? Promise.resolve(true) : new Promise((resolve, reject) => {
|
|
192
192
|
ready('jmfe', 3000).then(() => {
|
|
193
193
|
window?.jmfe && window.jmfe.registerCode(JSSDK_APP_WEBVIEW_CODE)
|
|
194
194
|
this.jmfeRegisterState = true
|
|
195
195
|
resolve(true)
|
|
196
196
|
console.log('松果app内初始化注册jmfe认证完成')
|
|
197
197
|
}).catch(() => {
|
|
198
198
|
reject(false)
|
|
199
199
|
})
|
|
200
200
|
})
|
|
201
201
|
}
|
|
202
202
|
|
|
203
203
|
updateBusinessDomainAndApi(domain, api) {
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
formatNativeScreenPageData(action) {
|
|
207
207
|
let getChangePageInfo: any = null
|
|
208
208
|
try {
|
|
209
209
|
const getNativeScreenPageInfoStr = window.XWebView?._callNative(JSON.stringify({
|
|
210
210
|
plugin: "JDHybridScreenPlugin",
|
|
211
211
|
action,
|
|
212
212
|
sync: "1"
|
|
213
213
|
}));
|
|
214
214
|
const getChangePageInfoData = typeof getNativeScreenPageInfoStr === 'string' ? JSON.parse(getNativeScreenPageInfoStr) : null
|
|
215
215
|
if(getChangePageInfoData && typeof getChangePageInfoData === 'object'){
|
|
216
216
|
const { code, data} = getChangePageInfoData
|
|
217
217
|
getChangePageInfo = code && code === "0" ? data : null;
|
|
218
218
|
}
|
|
219
219
|
}catch (e) {
|
|
220
220
|
console.log("JDHybridScreenPlugin转换异常", e)
|
|
221
221
|
}
|
|
222
222
|
return getChangePageInfo
|
|
223
223
|
}
|
|
224
224
|
|
|
225
225
|
isAndroidFoldScreen() {
|
|
226
226
|
return this.formatNativeScreenPageData('isFoldScreen') === '1'
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
getJdAndroidPageChangeScreenInfo() {
|
|
230
230
|
const getPageScreenInfo = this.formatNativeScreenPageData('getScreenSize')
|
|
231
231
|
if(getPageScreenInfo && getPageScreenInfo?.pageWidth && getPageScreenInfo?.pageHeight){
|
|
232
232
|
getPageScreenInfo.pageWidth = Math.round(getPageScreenInfo.pageWidth / window.devicePixelRatio)
|
|
233
233
|
getPageScreenInfo.pageHeight = Math.round(getPageScreenInfo.pageHeight / window.devicePixelRatio)
|
|
234
234
|
}
|
|
235
235
|
return getPageScreenInfo
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
getSystemInfo(params) {
|
|
239
239
|
let info: UtilsInterFace.taroGetSystemInfoSyncRes | {} = isPc
|
|
240
240
|
? {}
|
|
241
241
|
: getSystemInfos(params)
|
|
242
242
|
if(isJdAndAndroidDevice && window.innerWidth <= 0){
|
|
243
243
|
const isfoldScreen = this.isAndroidFoldScreen()
|
|
244
244
|
if(isfoldScreen){
|
|
245
245
|
const getJdAndroidPageInfo = this.getJdAndroidPageChangeScreenInfo()
|
|
246
246
|
getJdAndroidPageInfo && (info = getSystemInfos(getJdAndroidPageInfo))
|
|
247
247
|
console.info("安卓松果app折叠屏获取webview宽度为0,那么通过内部方法重置获取",getJdAndroidPageInfo)
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
this.info.sysInfo = {
|
|
251
251
|
actualNavBarHeight: 0,
|
|
252
252
|
...this.info.sysInfo,
|
|
253
253
|
...info,
|
|
254
254
|
safeContentHeight: info?.screenHeight,
|
|
255
255
|
headerHeight: 0,
|
|
256
256
|
tabBarHeight: 0,
|
|
257
257
|
}
|
|
258
258
|
if (isJdApp) {
|
|
259
259
|
this.info.sysInfo['hostVersionName'] = jdAppVersionStr
|
|
260
260
|
this.info.sysInfo['hostAppVersion'] = jdAppVersion
|
|
261
261
|
this.getAddressCachePromise()
|
|
262
262
|
this.getElderModePromise()
|
|
263
263
|
}
|
|
264
264
|
this.getNetWorkType()
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
getNetWorkType() {
|
|
268
268
|
if (isJdApp) {
|
|
269
269
|
this.jmfeReayPromise().then(() => {
|
|
270
270
|
window.jmfe.getNetworkStatus().then(({ status, data }) => {
|
|
271
271
|
console.log('在app内初始化通过jmfe对象获取网络状态完成,当前网络状态====', data)
|
|
272
272
|
if (status === '0') {
|
|
273
273
|
this.info.sysInfo['netWorkType'] = data
|
|
274
274
|
}else {
|
|
275
275
|
this._taroGetNetworkType()
|
|
276
276
|
}
|
|
277
277
|
}).catch((err) => {
|
|
278
278
|
console.log('在app内初始化通过jmfe对象获取网络状态异常====', err)
|
|
279
279
|
this._taroGetNetworkType()
|
|
280
280
|
})
|
|
281
281
|
})
|
|
282
282
|
} else {
|
|
283
283
|
this._taroGetNetworkType()
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
286
|
_taroGetNetworkType(){
|
|
287
287
|
Taro.getNetworkType().then((getRes) => {
|
|
288
288
|
if (getRes &&
|
|
289
289
|
getRes.networkType) {
|
|
290
290
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
291
291
|
console.log('在app内通过taro对象获取网络状态完成,当前网络状态', this.info.sysInfo['netWorkType'])
|
|
292
292
|
}
|
|
293
293
|
})
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
getElderModePromise(){
|
|
297
297
|
if(this.info.sysInfo.hasOwnProperty('jdAppModeType')){
|
|
298
298
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
299
299
|
}else {
|
|
300
300
|
if(isJdAndAndroidDevice || /mac|window/i.test(navigator.userAgent)){
|
|
301
301
|
this.info.sysInfo.jdAppModeType = "0"
|
|
302
302
|
return Promise.resolve(this.info.sysInfo.jdAppModeType)
|
|
303
303
|
}else {
|
|
304
304
|
return new Promise(resolve => {
|
|
305
305
|
const getCallBackName = `getJdCurrentModeType${Date.now()}`
|
|
306
306
|
if(!window[getCallBackName]){
|
|
307
307
|
window[getCallBackName] = function(res){
|
|
308
308
|
try {
|
|
309
309
|
const getResJson = typeof res === 'string' ? JSON.parse(res) : res;
|
|
310
310
|
const {status, data, msg} = getResJson
|
|
311
311
|
status === '0' ? resolve(data) : resolve("0")
|
|
312
312
|
}catch (e) {
|
|
313
313
|
resolve("0")
|
|
314
314
|
}
|
|
315
315
|
window[getCallBackName] = null
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
318
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
319
319
|
method: 'callSyncRouterModuleWithParams',
|
|
320
320
|
params: JSON.stringify({
|
|
321
321
|
routerURL: "router://JDBModeModule/getCurrentMode",
|
|
322
322
|
routerParam: {},
|
|
323
323
|
callBackName: `window.${getCallBackName}`,
|
|
324
324
|
callBackId: `${getCallBackName}Ios`,
|
|
325
325
|
}),
|
|
326
326
|
})
|
|
327
327
|
})
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
}
|
|
331
331
|
getCacheAddressRouter() {
|
|
332
332
|
if (!window.jmfe) return
|
|
333
333
|
if (isAndroidDevice) {
|
|
334
334
|
return window.jmfe.callRouter({
|
|
335
335
|
jdRouter: '1',
|
|
336
336
|
routerURL: 'router://JDAddressModule/getCacheAddress',
|
|
337
337
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
338
338
|
})
|
|
339
339
|
} else {
|
|
340
340
|
return window.jmfe.callRouter({
|
|
341
341
|
jdRouter: '1',
|
|
342
342
|
routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
|
|
343
343
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
344
344
|
})
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
347
|
getAddressCachePromise() {
|
|
348
348
|
return new Promise((resolve) => {
|
|
349
349
|
if (
|
|
350
350
|
this?.info?.sysInfo?.lat &&
|
|
351
351
|
this?.info?.sysInfo?.lng &&
|
|
352
352
|
this?.info?.sysInfo?.area
|
|
353
353
|
) {
|
|
354
354
|
resolve({
|
|
355
355
|
lat: this.info.sysInfo.lat,
|
|
356
356
|
lng: this.info.sysInfo.lng,
|
|
357
357
|
area: this?.info?.sysInfo?.area,
|
|
358
358
|
})
|
|
359
359
|
} else {
|
|
360
360
|
this.jmfeReayPromise().then(() => {
|
|
361
361
|
this.getCacheAddressRouter()
|
|
362
362
|
.then(({ status, data }) => {
|
|
363
363
|
if (status === '0' && data) {
|
|
364
364
|
const { lat , latitude, lng, longitude, provinceId, cityId,
|
|
365
365
|
countyId,townId} = data || {}
|
|
366
366
|
let area = '';
|
|
367
367
|
this.info.sysInfo['lat'] = `${lat || latitude || ''}`
|
|
368
368
|
this.info.sysInfo['lng'] = `${lng || longitude || ''}`
|
|
369
369
|
if (provinceId) {
|
|
370
370
|
area = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`
|
|
371
371
|
this.info.pageInfo['address'] = area
|
|
372
372
|
this.info.pageInfo['addressCommaStr'] = area.replace(/_/g,',')
|
|
373
373
|
}
|
|
374
374
|
resolve({
|
|
375
375
|
lat: this.info.sysInfo['lat'],
|
|
376
376
|
lng: this.info.sysInfo['lng'],
|
|
377
377
|
area: area,
|
|
378
378
|
})
|
|
379
379
|
} else {
|
|
380
380
|
resolve({ lat: '', lng: '', area: '' })
|
|
381
381
|
}
|
|
382
382
|
})
|
|
383
383
|
.catch(() => {
|
|
384
384
|
resolve({ lat: '', lng: '', area: '' })
|
|
385
385
|
})
|
|
386
386
|
}).catch(() => {
|
|
387
387
|
resolve({ lat: '', lng: '', area: '' })
|
|
388
388
|
console.log("判断jmfe不存在,获取经纬度信息异常")
|
|
389
389
|
})
|
|
390
390
|
}
|
|
391
391
|
})
|
|
392
392
|
}
|
|
393
393
|
|
|
394
394
|
toLogin(options) {
|
|
395
395
|
return this.info.isJingGouMiniViewState
|
|
396
396
|
? this.toWxAppLogin(options)
|
|
397
397
|
: this.toWebLogin(options)
|
|
398
398
|
}
|
|
399
399
|
|
|
400
400
|
doLogin(options) {
|
|
401
401
|
return this.toLogin(options)
|
|
402
402
|
}
|
|
403
403
|
|
|
404
404
|
toWebLogin(options) {
|
|
405
405
|
let params: {
|
|
406
406
|
returnurl: string
|
|
407
407
|
} = {
|
|
408
408
|
returnurl: '',
|
|
409
409
|
}
|
|
410
410
|
const loginUrl = isPc
|
|
411
411
|
? `//passport.jd.com/new/login.aspx`
|
|
412
412
|
: `${domain.mobileLogin}/user/login.action`
|
|
413
413
|
const defaultParams = {
|
|
414
414
|
appid: '100',
|
|
415
415
|
returnurl: window.location.href,
|
|
416
416
|
}
|
|
417
417
|
if (isString(options)) {
|
|
418
418
|
params = Object.assign({}, defaultParams, {
|
|
419
419
|
returnurl: options,
|
|
420
420
|
})
|
|
421
421
|
} else if (isObject(options)) {
|
|
422
422
|
params = Object.assign({}, defaultParams, options)
|
|
423
423
|
} else {
|
|
424
424
|
params = defaultParams
|
|
425
425
|
}
|
|
426
426
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
427
427
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
428
428
|
if (isPc) {
|
|
429
429
|
getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
|
|
430
430
|
}
|
|
431
431
|
return Promise.resolve({
|
|
432
432
|
h5ToUrl: true,
|
|
433
433
|
url: getFullUrl,
|
|
434
434
|
}).then(() => {
|
|
435
435
|
window.location.href = getFullUrl
|
|
436
436
|
})
|
|
437
437
|
}
|
|
438
438
|
|
|
439
439
|
toWxAppLogin(options) {
|
|
440
440
|
console.log('微信京购小程序中h5登录跳转', options)
|
|
441
441
|
return Promise.resolve(true).then(() => {
|
|
442
442
|
window.location.href = `${
|
|
443
443
|
domain.wq
|
|
444
444
|
}/pinbind/pintokenredirect?biz=${WXAPP_BIZ_KEY}&url=${encodeURIComponent(
|
|
445
445
|
window.location.href,
|
|
446
446
|
)}`
|
|
447
447
|
})
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
getLoginCookie() {
|
|
451
451
|
return Promise.resolve({
|
|
452
452
|
pin: cookie.get('pin') || '',
|
|
453
453
|
})
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
clearLoginCookie() {
|
|
457
457
|
cookie.remove('pin')
|
|
458
458
|
}
|
|
459
459
|
|
|
460
460
|
checkStatusAndLogin(options = {}) {
|
|
461
461
|
if (!this.checkStatusAndLoginPromise) {
|
|
462
462
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
463
463
|
try {
|
|
464
464
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
465
465
|
if (getLoginState) {
|
|
466
466
|
resolve(true)
|
|
467
467
|
} else {
|
|
468
468
|
this.toLogin(options)
|
|
469
469
|
reject(false)
|
|
470
470
|
}
|
|
471
471
|
} catch (e) {
|
|
472
472
|
this.toLogin(options)
|
|
473
473
|
reject(false)
|
|
474
474
|
}
|
|
475
475
|
})
|
|
476
476
|
return this.checkStatusAndLoginPromise
|
|
477
477
|
} else {
|
|
478
478
|
return this.checkStatusAndLoginPromise
|
|
479
479
|
.then(() => {
|
|
480
480
|
return Promise.resolve(true)
|
|
481
481
|
})
|
|
482
482
|
.catch(() => {
|
|
483
483
|
this.toLogin(options)
|
|
484
484
|
return Promise.reject(true)
|
|
485
485
|
})
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
488
|
|
|
489
489
|
doCheckLoginStateAndForApiCheck() {
|
|
490
490
|
if (this.info.loginState) {
|
|
491
491
|
return Promise.resolve(true)
|
|
492
492
|
} else {
|
|
493
493
|
return new Promise((resolve, reject) => {
|
|
494
494
|
if (this.info.isJingGouMiniViewState) {
|
|
495
495
|
const getWqAuthToken = cookie.get('wq_auth_token')
|
|
496
496
|
if (getWqAuthToken) {
|
|
497
497
|
this.info.loginState = true
|
|
498
498
|
resolve(true)
|
|
499
499
|
} else {
|
|
500
500
|
reject(false)
|
|
501
501
|
}
|
|
502
502
|
} else {
|
|
503
503
|
Taro.request({
|
|
504
504
|
url: api.isLogin,
|
|
505
505
|
jsonp: true,
|
|
506
506
|
timeout: 3000,
|
|
507
507
|
success: (res) => {
|
|
508
508
|
const { statusCode, data } = res
|
|
509
509
|
if (
|
|
510
510
|
statusCode === 200 &&
|
|
511
511
|
data?.islogin &&
|
|
512
512
|
Number(data.islogin) === 1
|
|
513
513
|
) {
|
|
514
514
|
this.info.loginState = true
|
|
515
515
|
resolve(true)
|
|
516
516
|
} else {
|
|
517
517
|
reject(false)
|
|
518
518
|
}
|
|
519
519
|
},
|
|
520
520
|
fail: (err) => {
|
|
521
521
|
console.log('登录检查异常', err)
|
|
522
522
|
reject(false)
|
|
523
523
|
},
|
|
524
524
|
})
|
|
525
525
|
}
|
|
526
526
|
})
|
|
527
527
|
}
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
checkLoginStatus() {
|
|
531
531
|
return new Promise(async (resolve, reject) => {
|
|
532
532
|
try {
|
|
533
533
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
534
534
|
if (getLoginState) {
|
|
535
535
|
const { pin } = await this.getLoginCookie()
|
|
536
536
|
this.info.userInfo = {
|
|
537
537
|
pin,
|
|
538
538
|
encodePin: encodeURIComponent(pin),
|
|
539
539
|
ptkey: '',
|
|
540
540
|
}
|
|
541
541
|
resolve(true)
|
|
542
542
|
} else {
|
|
543
543
|
reject(false)
|
|
544
544
|
}
|
|
545
545
|
} catch (e) {
|
|
546
546
|
reject(false)
|
|
547
547
|
}
|
|
548
548
|
})
|
|
549
549
|
}
|
|
550
550
|
|
|
551
551
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
552
552
|
const createUpdateQueryInfo: {
|
|
553
553
|
query: {
|
|
554
554
|
shopId?: string | number
|
|
555
555
|
venderId?: string | number
|
|
556
556
|
}
|
|
557
557
|
updateShopInfoState: boolean
|
|
558
558
|
} = Object.assign(
|
|
559
559
|
{},
|
|
560
560
|
{
|
|
561
561
|
query: {},
|
|
562
562
|
updateShopInfoState: false,
|
|
563
563
|
},
|
|
564
564
|
updateQuery,
|
|
565
565
|
)
|
|
566
566
|
console.log(
|
|
567
567
|
'获取当前下发的店铺查询参数',
|
|
568
568
|
updateQuery,
|
|
569
569
|
'获取之前保存的shopInfo店铺查询参数',
|
|
570
570
|
this.info?.shopInfo,
|
|
571
571
|
)
|
|
572
572
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
573
573
|
const { shopId, venderId, un_area } = query
|
|
574
574
|
if (updateShopInfoState) {
|
|
575
575
|
this.info.queryInfo = {
|
|
576
576
|
...this.info.queryInfo,
|
|
577
577
|
...query,
|
|
578
578
|
}
|
|
579
579
|
if (shopId && venderId) {
|
|
580
580
|
this.info.shopInfo = {
|
|
581
581
|
shopId: `${shopId}`,
|
|
582
582
|
venderId: `${venderId}`,
|
|
583
583
|
}
|
|
584
584
|
}
|
|
585
585
|
} else {
|
|
586
586
|
this.info.queryInfo = {
|
|
587
587
|
...query,
|
|
588
588
|
}
|
|
589
589
|
if (
|
|
590
590
|
this.info.shopInfo?.shopId &&
|
|
591
591
|
this.info.shopInfo?.venderId &&
|
|
592
592
|
(this.info.shopInfo.shopId == shopId ||
|
|
593
593
|
this.info.shopInfo.venderId == venderId)
|
|
594
594
|
) {
|
|
595
595
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
596
596
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
597
597
|
console.log(
|
|
598
598
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
599
599
|
this.info.queryInfo,
|
|
600
600
|
)
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
603
|
this.info.queryInfo['shopId'] &&
|
|
604
604
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
605
605
|
this.info.queryInfo['venderId'] &&
|
|
606
606
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
607
607
|
console.log(
|
|
608
608
|
'h5==获取店铺下发查询参数\n',
|
|
609
609
|
query,
|
|
610
610
|
'\n获取店铺最后查询参数\n',
|
|
611
611
|
this.info.queryInfo,
|
|
612
612
|
'\n是否为更新店铺状态\n',
|
|
613
613
|
updateShopInfoState,
|
|
614
614
|
)
|
|
615
615
|
const changeArea =
|
|
616
616
|
un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
|
|
617
617
|
if (changeArea) {
|
|
618
618
|
this.info.pageInfo.address = changeArea
|
|
619
619
|
this.info.pageInfo.un_area = changeArea
|
|
620
620
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
621
621
|
}
|
|
622
622
|
if (urlCookie['wq_auth_token']) {
|
|
623
623
|
try {
|
|
624
624
|
this.info.userInfo.wqAuthToken = urlCookie['wq_auth_token']
|
|
625
625
|
console.log(
|
|
626
626
|
'url中获取cookie内wq_auth_token下发成功,将会在接口中的cookie携带',
|
|
627
627
|
urlCookie['wq_auth_token'],
|
|
628
628
|
)
|
|
629
629
|
cookie.set('wq_auth_token', this.info.userInfo.wqAuthToken, {
|
|
630
630
|
domain: '.jd.com',
|
|
631
631
|
path: '/',
|
|
632
632
|
expires: new Date(Date.now() + 4 * 60 * 60 * 1000),
|
|
633
633
|
})
|
|
634
634
|
} catch (e) {
|
|
635
635
|
console.log(
|
|
636
636
|
'url中转换解析下发的cookie失败,这里主要是京购下面访问h5会携带',
|
|
637
637
|
)
|
|
638
638
|
}
|
|
639
639
|
}
|
|
640
640
|
}
|