@conecli/cone-render 0.9.1-shop2.9 → 0.10.1-beta.1
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/assets/icon_blue_info.svg +1 -0
- 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/jdplayerSdk.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +67 -0
- package/dist/components/debug/DebugLayout/index.tsx +1 -0
- package/dist/components/debug/DebugLayout/utils.ts +1 -0
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/open/api/index.ts +1 -1
- package/dist/sass/app.h5.scss +5 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +42 -39
- package/dist/customHooks/useDocumentVisibilitychange.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
WXAPP_SUBS_GUIDER
|
|
3
2
|
WXAPP_BIZ_SHOP_LIGHT_KEY
|
|
4
3
|
floorVideInfo: {},
|
|
5
4
|
productVideInfo: {},
|
|
6
5
|
isVipShop: false,
|
|
7
6
|
isJdShowNativeImmersivePlayer: false,
|
|
8
7
|
pageIdxHeightInfo: {
|
|
9
8
|
list: []
|
|
10
9
|
},
|
|
11
10
|
jdBottomBarHeight: 0,
|
|
12
11
|
jdNativeHeaderHeight: 0,
|
|
13
12
|
shopInfo: {},
|
|
14
13
|
openAppData: {}
|
|
15
14
|
public config: {
|
|
16
15
|
[key: string]: any
|
|
17
16
|
}
|
|
18
17
|
this.config = {}
|
|
19
18
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER
|
|
20
19
|
|
|
21
20
|
taskTimeoutPromise(callBack, timeout = 2000){
|
|
22
21
|
return new Promise((resolve) => {
|
|
23
22
|
setTimeout(() => {
|
|
24
23
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
25
24
|
return resolve(getCallBackRes || false)
|
|
26
25
|
}, timeout)
|
|
27
26
|
})
|
|
28
27
|
}
|
|
29
28
|
console.log('=================>', 'updateBusinessDomainAndApi')
|
|
30
29
|
|
|
31
30
|
checkStatusAndLogin(options = {}) {
|
|
32
31
|
|
|
33
32
|
checkJdStatusAndLogin(options = {
|
|
34
33
|
loginColor: {
|
|
35
34
|
bzi: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
36
35
|
dpin: 0,
|
|
37
36
|
},
|
|
38
37
|
}){
|
|
39
38
|
return this.checkStatusAndLogin(options)
|
|
40
39
|
}
|
|
41
40
|
loginColor: {
|
|
42
41
|
bzi:WXAPP_BIZ_KEY,
|
|
43
42
|
dpin: 1,
|
|
44
43
|
},
|
|
45
44
|
setTimeout(() => {
|
|
46
45
|
console.log("微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
|
|
47
46
|
this.getLoginCookie(`${Date.now()}`)
|
|
48
47
|
},500)
|
|
49
48
|
this.getLoginCookie(`${Date.now()}`)
|
|
50
49
|
loginColor: {
|
|
51
50
|
bzi:WXAPP_BIZ_KEY,
|
|
52
51
|
dpin: 1,
|
|
53
52
|
},
|
|
54
53
|
setTimeout(() => {
|
|
55
54
|
console.log("微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
|
|
56
55
|
this.getLoginCookie(`${Date.now()}`)
|
|
57
56
|
},500)
|
|
58
57
|
|
|
59
58
|
doLoginForJdPin(options = {}) {
|
|
60
59
|
return this.doLogin({
|
|
61
60
|
loginColor: {
|
|
62
61
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
63
62
|
dpin: 0,
|
|
64
63
|
},
|
|
65
64
|
...options
|
|
66
65
|
})
|
|
67
66
|
}
|
|
68
67
|
return new Promise((resolve) => {
|
|
69
68
|
console.log("开始获取更新wxapp中的cookie信息", updateKey)
|
|
70
69
|
if(this.config.wqCookie && this.config.wqCookieStr && this.config.getWqCookieKey === updateKey){
|
|
71
70
|
console.log("已有存储wxapp中的cookie信息,直接返回",this.config)
|
|
72
71
|
resolve({
|
|
73
72
|
wqCookie: this.config.wqCookie,
|
|
74
73
|
wqCookieStr: this.config.wqCookieStr,
|
|
75
74
|
})
|
|
76
75
|
}else {
|
|
77
76
|
if (isPublishToWxapp) {
|
|
78
77
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
79
78
|
if (getWxappCookieObj) {
|
|
80
79
|
const getCookieObj = getWxappCookieObj['_data']
|
|
81
80
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
82
81
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie
|
|
83
82
|
this.info.loginState = true
|
|
84
83
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
85
84
|
this.info.userInfo.wqVisitkey = visitkey
|
|
86
85
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
87
86
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
88
87
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
89
88
|
if (getUserAddress) {
|
|
90
89
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
91
90
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo
|
|
92
91
|
.address
|
|
93
92
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
94
93
|
: ''
|
|
95
94
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
96
95
|
Taro.eventCenter.trigger(
|
|
97
96
|
TaroEventType.USER_AREA_UPDATE,
|
|
98
97
|
this.info.pageInfo.address,
|
|
99
98
|
)
|
|
100
99
|
}
|
|
101
100
|
if(this.miniAppLogInstance){
|
|
102
101
|
this.miniAppLogInstance.set({
|
|
103
102
|
account: pin,
|
|
104
103
|
unionid: wq_unionid,
|
|
105
104
|
openid: wxapp_openid,
|
|
106
105
|
})
|
|
107
106
|
}
|
|
108
107
|
this.config.wqCookie = wqCookie
|
|
109
108
|
this.config.wqCookieStr = wqCookieStr
|
|
110
109
|
this.config.getWqCookieKey = updateKey
|
|
111
110
|
console.log("解析wxapp中的cookie信息成功,返回后存储",this.config)
|
|
112
111
|
resolve({
|
|
113
112
|
wqCookie,
|
|
114
113
|
wqCookieStr,
|
|
115
114
|
})
|
|
116
115
|
}else {
|
|
117
116
|
console.log("解析wxapp中的cookie信息异常,返回异常结果",this.config)
|
|
118
117
|
resolve({
|
|
119
118
|
wqCookie: false,
|
|
120
119
|
wqCookieStr: false,
|
|
121
120
|
})
|
|
122
121
|
}
|
|
123
122
|
}else {
|
|
124
123
|
resolve({
|
|
125
124
|
wqCookie: false,
|
|
126
125
|
wqCookieStr: false,
|
|
127
126
|
})
|
|
128
127
|
}
|
|
129
128
|
}
|
|
130
129
|
})
|
|
131
130
|
|
|
132
131
|
getAddressCachePromise = () => {
|
|
133
132
|
return Promise.reject("该方法只在APP内适用")
|
|
134
133
|
}
|
|
135
134
|
this.info.originQueryInfo = {
|
|
136
135
|
...query
|
|
137
136
|
}
|
|
137
|
+
import Taro from '@tarojs/taro'
|
|
138
138
|
WXAPP_LOGIN,
|
|
139
139
|
WXAPP_BIZ,
|
|
140
140
|
WXAPP_USER_INFO,
|
|
141
141
|
WXAPP_NAVIGATOR,
|
|
142
142
|
WXAPP_REPORT_GDT,
|
|
143
143
|
WXAPP_PARAMS_SIGN,
|
|
144
144
|
WXAPP_FINGER_REPORT,
|
|
145
145
|
WXAPP_REPORT_MANAGE,
|
|
146
146
|
WXAPP_SUBS_GUIDER,
|
|
147
147
|
BUSINESS_TYPE,
|
|
148
148
|
SHOP_MENU_ID_TYPE,
|
|
149
149
|
SHOP_MENU_ID_NAME,
|
|
150
150
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
151
151
|
SECTION_HOME_TAB_TYPE,
|
|
152
152
|
TaroEventType,
|
|
153
153
|
WX_BUSINESS_TYPE,
|
|
154
154
|
WXAPP_BIZ_KEY,
|
|
155
155
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
156
156
|
getSystemInfos,
|
|
157
157
|
getTaroStorageKeyValue,
|
|
158
158
|
getWxAppCookieStr,
|
|
159
159
|
objectToUrlEncode,
|
|
160
160
|
loginState: jdUserLoginState,
|
|
161
161
|
cookiesStr: '',
|
|
162
162
|
userInfo: userPinKey,
|
|
163
163
|
pageInfo: {
|
|
164
164
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
165
165
|
address: '',
|
|
166
166
|
addressCommaStr: '',
|
|
167
167
|
un_area: '',
|
|
168
168
|
vapptype: '1',
|
|
169
169
|
pageType: 'home',
|
|
170
170
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
171
171
|
floorExposureInfo: {},
|
|
172
172
|
floorVideInfo: {},
|
|
173
173
|
productVideInfo: {},
|
|
174
174
|
tabsLoadAllDataInfo: {
|
|
175
175
|
[SECTION_HOME_TAB_NAME_TYPE[
|
|
176
176
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
177
177
|
]]: false,
|
|
178
178
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
179
179
|
},
|
|
180
180
|
updateShopInfosAllState: false,
|
|
181
181
|
isVipShop: false,
|
|
182
182
|
isJdShowNativeImmersivePlayer: false,
|
|
183
183
|
...shopConfig,
|
|
184
184
|
pageScrollTop: 0,
|
|
185
185
|
pageIdxHeightInfo: {
|
|
186
186
|
list: [],
|
|
187
187
|
},
|
|
188
188
|
shopNavBarHeight: 0,
|
|
189
189
|
},
|
|
190
190
|
defaultQueryLogInfo: {
|
|
191
191
|
sourceType: 'JDshop',
|
|
192
192
|
sourceValue: '',
|
|
193
193
|
moduleId: 'none',
|
|
194
194
|
entrance: 'none',
|
|
195
195
|
},
|
|
196
196
|
originQueryInfo: {},
|
|
197
197
|
sysInfo: {
|
|
198
198
|
windowWidth: 0,
|
|
199
199
|
windowHeight: 0,
|
|
200
200
|
netWorkType: '4g',
|
|
201
201
|
jdBottomBarHeight: 0,
|
|
202
202
|
jdNativeHeaderHeight: 0,
|
|
203
203
|
},
|
|
204
204
|
queryInfo: {},
|
|
205
205
|
shopInfo: {},
|
|
206
206
|
openAppData: {},
|
|
207
207
|
public info: CommonInterFace.BaseConfigInfo
|
|
208
208
|
public config: {
|
|
209
209
|
[key: string]: any
|
|
210
210
|
}
|
|
211
211
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
212
212
|
public rootEleNode: HTMLElement | null
|
|
213
213
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil
|
|
214
214
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null
|
|
215
215
|
public checkStatusAndLoginPromise: object | null
|
|
216
216
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin
|
|
217
217
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo
|
|
218
218
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo
|
|
219
219
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage
|
|
220
220
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT
|
|
221
221
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator
|
|
222
222
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign
|
|
223
223
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign
|
|
224
224
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign
|
|
225
225
|
constructor(opt) {
|
|
226
226
|
this.info = this._getConfig(opt)
|
|
227
227
|
this.config = {}
|
|
228
228
|
this.lazyContainer = {
|
|
229
229
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
230
230
|
appLazyContainerList: [],
|
|
231
231
|
appLazyFinishContainerList: [],
|
|
232
232
|
},
|
|
233
233
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
234
234
|
appLazyContainerList: [],
|
|
235
235
|
appLazyFinishContainerList: [],
|
|
236
236
|
},
|
|
237
237
|
}
|
|
238
238
|
this.rootEleNode = null
|
|
239
239
|
this.miniApplogUtil = MiniAppLogUtil
|
|
240
240
|
this.miniAppLogInstance = null
|
|
241
241
|
this.checkStatusAndLoginPromise = null
|
|
242
242
|
this.wxAppLoginInstance = WXAPP_LOGIN
|
|
243
243
|
this.wxAppBizInstance = WXAPP_BIZ
|
|
244
244
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO
|
|
245
245
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE
|
|
246
246
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT
|
|
247
247
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR
|
|
248
248
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN
|
|
249
249
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
|
|
250
250
|
? new WXAPP_FINGER_REPORT()
|
|
251
251
|
: {}
|
|
252
252
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER
|
|
253
253
|
}
|
|
254
254
|
_getConfig(opt) {
|
|
255
255
|
return Object.assign({}, DefaultConfig, opt)
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
259
259
|
return new Promise(resolve => {
|
|
260
260
|
setTimeout(() => {
|
|
261
261
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
262
262
|
return resolve(getCallBackRes || false)
|
|
263
263
|
}, timeout)
|
|
264
264
|
})
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
updateBusinessDomainAndApi(domain, api) {
|
|
268
268
|
console.log('=================>', 'updateBusinessDomainAndApi')
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
getFullScreenHeight(systemInfo) {
|
|
272
272
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo
|
|
273
273
|
let result = screenHeight
|
|
274
274
|
if (statusBarHeight > 20 && isAndroid) {
|
|
275
275
|
result = screenHeight + statusBarHeight
|
|
276
276
|
}
|
|
277
277
|
return result
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
getTabBarHeight(systemInfo) {
|
|
281
281
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo
|
|
282
282
|
let result = 50
|
|
283
283
|
if (statusBarHeight > 20) {
|
|
284
284
|
if (isIOS) {
|
|
285
285
|
result = 84
|
|
286
286
|
} else if (isAndroid) {
|
|
287
287
|
result = 53
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
return result
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
getSystemInfo() {
|
|
294
294
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {}
|
|
295
295
|
const actualNavBarHeight =
|
|
296
296
|
(info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0)
|
|
297
297
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0)
|
|
298
298
|
const fullScreenHeight = this.getFullScreenHeight(info)
|
|
299
299
|
const tabBarHeight = this.getTabBarHeight(info)
|
|
300
300
|
const safeContentHeight = fullScreenHeight - headerHeight
|
|
301
301
|
this.info.sysInfo = {
|
|
302
302
|
...this.info.sysInfo,
|
|
303
303
|
...info,
|
|
304
304
|
actualNavBarHeight,
|
|
305
305
|
headerHeight,
|
|
306
306
|
fullScreenHeight,
|
|
307
307
|
tabBarHeight,
|
|
308
308
|
safeContentHeight,
|
|
309
309
|
}
|
|
310
310
|
if (this.info.sysInfo['hostVersionName']) {
|
|
311
311
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
312
312
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
313
313
|
)
|
|
314
314
|
}
|
|
315
315
|
this.info.sysInfo['wifiVideoAutoPlay'] = false
|
|
316
316
|
this.getNetWorkType()
|
|
317
317
|
console.log('获取系统信息', this.info.sysInfo)
|
|
318
318
|
}
|
|
319
319
|
async updateMPaasConfig() {}
|
|
320
320
|
|
|
321
321
|
getNetWorkType() {
|
|
322
322
|
Taro.getNetworkType().then(getRes => {
|
|
323
323
|
getRes &&
|
|
324
324
|
getRes.networkType &&
|
|
325
325
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
326
326
|
})
|
|
327
327
|
}
|
|
328
328
|
|
|
329
329
|
checkStatusAndLogin(options = {}) {
|
|
330
330
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
331
331
|
console.log(
|
|
332
332
|
'微信小程序登录状态及获取cookie状态的promise,之前登录状态',
|
|
333
333
|
this.info.loginState,
|
|
334
334
|
)
|
|
335
335
|
this.toLogin(options)
|
|
336
336
|
.then(res => {
|
|
337
337
|
console.log('微信小程序登录状态结果,成功', res)
|
|
338
338
|
this.info.loginState = true
|
|
339
339
|
resolve(res)
|
|
340
340
|
})
|
|
341
341
|
.catch(err => {
|
|
342
342
|
console.log('微信小程序登录异常状态结果', err)
|
|
343
343
|
this.doLogin(options)
|
|
344
344
|
.then(res2 => {
|
|
345
345
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2)
|
|
346
346
|
this.info.loginState = true
|
|
347
347
|
resolve(res2)
|
|
348
348
|
})
|
|
349
349
|
.catch(err2 => {
|
|
350
350
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2)
|
|
351
351
|
this.checkStatusAndLoginPromise = null
|
|
352
352
|
reject(err2)
|
|
353
353
|
})
|
|
354
354
|
})
|
|
355
355
|
})
|
|
356
356
|
return this.checkStatusAndLoginPromise
|
|
357
357
|
}
|
|
358
358
|
|
|
359
359
|
checkJdStatusAndLogin(
|
|
360
360
|
options = {
|
|
361
361
|
loginColor: {
|
|
362
362
|
bzi: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
363
363
|
dpin: 0,
|
|
364
364
|
},
|
|
365
365
|
},
|
|
366
366
|
) {
|
|
367
367
|
return this.checkStatusAndLogin(options)
|
|
368
368
|
}
|
|
369
369
|
|
|
370
370
|
toLogin(options = {}): Promise<any> {
|
|
371
371
|
return this.wxAppLoginInstance
|
|
372
372
|
.getLoginPromise({
|
|
373
373
|
mode: 'silent',
|
|
374
374
|
loginColor: {
|
|
375
375
|
bzi: WXAPP_BIZ_KEY,
|
|
376
376
|
dpin: 1,
|
|
377
377
|
},
|
|
378
378
|
...options,
|
|
379
379
|
})
|
|
380
380
|
.then(res => {
|
|
381
381
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res)
|
|
382
382
|
setTimeout(() => {
|
|
383
383
|
console.log(
|
|
384
384
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
385
385
|
)
|
|
386
386
|
this.getLoginCookie(`${Date.now()}`)
|
|
387
387
|
}, 500)
|
|
388
388
|
})
|
|
389
389
|
.catch(err => {
|
|
390
390
|
console.log('微信app登录异常返回信息,也获取cookie', err)
|
|
391
391
|
this.getLoginCookie(`${Date.now()}`)
|
|
392
392
|
})
|
|
393
393
|
}
|
|
394
394
|
|
|
395
395
|
doLogin(options = {}) {
|
|
396
396
|
const getParams = {
|
|
397
397
|
loginColor: {
|
|
398
398
|
bzi: WXAPP_BIZ_KEY,
|
|
399
399
|
dpin: 1,
|
|
400
400
|
},
|
|
401
401
|
...options,
|
|
402
402
|
}
|
|
403
403
|
if (isPublishToWxapp) {
|
|
404
404
|
getParams[
|
|
405
405
|
'returnUrl'
|
|
406
406
|
] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
407
407
|
...this.info.originQueryInfo,
|
|
408
408
|
loadShopxType: 'redirect',
|
|
409
409
|
})}`
|
|
410
410
|
}
|
|
411
411
|
return this.wxAppLoginInstance.doLogin(getParams).then(res => {
|
|
412
412
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res)
|
|
413
413
|
setTimeout(() => {
|
|
414
414
|
console.log(
|
|
415
415
|
'微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
416
416
|
)
|
|
417
417
|
this.getLoginCookie(`${Date.now()}`)
|
|
418
418
|
}, 500)
|
|
419
419
|
return res
|
|
420
420
|
})
|
|
421
421
|
}
|
|
422
422
|
|
|
423
423
|
doLoginForJdPin(options = {}) {
|
|
424
424
|
return this.doLogin({
|
|
425
425
|
loginColor: {
|
|
426
426
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
427
427
|
dpin: 0,
|
|
428
428
|
},
|
|
429
429
|
...options,
|
|
430
430
|
})
|
|
431
431
|
}
|
|
432
432
|
|
|
433
433
|
getLoginCookie(updateKey = 'wxapp') {
|
|
434
434
|
return new Promise(resolve => {
|
|
435
435
|
console.log('开始获取更新wxapp中的cookie信息', updateKey)
|
|
436
436
|
if (
|
|
437
437
|
this.config.wqCookie &&
|
|
438
438
|
this.config.wqCookieStr &&
|
|
439
439
|
this.config.getWqCookieKey === updateKey
|
|
440
440
|
) {
|
|
441
441
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config)
|
|
442
442
|
resolve({
|
|
443
443
|
wqCookie: this.config.wqCookie,
|
|
444
444
|
wqCookieStr: this.config.wqCookieStr,
|
|
445
445
|
})
|
|
446
446
|
} else {
|
|
447
447
|
if (isPublishToWxapp) {
|
|
448
448
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
449
449
|
if (getWxappCookieObj) {
|
|
450
450
|
const getCookieObj = getWxappCookieObj['_data']
|
|
451
451
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
452
452
|
const {
|
|
453
453
|
pin = '',
|
|
454
454
|
visitkey = '-1',
|
|
455
455
|
wq_unionid = '',
|
|
456
456
|
wxapp_openid = '',
|
|
457
457
|
} = wqCookie
|
|
458
458
|
this.info.loginState = true
|
|
459
459
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
460
460
|
this.info.userInfo.wqVisitkey = visitkey
|
|
461
461
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
462
462
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
463
463
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
464
464
|
if (getUserAddress) {
|
|
465
465
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
466
466
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
|
|
467
467
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
468
468
|
: ''
|
|
469
469
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
470
470
|
Taro.eventCenter.trigger(
|
|
471
471
|
TaroEventType.USER_AREA_UPDATE,
|
|
472
472
|
this.info.pageInfo.address,
|
|
473
473
|
)
|
|
474
474
|
}
|
|
475
475
|
if (this.miniAppLogInstance) {
|
|
476
476
|
this.miniAppLogInstance.set({
|
|
477
477
|
account: pin,
|
|
478
478
|
unionid: wq_unionid,
|
|
479
479
|
openid: wxapp_openid,
|
|
480
480
|
})
|
|
481
481
|
}
|
|
482
482
|
this.config.wqCookie = wqCookie
|
|
483
483
|
this.config.wqCookieStr = wqCookieStr
|
|
484
484
|
this.config.getWqCookieKey = updateKey
|
|
485
485
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config)
|
|
486
486
|
resolve({
|
|
487
487
|
wqCookie,
|
|
488
488
|
wqCookieStr,
|
|
489
489
|
})
|
|
490
490
|
} else {
|
|
491
491
|
console.log(
|
|
492
492
|
'解析wxapp中的cookie信息异常,返回异常结果',
|
|
493
493
|
this.config,
|
|
494
494
|
)
|
|
495
495
|
resolve({
|
|
496
496
|
wqCookie: false,
|
|
497
497
|
wqCookieStr: false,
|
|
498
498
|
})
|
|
499
499
|
}
|
|
500
500
|
} else {
|
|
501
501
|
resolve({
|
|
502
502
|
wqCookie: false,
|
|
503
503
|
wqCookieStr: false,
|
|
504
504
|
})
|
|
505
505
|
}
|
|
506
506
|
}
|
|
507
507
|
})
|
|
508
508
|
}
|
|
509
509
|
|
|
510
510
|
|
|
511
511
|
checkLoginStatus() {
|
|
512
512
|
return this.getLoginCookie()
|
|
513
513
|
}
|
|
514
514
|
|
|
515
515
|
getAddressCachePromise = () => {
|
|
516
516
|
return Promise.reject('该方法只在APP内适用')
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
520
520
|
const createUpdateQueryInfo: {
|
|
521
521
|
query: {
|
|
522
522
|
shopId?: string | number
|
|
523
523
|
venderId?: string | number
|
|
524
524
|
}
|
|
525
525
|
updateShopInfoState: boolean
|
|
526
526
|
} = Object.assign(
|
|
527
527
|
{},
|
|
528
528
|
{
|
|
529
529
|
query: {},
|
|
530
530
|
updateShopInfoState: false,
|
|
531
531
|
},
|
|
532
532
|
updateQuery,
|
|
533
533
|
)
|
|
534
534
|
console.log(
|
|
535
535
|
'获取当前下发的店铺查询参数',
|
|
536
536
|
updateQuery,
|
|
537
537
|
'获取之前保存的shopInfo店铺查询参数',
|
|
538
538
|
this.info?.shopInfo,
|
|
539
539
|
)
|
|
540
540
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
541
541
|
const { shopId, venderId } = query
|
|
542
542
|
if (updateShopInfoState) {
|
|
543
543
|
this.info.queryInfo = {
|
|
544
544
|
...this.info.queryInfo,
|
|
545
545
|
...query,
|
|
546
546
|
}
|
|
547
547
|
if (shopId && venderId) {
|
|
548
548
|
this.info.shopInfo = {
|
|
549
549
|
shopId: `${shopId}`,
|
|
550
550
|
venderId: `${venderId}`,
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
553
|
} else {
|
|
554
554
|
this.info.queryInfo = {
|
|
555
555
|
...query,
|
|
556
556
|
}
|
|
557
557
|
this.info.originQueryInfo = {
|
|
558
558
|
...query,
|
|
559
559
|
}
|
|
560
560
|
if (
|
|
561
561
|
this.info.shopInfo?.shopId &&
|
|
562
562
|
this.info.shopInfo?.venderId &&
|
|
563
563
|
(this.info.shopInfo.shopId == shopId ||
|
|
564
564
|
this.info.shopInfo.venderId == venderId)
|
|
565
565
|
) {
|
|
566
566
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
567
567
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
568
568
|
console.log(
|
|
569
569
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
570
570
|
this.info.queryInfo,
|
|
571
571
|
)
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
574
|
this.info.queryInfo['shopId'] &&
|
|
575
575
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
576
576
|
this.info.queryInfo['venderId'] &&
|
|
577
577
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
578
578
|
console.log(
|
|
579
579
|
'weapp===获取店铺下发查询参数\n',
|
|
580
580
|
query,
|
|
581
581
|
'\n获取店铺最后查询参数\n',
|
|
582
582
|
this.info.queryInfo,
|
|
583
583
|
'\n是否为更新店铺状态\n',
|
|
584
584
|
updateShopInfoState,
|
|
585
585
|
)
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
getDynamicConfig(key: string) {
|
|
589
589
|
console.warn(
|
|
590
590
|
'调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!',
|
|
591
591
|
)
|
|
592
592
|
return null
|
|
593
593
|
}
|