@conecli/cone-render 0.8.38-beta.0 → 0.8.39
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 -1
- 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/ExposureSmart/reporter.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/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/interface/component.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/index.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/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
|
jdAppVersion,
|
|
102
102
|
jdAppVersionStr,
|
|
103
103
|
isString,
|
|
104
104
|
isObject,
|
|
105
105
|
serialize,
|
|
106
106
|
urlCookie,
|
|
107
107
|
BUSINESS_TYPE,
|
|
108
108
|
SECTION_HOME_TAB_TYPE,
|
|
109
109
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
110
110
|
WXAPP_BIZ_KEY,
|
|
111
111
|
WX_BUSINESS_TYPE,
|
|
112
112
|
const designWidth = 750
|
|
113
113
|
return (
|
|
114
114
|
Math.ceil(
|
|
115
115
|
(((parseInt(String(size), 10) / 40) * 750) / designWidth) * 10000,
|
|
116
116
|
) /
|
|
117
117
|
10000 +
|
|
118
118
|
'rem'
|
|
119
119
|
)
|
|
120
120
|
loginState: false,
|
|
121
121
|
cookiesStr: '',
|
|
122
122
|
userInfo: userPinKey,
|
|
123
123
|
isJingGouMiniViewState: false,
|
|
124
124
|
pageInfo: {
|
|
125
125
|
wxBusinessType: WX_BUSINESS_TYPE.NO,
|
|
126
126
|
address: '',
|
|
127
127
|
addressCommaStr: '',
|
|
128
128
|
un_area: '',
|
|
129
129
|
vapptype: '1',
|
|
130
130
|
pageType: 'home',
|
|
131
131
|
isExposureState: false,
|
|
132
132
|
moduleId: '',
|
|
133
133
|
entrance: '',
|
|
134
134
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
135
135
|
floorExposureInfo: {},
|
|
136
136
|
floorVideInfo: {},
|
|
137
137
|
tabsLoadAllDataInfo: {
|
|
138
138
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
|
|
139
139
|
false,
|
|
140
140
|
},
|
|
141
141
|
updateShopInfosAllState: false,
|
|
142
142
|
isVipShop: false,
|
|
143
143
|
...shopConfig,
|
|
144
144
|
pageScrollTop: 0,
|
|
145
145
|
shopNavBarHeight: 0,
|
|
146
146
|
},
|
|
147
147
|
defaultQueryLogInfo: {
|
|
148
148
|
sourceType: 'JDshop',
|
|
149
149
|
sourceValue: '',
|
|
150
150
|
moduleId: 'none',
|
|
151
151
|
entrance: 'none',
|
|
152
152
|
},
|
|
153
153
|
sysInfo: {
|
|
154
154
|
windowWidth: isPc ? 375 : 0,
|
|
155
155
|
containerWidth: isPc ? 375 : 0,
|
|
156
156
|
windowHeight: 0,
|
|
157
157
|
netWorkType: '4g',
|
|
158
158
|
},
|
|
159
159
|
queryInfo: {},
|
|
160
160
|
shopInfo: {},
|
|
161
161
|
public info: CommonInterFace.BaseConfigInfo
|
|
162
162
|
public config: {
|
|
163
163
|
[key: string]: any
|
|
164
164
|
}
|
|
165
165
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
166
166
|
public renderedIsvComponents: CommonInterFace.renderedIsvComponents
|
|
167
167
|
public rootEleNode: HTMLElement | null
|
|
168
168
|
public checkStatusAndLoginPromise: object | null
|
|
169
169
|
constructor(opt) {
|
|
170
170
|
this.info = this._getConfig(opt)
|
|
171
171
|
this.config = {}
|
|
172
172
|
this.lazyContainer = {
|
|
173
173
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
174
174
|
appLazyContainerList: [],
|
|
175
175
|
appLazyFinishContainerList: [],
|
|
176
176
|
},
|
|
177
177
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
178
178
|
appLazyContainerList: [],
|
|
179
179
|
appLazyFinishContainerList: [],
|
|
180
180
|
},
|
|
181
181
|
}
|
|
182
182
|
this.renderedIsvComponents = {}
|
|
183
183
|
this.rootEleNode = document.querySelector('body')
|
|
184
184
|
this.checkStatusAndLoginPromise = null
|
|
185
185
|
}
|
|
186
186
|
_getConfig(opt) {
|
|
187
187
|
return Object.assign({}, DefaultConfig, opt)
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
updateBusinessDomainAndApi(domain, api) {
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
getSystemInfo() {
|
|
194
194
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = isPc
|
|
195
195
|
? {}
|
|
196
196
|
: getSystemInfos()
|
|
197
197
|
this.info.sysInfo = {
|
|
198
198
|
actualNavBarHeight: 0,
|
|
199
199
|
...this.info.sysInfo,
|
|
200
200
|
...info,
|
|
201
201
|
safeContentHeight: info.screenHeight,
|
|
202
202
|
headerHeight: 0,
|
|
203
203
|
tabBarHeight: 0,
|
|
204
204
|
}
|
|
205
205
|
if (isJdApp) {
|
|
206
206
|
this.info.sysInfo['hostVersionName'] = jdAppVersionStr
|
|
207
207
|
this.info.sysInfo['hostAppVersion'] = jdAppVersion
|
|
208
208
|
this.getAddressCachePromise()
|
|
209
209
|
}
|
|
210
210
|
this.getNetWorkType()
|
|
211
211
|
}
|
|
212
212
|
|
|
213
213
|
getNetWorkType() {
|
|
214
214
|
Taro.getNetworkType().then((getRes) => {
|
|
215
215
|
getRes &&
|
|
216
216
|
getRes.networkType &&
|
|
217
217
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
218
218
|
})
|
|
219
219
|
}
|
|
220
220
|
registerCode(code: string) {
|
|
221
221
|
if (window?.jmfe) {
|
|
222
222
|
console.log('registerCode:', code)
|
|
223
223
|
window.jmfe.registerCode(code)
|
|
224
224
|
} else {
|
|
225
225
|
console.warn('jmfe对象不存在,可能没有提前引入jd-jssdk.js')
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
getCacheAddressRouter() {
|
|
229
229
|
if (!window.jmfe) return
|
|
230
230
|
if (isAndroidDevice) {
|
|
231
231
|
return window.jmfe.callRouter({
|
|
232
232
|
jdRouter: '1',
|
|
233
233
|
routerURL: 'router://JDAddressModule/getCacheAddress',
|
|
234
234
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
235
235
|
})
|
|
236
236
|
} else {
|
|
237
237
|
return window.jmfe.callRouter({
|
|
238
238
|
jdRouter: '1',
|
|
239
239
|
routerURL: 'router://JDBAddressCacheManagerModule/getCacheAddress',
|
|
240
240
|
routerParam: { sceneId: 'basicShoppingProcess' },
|
|
241
241
|
})
|
|
242
242
|
}
|
|
243
243
|
}
|
|
244
244
|
|
|
245
245
|
getAddressCachePromise() {
|
|
246
246
|
return new Promise((resolve, reject) => {
|
|
247
247
|
if (
|
|
248
248
|
this?.info?.sysInfo?.lat &&
|
|
249
249
|
this?.info?.sysInfo?.lng &&
|
|
250
250
|
this?.info?.sysInfo?.area
|
|
251
251
|
) {
|
|
252
252
|
resolve({
|
|
253
253
|
lat: this.info.sysInfo.lat,
|
|
254
254
|
lng: this.info.sysInfo.lng,
|
|
255
255
|
area: this?.info?.sysInfo?.area,
|
|
256
256
|
})
|
|
257
257
|
} else {
|
|
258
258
|
ready('jmfe', 3000)
|
|
259
259
|
.then(() => {
|
|
260
260
|
this.registerCode(JSSDK_APP_WEBVIEW_CODE)
|
|
261
261
|
this.getCacheAddressRouter()
|
|
262
262
|
.then(({ status, data }) => {
|
|
263
263
|
if (status === '0' && data) {
|
|
264
264
|
let area = '',
|
|
265
265
|
lat = this?.info?.sysInfo?.lat || '',
|
|
266
266
|
lng = this?.info?.sysInfo?.lng || ''
|
|
267
267
|
if (
|
|
268
268
|
(data?.lat || data?.latitude) &&
|
|
269
269
|
(data?.lng || data?.longitude)
|
|
270
270
|
) {
|
|
271
271
|
lat = data.lat || data.latitude
|
|
272
272
|
lng = data.lng || data.longitude
|
|
273
273
|
this.info.sysInfo['lat'] = lat
|
|
274
274
|
this.info.sysInfo['lng'] = lng
|
|
275
275
|
}
|
|
276
276
|
if (data.provinceId) {
|
|
277
277
|
area = `${data.provinceId}_${data.cityId || 0}_${
|
|
278
278
|
data.countyId || 0
|
|
279
279
|
}_${data.townId || 0}`
|
|
280
280
|
this.info.pageInfo['address'] = area
|
|
281
281
|
this.info.pageInfo['addressCommaStr'] = area.replace(
|
|
282
282
|
/_/g,
|
|
283
283
|
',',
|
|
284
284
|
)
|
|
285
285
|
}
|
|
286
286
|
resolve({
|
|
287
287
|
lat: lat,
|
|
288
288
|
lng: lng,
|
|
289
289
|
area: area,
|
|
290
290
|
})
|
|
291
291
|
} else {
|
|
292
292
|
resolve({ lat: '', lng: '', area: '' })
|
|
293
293
|
}
|
|
294
294
|
})
|
|
295
295
|
.catch(() => {
|
|
296
296
|
reject(null)
|
|
297
297
|
})
|
|
298
298
|
})
|
|
299
299
|
.catch(() => {
|
|
300
300
|
console.log('window.jmfe不存在')
|
|
301
301
|
reject(null)
|
|
302
302
|
})
|
|
303
303
|
}
|
|
304
304
|
})
|
|
305
305
|
}
|
|
306
306
|
|
|
307
307
|
toLogin(options) {
|
|
308
308
|
return this.info.isJingGouMiniViewState
|
|
309
309
|
? this.toWxAppLogin(options)
|
|
310
310
|
: this.toWebLogin(options)
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
doLogin(options) {
|
|
314
314
|
return this.toLogin(options)
|
|
315
315
|
}
|
|
316
316
|
|
|
317
317
|
toWebLogin(options) {
|
|
318
318
|
let params: {
|
|
319
319
|
returnurl: string
|
|
320
320
|
} = {
|
|
321
321
|
returnurl: '',
|
|
322
322
|
}
|
|
323
323
|
const loginUrl = isPc
|
|
324
324
|
? `//passport.jd.com/new/login.aspx`
|
|
325
325
|
: `${domain.mobileLogin}/user/login.action`
|
|
326
326
|
const defaultParams = {
|
|
327
327
|
appid: '100',
|
|
328
328
|
returnurl: window.location.href,
|
|
329
329
|
}
|
|
330
330
|
if (isString(options)) {
|
|
331
331
|
params = Object.assign({}, defaultParams, {
|
|
332
332
|
returnurl: options,
|
|
333
333
|
})
|
|
334
334
|
} else if (isObject(options)) {
|
|
335
335
|
params = Object.assign({}, defaultParams, options)
|
|
336
336
|
} else {
|
|
337
337
|
params = defaultParams
|
|
338
338
|
}
|
|
339
339
|
params.returnurl = encodeURIComponent(params.returnurl)
|
|
340
340
|
let getFullUrl = loginUrl + '?' + serialize(params)
|
|
341
341
|
if (isPc) {
|
|
342
342
|
getFullUrl = getFullUrl.replace(/returnurl/, 'ReturnUrl')
|
|
343
343
|
}
|
|
344
344
|
return Promise.resolve({
|
|
345
345
|
h5ToUrl: true,
|
|
346
346
|
url: getFullUrl,
|
|
347
347
|
}).then(() => {
|
|
348
348
|
window.location.href = getFullUrl
|
|
349
349
|
})
|
|
350
350
|
}
|
|
351
351
|
|
|
352
352
|
toWxAppLogin(options) {
|
|
353
353
|
console.log('微信京购小程序中h5登录跳转', options)
|
|
354
354
|
return Promise.resolve(true).then(() => {
|
|
355
355
|
window.location.href = `${
|
|
356
356
|
domain.wq
|
|
357
357
|
}/pinbind/pintokenredirect?biz=${WXAPP_BIZ_KEY}&url=${encodeURIComponent(
|
|
358
358
|
window.location.href,
|
|
359
359
|
)}`
|
|
360
360
|
})
|
|
361
361
|
}
|
|
362
362
|
|
|
363
363
|
getLoginCookie() {
|
|
364
364
|
return Promise.resolve({
|
|
365
365
|
pin: cookie.get('pin') || '',
|
|
366
366
|
})
|
|
367
367
|
}
|
|
368
368
|
|
|
369
369
|
clearLoginCookie() {
|
|
370
370
|
cookie.remove('pin')
|
|
371
371
|
}
|
|
372
372
|
|
|
373
373
|
checkStatusAndLogin(options = {}) {
|
|
374
374
|
if (!this.checkStatusAndLoginPromise) {
|
|
375
375
|
this.checkStatusAndLoginPromise = new Promise(async (resolve, reject) => {
|
|
376
376
|
try {
|
|
377
377
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
378
378
|
if (getLoginState) {
|
|
379
379
|
resolve(true)
|
|
380
380
|
} else {
|
|
381
381
|
this.toLogin(options)
|
|
382
382
|
reject(false)
|
|
383
383
|
}
|
|
384
384
|
} catch (e) {
|
|
385
385
|
this.toLogin(options)
|
|
386
386
|
reject(false)
|
|
387
387
|
}
|
|
388
388
|
})
|
|
389
389
|
return this.checkStatusAndLoginPromise
|
|
390
390
|
} else {
|
|
391
391
|
return this.checkStatusAndLoginPromise
|
|
392
392
|
.then(() => {
|
|
393
393
|
return Promise.resolve(true)
|
|
394
394
|
})
|
|
395
395
|
.catch(() => {
|
|
396
396
|
this.toLogin(options)
|
|
397
397
|
return Promise.reject(true)
|
|
398
398
|
})
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
doCheckLoginStateAndForApiCheck() {
|
|
403
403
|
if (this.info.loginState) {
|
|
404
404
|
return Promise.resolve(true)
|
|
405
405
|
} else {
|
|
406
406
|
return new Promise((resolve, reject) => {
|
|
407
407
|
if (this.info.isJingGouMiniViewState) {
|
|
408
408
|
const getWqAuthToken = cookie.get('wq_auth_token')
|
|
409
409
|
if (getWqAuthToken) {
|
|
410
410
|
this.info.loginState = true
|
|
411
411
|
resolve(true)
|
|
412
412
|
} else {
|
|
413
413
|
reject(false)
|
|
414
414
|
}
|
|
415
415
|
} else {
|
|
416
416
|
Taro.request({
|
|
417
417
|
url: api.isLogin,
|
|
418
418
|
jsonp: true,
|
|
419
419
|
timeout: 3000,
|
|
420
420
|
success: (res) => {
|
|
421
421
|
const { statusCode, data } = res
|
|
422
422
|
if (
|
|
423
423
|
statusCode === 200 &&
|
|
424
424
|
data?.islogin &&
|
|
425
425
|
Number(data.islogin) === 1
|
|
426
426
|
) {
|
|
427
427
|
this.info.loginState = true
|
|
428
428
|
resolve(true)
|
|
429
429
|
} else {
|
|
430
430
|
reject(false)
|
|
431
431
|
}
|
|
432
432
|
},
|
|
433
433
|
fail: (err) => {
|
|
434
434
|
console.log('登录检查异常', err)
|
|
435
435
|
reject(false)
|
|
436
436
|
},
|
|
437
437
|
})
|
|
438
438
|
}
|
|
439
439
|
})
|
|
440
440
|
}
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
checkLoginStatus() {
|
|
444
444
|
return new Promise(async (resolve, reject) => {
|
|
445
445
|
try {
|
|
446
446
|
const getLoginState = await this.doCheckLoginStateAndForApiCheck()
|
|
447
447
|
if (getLoginState) {
|
|
448
448
|
const { pin } = await this.getLoginCookie()
|
|
449
449
|
this.info.userInfo = {
|
|
450
450
|
pin,
|
|
451
451
|
encodePin: encodeURIComponent(pin),
|
|
452
452
|
ptkey: '',
|
|
453
453
|
}
|
|
454
454
|
resolve(true)
|
|
455
455
|
} else {
|
|
456
456
|
reject(false)
|
|
457
457
|
}
|
|
458
458
|
} catch (e) {
|
|
459
459
|
reject(false)
|
|
460
460
|
}
|
|
461
461
|
})
|
|
462
462
|
}
|
|
463
463
|
|
|
464
464
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
465
465
|
const createUpdateQueryInfo: {
|
|
466
466
|
query: {
|
|
467
467
|
shopId?: string | number
|
|
468
468
|
venderId?: string | number
|
|
469
469
|
}
|
|
470
470
|
updateShopInfoState: boolean
|
|
471
471
|
} = Object.assign(
|
|
472
472
|
{},
|
|
473
473
|
{
|
|
474
474
|
query: {},
|
|
475
475
|
updateShopInfoState: false,
|
|
476
476
|
},
|
|
477
477
|
updateQuery,
|
|
478
478
|
)
|
|
479
479
|
console.log(
|
|
480
480
|
'获取当前下发的店铺查询参数',
|
|
481
481
|
updateQuery,
|
|
482
482
|
'获取之前保存的shopInfo店铺查询参数',
|
|
483
483
|
this.info?.shopInfo,
|
|
484
484
|
)
|
|
485
485
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
486
486
|
const { shopId, venderId, un_area } = query
|
|
487
487
|
if (updateShopInfoState) {
|
|
488
488
|
this.info.queryInfo = {
|
|
489
489
|
...this.info.queryInfo,
|
|
490
490
|
...query,
|
|
491
491
|
}
|
|
492
492
|
if (shopId && venderId) {
|
|
493
493
|
this.info.shopInfo = {
|
|
494
494
|
shopId: `${shopId}`,
|
|
495
495
|
venderId: `${venderId}`,
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
} else {
|
|
499
499
|
this.info.queryInfo = {
|
|
500
500
|
...query,
|
|
501
501
|
}
|
|
502
502
|
if (
|
|
503
503
|
this.info.shopInfo?.shopId &&
|
|
504
504
|
this.info.shopInfo?.venderId &&
|
|
505
505
|
(this.info.shopInfo.shopId == shopId ||
|
|
506
506
|
this.info.shopInfo.venderId == venderId)
|
|
507
507
|
) {
|
|
508
508
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
509
509
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
510
510
|
console.log(
|
|
511
511
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
512
512
|
this.info.queryInfo,
|
|
513
513
|
)
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
this.info.queryInfo['shopId'] &&
|
|
517
517
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
518
518
|
this.info.queryInfo['venderId'] &&
|
|
519
519
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
520
520
|
console.log(
|
|
521
521
|
'h5==获取店铺下发查询参数\n',
|
|
522
522
|
query,
|
|
523
523
|
'\n获取店铺最后查询参数\n',
|
|
524
524
|
this.info.queryInfo,
|
|
525
525
|
'\n是否为更新店铺状态\n',
|
|
526
526
|
updateShopInfoState,
|
|
527
527
|
)
|
|
528
528
|
const changeArea =
|
|
529
529
|
un_area && un_area.length > 0 ? un_area : ipLoc_djd ? ipLoc_djd : ''
|
|
530
530
|
if (changeArea) {
|
|
531
531
|
this.info.pageInfo.address = changeArea
|
|
532
532
|
this.info.pageInfo.un_area = changeArea
|
|
533
533
|
this.info.pageInfo.addressCommaStr = changeArea.replace(/_/g, ',')
|
|
534
534
|
}
|
|
535
535
|
if (urlCookie['wq_auth_token']) {
|
|
536
536
|
try {
|
|
537
537
|
this.info.userInfo.wqAuthToken = urlCookie['wq_auth_token']
|
|
538
538
|
console.log(
|
|
539
539
|
'url中获取cookie内wq_auth_token下发成功,将会在接口中的cookie携带',
|
|
540
540
|
urlCookie['wq_auth_token'],
|
|
541
541
|
)
|
|
542
542
|
cookie.set('wq_auth_token', this.info.userInfo.wqAuthToken, {
|
|
543
543
|
domain: '.jd.com',
|
|
544
544
|
path: '/',
|
|
545
545
|
expires: new Date(Date.now() + 4 * 60 * 60 * 1000),
|
|
546
546
|
})
|
|
547
547
|
} catch (e) {
|
|
548
548
|
console.log(
|
|
549
549
|
'url中转换解析下发的cookie失败,这里主要是京购下面访问h5会携带',
|
|
550
550
|
)
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
}
|
package/dist/common/index.jd.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
floorVideInfo: {},
|
|
3
2
|
public config: object
|
|
4
3
|
this.config = {}
|
|
5
4
|
return new Promise((resolve, reject) => {
|
|
6
5
|
if (typeof jd !== 'undefined' && jd.requestWebCookie) {
|
|
7
6
|
jd.requestWebCookie({
|
|
8
7
|
needpin: 1,
|
|
9
8
|
success: (res) => {
|
|
10
9
|
console.log(res)
|
|
11
10
|
const { ticket, pt_pin } = res
|
|
12
11
|
console.log('requestWebCookie.success', res)
|
|
13
12
|
this.info.userInfo = {
|
|
14
13
|
pin: pt_pin,
|
|
15
14
|
encodePin: encodeURIComponent(pt_pin),
|
|
16
15
|
ptkey: ticket,
|
|
17
16
|
}
|
|
18
17
|
this.miniAppLogInstance &&
|
|
19
18
|
this.miniAppLogInstance.set({
|
|
20
19
|
account: pt_pin,
|
|
21
20
|
})
|
|
22
21
|
this.info.loginState = true
|
|
23
22
|
resolve(res)
|
|
24
23
|
},
|
|
25
24
|
fail(res) {
|
|
26
25
|
console.log('requestWebCookie.fail', res)
|
|
27
26
|
reject(res)
|
|
28
27
|
},
|
|
29
28
|
})
|
|
30
29
|
} else {
|
|
31
30
|
resolve({
|
|
32
31
|
pin: '',
|
|
33
32
|
ptkey: '',
|
|
34
33
|
mock: true
|
|
35
34
|
})
|
|
36
35
|
}
|
|
37
36
|
})
|
|
38
37
|
this.checkLoginStatus().then(res => {
|
|
39
38
|
console.log(
|
|
40
39
|
'jdLoadCheckStatusAndLogin hasUserLogined.success: ',
|
|
41
40
|
res,
|
|
42
41
|
)
|
|
43
42
|
resolve(res)
|
|
44
43
|
}).catch(err => {
|
|
45
44
|
console.warn(
|
|
46
45
|
'jdLoadCheckStatusAndLogin hasUserLogined.fail: ',
|
|
47
46
|
err,
|
|
48
47
|
)
|
|
49
48
|
this.toLogin().then(res => {
|
|
50
49
|
resolve(res)
|
|
51
50
|
}).catch(err => {
|
|
52
51
|
reject(err)
|
|
53
52
|
})
|
|
54
53
|
})
|
|
55
54
|
return this.checkStatusAndLoginPromise
|
|
56
55
|
return new Promise((resolve,reject) => {
|
|
57
56
|
if (typeof jd !== 'undefined' && jd.hasUserLogined) {
|
|
58
57
|
jd.hasUserLogined({
|
|
59
58
|
success: (res) => {
|
|
60
59
|
console.log('hasUserLogined.success: ', res)
|
|
61
60
|
if (res.status === 1) {
|
|
62
61
|
this.getLoginCookie()
|
|
63
62
|
resolve(res)
|
|
64
63
|
}else {
|
|
65
64
|
reject(res)
|
|
66
65
|
}
|
|
67
66
|
},
|
|
68
67
|
fail: (res) => {
|
|
69
68
|
console.warn('hasUserLogined.fail: ', res)
|
|
70
69
|
reject(res)
|
|
71
70
|
},
|
|
72
71
|
})
|
|
73
72
|
} else {
|
|
74
73
|
reject(false)
|
|
75
74
|
}
|
|
76
75
|
})
|
|
76
|
+
import Taro from '@tarojs/taro'
|
|
77
77
|
floorVideInfo: {},
|
|
78
78
|
public config: object
|
|
79
79
|
this.config = {}
|
|
80
80
|
return new Promise((resolve, reject) => {
|
|
81
81
|
if (typeof jd !== 'undefined' && jd.requestWebCookie) {
|
|
82
82
|
jd.requestWebCookie({
|
|
83
83
|
needpin: 1,
|
|
84
84
|
success: (res) => {
|
|
85
85
|
console.log(res)
|
|
86
86
|
const { ticket, pt_pin } = res
|
|
87
87
|
console.log('requestWebCookie.success', res)
|
|
88
88
|
this.info.userInfo = {
|
|
89
89
|
pin: pt_pin,
|
|
90
90
|
encodePin: encodeURIComponent(pt_pin),
|
|
91
91
|
ptkey: ticket,
|
|
92
92
|
}
|
|
93
93
|
this.miniAppLogInstance &&
|
|
94
94
|
this.miniAppLogInstance.set({
|
|
95
95
|
account: pt_pin,
|
|
96
96
|
})
|
|
97
97
|
this.info.loginState = true
|
|
98
98
|
resolve(res)
|
|
99
99
|
},
|
|
100
100
|
fail(res) {
|
|
101
101
|
console.log('requestWebCookie.fail', res)
|
|
102
102
|
reject(res)
|
|
103
103
|
},
|
|
104
104
|
})
|
|
105
105
|
} else {
|
|
106
106
|
resolve({
|
|
107
107
|
pin: '',
|
|
108
108
|
ptkey: '',
|
|
109
109
|
mock: true
|
|
110
110
|
})
|
|
111
111
|
}
|
|
112
112
|
})
|
|
113
113
|
this.checkLoginStatus().then(res => {
|
|
114
114
|
console.log(
|
|
115
115
|
'jdLoadCheckStatusAndLogin hasUserLogined.success: ',
|
|
116
116
|
res,
|
|
117
117
|
)
|
|
118
118
|
resolve(res)
|
|
119
119
|
}).catch(err => {
|
|
120
120
|
console.warn(
|
|
121
121
|
'jdLoadCheckStatusAndLogin hasUserLogined.fail: ',
|
|
122
122
|
err,
|
|
123
123
|
)
|
|
124
124
|
this.toLogin().then(res => {
|
|
125
125
|
resolve(res)
|
|
126
126
|
}).catch(err => {
|
|
127
127
|
reject(err)
|
|
128
128
|
})
|
|
129
129
|
})
|
|
130
130
|
return this.checkStatusAndLoginPromise
|
|
131
131
|
return new Promise((resolve,reject) => {
|
|
132
132
|
if (typeof jd !== 'undefined' && jd.hasUserLogined) {
|
|
133
133
|
jd.hasUserLogined({
|
|
134
134
|
success: (res) => {
|
|
135
135
|
console.log('hasUserLogined.success: ', res)
|
|
136
136
|
if (res.status === 1) {
|
|
137
137
|
this.getLoginCookie()
|
|
138
138
|
resolve(res)
|
|
139
139
|
}else {
|
|
140
140
|
reject(res)
|
|
141
141
|
}
|
|
142
142
|
},
|
|
143
143
|
fail: (res) => {
|
|
144
144
|
console.warn('hasUserLogined.fail: ', res)
|
|
145
145
|
reject(res)
|
|
146
146
|
},
|
|
147
147
|
})
|
|
148
148
|
} else {
|
|
149
149
|
reject(false)
|
|
150
150
|
}
|
|
151
151
|
})
|
|
152
152
|
|
|
153
153
|
getAddressCachePromise = () => {
|
|
154
154
|
return Promise.reject("该方法只在APP内适用")
|