@conecli/cone-render 0.9.1-shop2.9 → 0.10.1-beta.0
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
package/dist/common/index.jd.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
WXAPP_LOGIN,
|
|
3
2
|
WXAPP_BIZ,
|
|
4
3
|
WXAPP_USER_INFO,
|
|
5
4
|
WXAPP_NAVIGATOR,
|
|
6
5
|
WXAPP_REPORT_GDT,
|
|
7
6
|
WXAPP_PARAMS_SIGN,
|
|
8
7
|
WXAPP_FINGER_REPORT,
|
|
9
8
|
WXAPP_REPORT_MANAGE,
|
|
10
9
|
BUSINESS_TYPE,
|
|
11
10
|
SHOP_MENU_ID_TYPE,
|
|
12
11
|
SHOP_MENU_ID_NAME,
|
|
13
12
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
14
13
|
SECTION_HOME_TAB_TYPE,
|
|
15
14
|
TaroEventType,
|
|
16
15
|
WX_BUSINESS_TYPE,
|
|
17
16
|
WXAPP_BIZ_KEY,
|
|
18
17
|
getSystemInfos,
|
|
19
18
|
getTaroStorageKeyValue,
|
|
20
19
|
getWxAppCookieStr,
|
|
21
20
|
objectToUrlEncode,
|
|
22
21
|
floorVideInfo: {},
|
|
23
22
|
productVideInfo: {},
|
|
24
23
|
updateShopInfosAllState: false,
|
|
25
24
|
isJdShowNativeImmersivePlayer: false,
|
|
26
25
|
pageIdxHeightInfo: {
|
|
27
26
|
list: []
|
|
28
27
|
},
|
|
29
28
|
originQueryInfo: {},
|
|
30
29
|
jdBottomBarHeight: 0,
|
|
31
30
|
jdNativeHeaderHeight: 0,
|
|
32
31
|
shopInfo: {},
|
|
33
32
|
openAppData: {}
|
|
34
33
|
public info: CommonInterFace.BaseConfigInfo
|
|
35
34
|
public config: {
|
|
36
35
|
[key: string]: any
|
|
37
36
|
}
|
|
38
37
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
39
38
|
public rootEleNode: HTMLElement | null
|
|
40
39
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil
|
|
41
40
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null
|
|
42
41
|
public checkStatusAndLoginPromise: object | null
|
|
43
42
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin
|
|
44
43
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo
|
|
45
44
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo
|
|
46
45
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage
|
|
47
46
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT
|
|
48
47
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator
|
|
49
48
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign
|
|
50
49
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign
|
|
51
50
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign
|
|
52
51
|
constructor(opt) {
|
|
53
52
|
this.info = this._getConfig(opt)
|
|
54
53
|
this.config = {}
|
|
55
54
|
this.lazyContainer = {
|
|
56
55
|
[SECTION_HOME_TAB_NAME_TYPE[
|
|
57
56
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
58
57
|
]]: {
|
|
59
58
|
appLazyContainerList: [],
|
|
60
59
|
appLazyFinishContainerList: [],
|
|
61
60
|
},
|
|
62
61
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]:
|
|
63
62
|
{
|
|
64
63
|
appLazyContainerList: [],
|
|
65
64
|
appLazyFinishContainerList: [],
|
|
66
65
|
},
|
|
67
66
|
}
|
|
68
67
|
this.rootEleNode = null
|
|
69
68
|
this.miniApplogUtil = MiniAppLogUtil
|
|
70
69
|
this.miniAppLogInstance = null
|
|
71
70
|
this.checkStatusAndLoginPromise = null
|
|
72
71
|
this.wxAppLoginInstance = WXAPP_LOGIN
|
|
73
72
|
this.wxAppBizInstance = WXAPP_BIZ
|
|
74
73
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO
|
|
75
74
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE
|
|
76
75
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT
|
|
77
76
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR
|
|
78
77
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN
|
|
79
78
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {}
|
|
80
79
|
this.wxAppSubsGuider = null
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
taskTimeoutPromise(callBack, timeout = 2000){
|
|
84
83
|
return new Promise((resolve) => {
|
|
85
84
|
setTimeout(() => {
|
|
86
85
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
87
86
|
return resolve(getCallBackRes || false)
|
|
88
87
|
}, timeout)
|
|
89
88
|
})
|
|
90
89
|
}
|
|
91
90
|
|
|
92
91
|
getTabBarHeight(systemInfo) {
|
|
93
92
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo
|
|
94
93
|
let result = 50
|
|
95
94
|
if (statusBarHeight > 20) {
|
|
96
95
|
if (isIOS) {
|
|
97
96
|
result = 84
|
|
98
97
|
} else if (isAndroid) {
|
|
99
98
|
result = 53
|
|
100
99
|
}
|
|
101
100
|
}
|
|
102
101
|
return result
|
|
103
102
|
}
|
|
104
103
|
|
|
105
104
|
getSystemInfo() {
|
|
106
105
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes =
|
|
107
106
|
getSystemInfos() || {}
|
|
108
107
|
const actualNavBarHeight =
|
|
109
108
|
(info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0)
|
|
110
109
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0)
|
|
111
110
|
const fullScreenHeight = this.getFullScreenHeight(info)
|
|
112
111
|
const tabBarHeight = this.getTabBarHeight(info)
|
|
113
112
|
const safeContentHeight = fullScreenHeight - headerHeight
|
|
114
113
|
this.info.sysInfo = {
|
|
115
114
|
...this.info.sysInfo,
|
|
116
115
|
...info,
|
|
117
116
|
actualNavBarHeight,
|
|
118
117
|
headerHeight,
|
|
119
118
|
fullScreenHeight,
|
|
120
119
|
tabBarHeight,
|
|
121
120
|
safeContentHeight,
|
|
122
121
|
}
|
|
123
122
|
if (this.info.sysInfo['hostVersionName']) {
|
|
124
123
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
125
124
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
126
125
|
)
|
|
127
126
|
}
|
|
128
127
|
console.log('获取系统信息', this.info.sysInfo)
|
|
129
128
|
this.getNetWorkType()
|
|
130
129
|
}
|
|
131
130
|
|
|
132
131
|
getNetWorkType() {
|
|
133
132
|
Taro.getNetworkType().then((getRes) => {
|
|
134
133
|
getRes &&
|
|
135
134
|
getRes.networkType &&
|
|
136
135
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
137
136
|
})
|
|
138
137
|
}
|
|
139
138
|
|
|
140
139
|
checkStatusAndLogin(options = {}) {
|
|
141
140
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
142
141
|
console.log(
|
|
143
142
|
'微信小程序登录状态及获取cookie状态的promise,之前登录状态',
|
|
144
143
|
this.info.loginState,
|
|
145
144
|
)
|
|
146
145
|
this.toLogin(options)
|
|
147
146
|
.then((res) => {
|
|
148
147
|
console.log('微信小程序登录状态结果,成功', res)
|
|
149
148
|
this.info.loginState = true
|
|
150
149
|
resolve(res)
|
|
151
150
|
})
|
|
152
151
|
.catch((err) => {
|
|
153
152
|
console.log('微信小程序登录异常状态结果', err)
|
|
154
153
|
this.doLogin(options)
|
|
155
154
|
.then((res2) => {
|
|
156
155
|
console.log(
|
|
157
156
|
'微信小程序wxDoLogin强制登陆成功:',
|
|
158
157
|
res2,
|
|
159
158
|
)
|
|
160
159
|
this.info.loginState = true
|
|
161
160
|
resolve(res2)
|
|
162
161
|
})
|
|
163
162
|
.catch((err2) => {
|
|
164
163
|
console.log(
|
|
165
164
|
'微信小程序wxDoLogin强制登陆失败:',
|
|
166
165
|
err2,
|
|
167
166
|
)
|
|
168
167
|
this.checkStatusAndLoginPromise = null
|
|
169
168
|
reject(err2)
|
|
170
169
|
})
|
|
171
170
|
})
|
|
172
171
|
})
|
|
173
172
|
return this.checkStatusAndLoginPromise
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
checkJdStatusAndLogin(options){
|
|
177
176
|
return this.checkStatusAndLogin(options)
|
|
178
177
|
}
|
|
179
178
|
|
|
180
179
|
doLoginForJdPin(options = {}) {
|
|
181
180
|
return this.doLogin(options)
|
|
182
181
|
}
|
|
183
182
|
|
|
184
183
|
toLogin(options = {}): Promise<any> {
|
|
185
184
|
return this.wxAppLoginInstance
|
|
186
185
|
.getLoginPromise({
|
|
187
186
|
mode: 'silent',
|
|
188
187
|
loginColor: {
|
|
189
188
|
biz: WXAPP_BIZ_KEY,
|
|
190
189
|
dpin: 0,
|
|
191
190
|
},
|
|
192
191
|
...options,
|
|
193
192
|
})
|
|
194
193
|
.then((res) => {
|
|
195
194
|
console.log(
|
|
196
195
|
'微信app登录返回信息,微信侧返回code为0表示成功',
|
|
197
196
|
res,
|
|
198
197
|
)
|
|
199
198
|
setTimeout(() => {
|
|
200
199
|
console.log("微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie")
|
|
201
200
|
this.getLoginCookie(`${Date.now()}`)
|
|
202
201
|
},500)
|
|
203
202
|
})
|
|
204
203
|
.catch((err) => {
|
|
205
204
|
console.log('微信app登录异常返回信息,也获取cookie', err)
|
|
206
205
|
this.getLoginCookie(`${Date.now()}`)
|
|
207
206
|
})
|
|
208
207
|
}
|
|
209
208
|
|
|
210
209
|
doLogin(options) {
|
|
211
210
|
console.log('触发松果小程序 doLogin() new new')
|
|
212
211
|
return new Promise((resolve, reject) => {
|
|
213
212
|
jd.login({
|
|
214
213
|
success: (res) => {
|
|
215
214
|
if (res.code) {
|
|
216
215
|
console.log("[common]松果小程序登录成功", res.code)
|
|
217
216
|
jd.redirectTo({
|
|
218
217
|
url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
219
218
|
...this.info.originQueryInfo
|
|
220
219
|
})}`
|
|
221
220
|
})
|
|
222
221
|
resolve(res)
|
|
223
222
|
} else {
|
|
224
223
|
console.error("[common]松果小程序登录失败", res.errMsg)
|
|
225
224
|
reject()
|
|
226
225
|
}
|
|
227
226
|
},
|
|
228
227
|
fail: (res) => {
|
|
229
228
|
console.error("[common]松果小程序登录失败", res.errMsg)
|
|
230
229
|
reject()
|
|
231
230
|
}
|
|
232
231
|
})
|
|
233
232
|
})
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
getLoginCookie(updateKey = 'wxapp') {
|
|
237
236
|
return new Promise((resolve) => {
|
|
238
237
|
console.log("开始获取更新wxapp中的cookie信息", updateKey)
|
|
239
238
|
if(this.config.wqCookie && this.config.wqCookieStr && this.config.getWqCookieKey === updateKey){
|
|
240
239
|
console.log("已有存储wxapp中的cookie信息,直接返回",this.config)
|
|
241
240
|
resolve({
|
|
242
241
|
wqCookie: this.config.wqCookie,
|
|
243
242
|
wqCookieStr: this.config.wqCookieStr,
|
|
244
243
|
})
|
|
245
244
|
}else {
|
|
246
245
|
if (isPublishToWxapp) {
|
|
247
246
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
248
247
|
if (getWxappCookieObj) {
|
|
249
248
|
const getCookieObj = getWxappCookieObj['_data']
|
|
250
249
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
251
250
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie
|
|
252
251
|
this.info.loginState = true
|
|
253
252
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
254
253
|
this.info.userInfo.wqVisitkey = visitkey
|
|
255
254
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
256
255
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
257
256
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
258
257
|
if (getUserAddress) {
|
|
259
258
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
260
259
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo
|
|
261
260
|
.address
|
|
262
261
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
263
262
|
: ''
|
|
264
263
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
265
264
|
Taro.eventCenter.trigger(
|
|
266
265
|
TaroEventType.USER_AREA_UPDATE,
|
|
267
266
|
this.info.pageInfo.address,
|
|
268
267
|
)
|
|
269
268
|
}
|
|
270
269
|
if(this.miniAppLogInstance){
|
|
271
270
|
this.miniAppLogInstance.set({
|
|
272
271
|
account: pin,
|
|
273
272
|
unionid: wq_unionid,
|
|
274
273
|
openid: wxapp_openid,
|
|
275
274
|
})
|
|
276
275
|
}
|
|
277
276
|
this.config.wqCookie = wqCookie
|
|
278
277
|
this.config.wqCookieStr = wqCookieStr
|
|
279
278
|
this.config.getWqCookieKey = updateKey
|
|
280
279
|
console.log("解析wxapp中的cookie信息成功,返回后存储",this.config)
|
|
281
280
|
resolve({
|
|
282
281
|
wqCookie,
|
|
283
282
|
wqCookieStr,
|
|
284
283
|
})
|
|
285
284
|
}else {
|
|
286
285
|
console.log("解析wxapp中的cookie信息异常,返回异常结果",this.config)
|
|
287
286
|
resolve({
|
|
288
287
|
wqCookie: false,
|
|
289
288
|
wqCookieStr: false,
|
|
290
289
|
})
|
|
291
290
|
}
|
|
292
291
|
}else {
|
|
293
292
|
resolve({
|
|
294
293
|
wqCookie: false,
|
|
295
294
|
wqCookieStr: false,
|
|
296
295
|
})
|
|
297
296
|
}
|
|
298
297
|
}
|
|
299
298
|
})
|
|
300
299
|
}
|
|
301
300
|
|
|
302
301
|
|
|
303
302
|
checkLoginStatus() {
|
|
304
303
|
return this.getLoginCookie()
|
|
305
304
|
}
|
|
306
305
|
|
|
307
306
|
getAddressCachePromise = () => {
|
|
308
307
|
return Promise.reject("该方法只在APP内适用")
|
|
309
308
|
}
|
|
310
309
|
|
|
311
310
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
312
311
|
const createUpdateQueryInfo: {
|
|
313
312
|
query: {
|
|
314
313
|
shopId?: string | number
|
|
315
314
|
venderId?: string | number
|
|
316
315
|
},
|
|
317
316
|
updateShopInfoState: boolean,
|
|
318
317
|
} = Object.assign({}, {
|
|
319
318
|
query: {},
|
|
320
319
|
updateShopInfoState: false
|
|
321
320
|
}, updateQuery)
|
|
322
321
|
console.log("获取当前下发的店铺查询参数",updateQuery, '获取之前保存的shopInfo店铺查询参数', this.info?.shopInfo)
|
|
323
322
|
const {query, updateShopInfoState} = createUpdateQueryInfo
|
|
324
323
|
const {shopId, venderId} = query
|
|
325
324
|
if (updateShopInfoState) {
|
|
326
325
|
this.info.queryInfo = {
|
|
327
326
|
...this.info.queryInfo,
|
|
328
327
|
...query,
|
|
329
328
|
}
|
|
330
329
|
if(shopId && venderId){
|
|
331
330
|
this.info.shopInfo = {
|
|
332
331
|
shopId: `${shopId}`,
|
|
333
332
|
venderId: `${venderId}`
|
|
334
333
|
}
|
|
335
334
|
}
|
|
336
335
|
} else {
|
|
337
336
|
this.info.queryInfo = {
|
|
338
337
|
...query
|
|
339
338
|
}
|
|
340
339
|
this.info.originQueryInfo = {
|
|
341
340
|
...query
|
|
342
341
|
}
|
|
343
342
|
if(this.info.shopInfo?.shopId && this.info.shopInfo?.venderId && (this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)){
|
|
344
343
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
345
344
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
346
345
|
console.log("当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数", this.info.queryInfo)
|
|
347
346
|
}
|
|
348
347
|
}
|
|
349
348
|
this.info.queryInfo['shopId'] &&
|
|
350
349
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
351
350
|
this.info.queryInfo['venderId'] &&
|
|
352
351
|
(this.info.queryInfo[
|
|
353
352
|
'venderId'
|
|
354
353
|
] = `${this.info.queryInfo['venderId']}`)
|
|
355
354
|
console.log(
|
|
356
355
|
'weapp===获取店铺下发查询参数\n',
|
|
357
356
|
query,
|
|
358
357
|
'\n获取店铺最后查询参数\n',
|
|
359
358
|
this.info.queryInfo,
|
|
360
359
|
'\n是否为更新店铺状态\n',
|
|
361
360
|
updateShopInfoState
|
|
362
361
|
)
|
|
363
362
|
}
|
|
363
|
+
import Taro from '@tarojs/taro'
|
|
364
364
|
appEid,
|
|
365
365
|
userPinKey,
|
|
366
366
|
jdUserLoginState,
|
|
367
367
|
WXAPP_LOGIN,
|
|
368
368
|
WXAPP_BIZ,
|
|
369
369
|
WXAPP_USER_INFO,
|
|
370
370
|
WXAPP_NAVIGATOR,
|
|
371
371
|
WXAPP_REPORT_GDT,
|
|
372
372
|
WXAPP_PARAMS_SIGN,
|
|
373
373
|
WXAPP_FINGER_REPORT,
|
|
374
374
|
WXAPP_REPORT_MANAGE,
|
|
375
375
|
BUSINESS_TYPE,
|
|
376
376
|
SHOP_MENU_ID_TYPE,
|
|
377
377
|
SHOP_MENU_ID_NAME,
|
|
378
378
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
379
379
|
SECTION_HOME_TAB_TYPE,
|
|
380
380
|
TaroEventType,
|
|
381
381
|
WX_BUSINESS_TYPE,
|
|
382
382
|
WXAPP_BIZ_KEY,
|
|
383
383
|
getSystemInfos,
|
|
384
384
|
getTaroStorageKeyValue,
|
|
385
385
|
removeTaroStorageKey,
|
|
386
386
|
setTaroStorage,
|
|
387
387
|
getWxAppCookieStr,
|
|
388
388
|
objectToUrlEncode,
|
|
389
389
|
loginState: jdUserLoginState,
|
|
390
390
|
cookiesStr: '',
|
|
391
391
|
userInfo: userPinKey,
|
|
392
392
|
pageInfo: {
|
|
393
393
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
394
394
|
address: '',
|
|
395
395
|
addressCommaStr: '',
|
|
396
396
|
un_area: '',
|
|
397
397
|
vapptype: '1',
|
|
398
398
|
pageType: 'home',
|
|
399
399
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
400
400
|
floorExposureInfo: {},
|
|
401
401
|
floorVideInfo: {},
|
|
402
402
|
productVideInfo: {},
|
|
403
403
|
tabsLoadAllDataInfo: {
|
|
404
404
|
[SECTION_HOME_TAB_NAME_TYPE[
|
|
405
405
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
406
406
|
]]: false,
|
|
407
407
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
408
408
|
},
|
|
409
409
|
updateShopInfosAllState: false,
|
|
410
410
|
isVipShop: false,
|
|
411
411
|
isJdShowNativeImmersivePlayer: false,
|
|
412
412
|
...shopConfig,
|
|
413
413
|
pageScrollTop: 0,
|
|
414
414
|
pageIdxHeightInfo: {
|
|
415
415
|
list: [],
|
|
416
416
|
},
|
|
417
417
|
shopNavBarHeight: 0,
|
|
418
418
|
},
|
|
419
419
|
defaultQueryLogInfo: {
|
|
420
420
|
sourceType: 'JDshop',
|
|
421
421
|
sourceValue: '',
|
|
422
422
|
moduleId: 'none',
|
|
423
423
|
entrance: 'none',
|
|
424
424
|
},
|
|
425
425
|
originQueryInfo: {},
|
|
426
426
|
sysInfo: {
|
|
427
427
|
windowWidth: 0,
|
|
428
428
|
windowHeight: 0,
|
|
429
429
|
eid: appEid,
|
|
430
430
|
netWorkType: '4g',
|
|
431
431
|
jdBottomBarHeight: 0,
|
|
432
432
|
jdNativeHeaderHeight: 0,
|
|
433
433
|
},
|
|
434
434
|
queryInfo: {},
|
|
435
435
|
shopInfo: {},
|
|
436
436
|
openAppData: {},
|
|
437
437
|
public info: CommonInterFace.BaseConfigInfo
|
|
438
438
|
public config: {
|
|
439
439
|
[key: string]: any
|
|
440
440
|
}
|
|
441
441
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
442
442
|
public rootEleNode: HTMLElement | null
|
|
443
443
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil
|
|
444
444
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null
|
|
445
445
|
public checkStatusAndLoginPromise: object | null
|
|
446
446
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin
|
|
447
447
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo
|
|
448
448
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo
|
|
449
449
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage
|
|
450
450
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT
|
|
451
451
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator
|
|
452
452
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign
|
|
453
453
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign
|
|
454
454
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign
|
|
455
455
|
constructor(opt) {
|
|
456
456
|
this.info = this._getConfig(opt)
|
|
457
457
|
this.config = {}
|
|
458
458
|
this.lazyContainer = {
|
|
459
459
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
460
460
|
appLazyContainerList: [],
|
|
461
461
|
appLazyFinishContainerList: [],
|
|
462
462
|
},
|
|
463
463
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
464
464
|
appLazyContainerList: [],
|
|
465
465
|
appLazyFinishContainerList: [],
|
|
466
466
|
},
|
|
467
467
|
}
|
|
468
468
|
this.rootEleNode = null
|
|
469
469
|
this.miniApplogUtil = MiniAppLogUtil
|
|
470
470
|
this.miniAppLogInstance = null
|
|
471
471
|
this.checkStatusAndLoginPromise = null
|
|
472
472
|
this.wxAppLoginInstance = WXAPP_LOGIN
|
|
473
473
|
this.wxAppBizInstance = WXAPP_BIZ
|
|
474
474
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO
|
|
475
475
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE
|
|
476
476
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT
|
|
477
477
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR
|
|
478
478
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN
|
|
479
479
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
|
|
480
480
|
? new WXAPP_FINGER_REPORT()
|
|
481
481
|
: {}
|
|
482
482
|
this.wxAppSubsGuider = null
|
|
483
483
|
}
|
|
484
484
|
_getConfig(opt) {
|
|
485
485
|
return Object.assign({}, DefaultConfig, opt)
|
|
486
486
|
}
|
|
487
487
|
|
|
488
488
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
489
489
|
return new Promise(resolve => {
|
|
490
490
|
setTimeout(() => {
|
|
491
491
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
492
492
|
return resolve(getCallBackRes || false)
|
|
493
493
|
}, timeout)
|
|
494
494
|
})
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
updateBusinessDomainAndApi(domain, api) {
|
|
498
498
|
}
|
|
499
499
|
|
|
500
500
|
getFullScreenHeight(systemInfo) {
|
|
501
501
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo
|
|
502
502
|
let result = screenHeight
|
|
503
503
|
if (statusBarHeight > 20 && isAndroid) {
|
|
504
504
|
result = screenHeight + statusBarHeight
|
|
505
505
|
}
|
|
506
506
|
return result
|
|
507
507
|
}
|
|
508
508
|
|
|
509
509
|
getTabBarHeight(systemInfo) {
|
|
510
510
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo
|
|
511
511
|
let result = 50
|
|
512
512
|
if (statusBarHeight > 20) {
|
|
513
513
|
if (isIOS) {
|
|
514
514
|
result = 84
|
|
515
515
|
} else if (isAndroid) {
|
|
516
516
|
result = 53
|
|
517
517
|
}
|
|
518
518
|
}
|
|
519
519
|
return result
|
|
520
520
|
}
|
|
521
521
|
|
|
522
522
|
getSystemInfo() {
|
|
523
523
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {}
|
|
524
524
|
const actualNavBarHeight =
|
|
525
525
|
(info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0)
|
|
526
526
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0)
|
|
527
527
|
const fullScreenHeight = this.getFullScreenHeight(info)
|
|
528
528
|
const tabBarHeight = this.getTabBarHeight(info)
|
|
529
529
|
const safeContentHeight = fullScreenHeight - headerHeight
|
|
530
530
|
this.info.sysInfo = {
|
|
531
531
|
...this.info.sysInfo,
|
|
532
532
|
...info,
|
|
533
533
|
actualNavBarHeight,
|
|
534
534
|
headerHeight,
|
|
535
535
|
fullScreenHeight,
|
|
536
536
|
tabBarHeight,
|
|
537
537
|
safeContentHeight,
|
|
538
538
|
}
|
|
539
539
|
this.getEid().then((res: { eid: string }) => {
|
|
540
540
|
res && res.eid && (this.info.sysInfo['eid'] = res.eid)
|
|
541
541
|
})
|
|
542
542
|
if (this.info.sysInfo['hostVersionName']) {
|
|
543
543
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
544
544
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
545
545
|
)
|
|
546
546
|
}
|
|
547
547
|
this.info.sysInfo['wifiVideoAutoPlay'] = false
|
|
548
548
|
this.getNetWorkType()
|
|
549
549
|
}
|
|
550
550
|
async updateMPaasConfig() {}
|
|
551
551
|
|
|
552
552
|
getNetWorkType() {
|
|
553
553
|
Taro.getNetworkType().then(getRes => {
|
|
554
554
|
getRes &&
|
|
555
555
|
getRes.networkType &&
|
|
556
556
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
557
557
|
})
|
|
558
558
|
}
|
|
559
559
|
|
|
560
560
|
checkStatusAndLogin(options = {}) {
|
|
561
561
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
562
562
|
console.log(
|
|
563
563
|
'微信小程序登录状态及获取cookie状态的promise,之前登录状态',
|
|
564
564
|
this.info.loginState,
|
|
565
565
|
)
|
|
566
566
|
this.toLogin(options)
|
|
567
567
|
.then(res => {
|
|
568
568
|
console.log('微信小程序登录状态结果,成功', res)
|
|
569
569
|
this.info.loginState = true
|
|
570
570
|
resolve(res)
|
|
571
571
|
})
|
|
572
572
|
.catch(err => {
|
|
573
573
|
console.log('微信小程序登录异常状态结果', err)
|
|
574
574
|
this.doLogin(options)
|
|
575
575
|
.then(res2 => {
|
|
576
576
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2)
|
|
577
577
|
this.info.loginState = true
|
|
578
578
|
resolve(res2)
|
|
579
579
|
})
|
|
580
580
|
.catch(err2 => {
|
|
581
581
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2)
|
|
582
582
|
this.checkStatusAndLoginPromise = null
|
|
583
583
|
reject(err2)
|
|
584
584
|
})
|
|
585
585
|
})
|
|
586
586
|
})
|
|
587
587
|
return this.checkStatusAndLoginPromise
|
|
588
588
|
}
|
|
589
589
|
|
|
590
590
|
checkJdStatusAndLogin(options) {
|
|
591
591
|
return this.checkStatusAndLogin(options)
|
|
592
592
|
}
|
|
593
593
|
|
|
594
594
|
|
|
595
595
|
doLoginForJdPin(options = {}) {
|
|
596
596
|
return this.doLogin(options)
|
|
597
597
|
}
|
|
598
598
|
|
|
599
599
|
getEid() {
|
|
600
600
|
if (typeof jd !== 'undefined' && jd.getEid) {
|
|
601
601
|
return new Promise((resolve, reject) => {
|
|
602
602
|
jd.getEid({
|
|
603
603
|
success: (res: { eid: string }) => {
|
|
604
604
|
resolve(res)
|
|
605
605
|
},
|
|
606
606
|
fail: (err: any) => {
|
|
607
607
|
reject(err)
|
|
608
608
|
},
|
|
609
609
|
})
|
|
610
610
|
})
|
|
611
611
|
} else {
|
|
612
612
|
return Promise.resolve(false)
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
615
|
|
|
616
616
|
toLogin(options = {}): Promise<any> {
|
|
617
617
|
return this.wxAppLoginInstance
|
|
618
618
|
.getLoginPromise({
|
|
619
619
|
mode: 'silent',
|
|
620
620
|
loginColor: {
|
|
621
621
|
biz: WXAPP_BIZ_KEY,
|
|
622
622
|
dpin: 0,
|
|
623
623
|
},
|
|
624
624
|
...options,
|
|
625
625
|
})
|
|
626
626
|
.then(res => {
|
|
627
627
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res)
|
|
628
628
|
setTimeout(() => {
|
|
629
629
|
console.log(
|
|
630
630
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
631
631
|
)
|
|
632
632
|
this.getLoginCookie(`${Date.now()}`)
|
|
633
633
|
}, 500)
|
|
634
634
|
})
|
|
635
635
|
.catch(err => {
|
|
636
636
|
console.log('微信app登录异常返回信息,也获取cookie', err)
|
|
637
637
|
this.getLoginCookie(`${Date.now()}`)
|
|
638
638
|
})
|
|
639
639
|
}
|
|
640
640
|
|
|
641
641
|
doLogin(options) {
|
|
642
642
|
console.log('触发松果小程序 doLogin() new new')
|
|
643
643
|
return new Promise((resolve, reject) => {
|
|
644
644
|
jd.login({
|
|
645
645
|
success: res => {
|
|
646
646
|
if (res.code) {
|
|
647
647
|
console.log('[common]松果小程序登录成功', res.code)
|
|
648
648
|
jd.redirectTo({
|
|
649
649
|
url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
650
650
|
...this.info.originQueryInfo,
|
|
651
651
|
})}`,
|
|
652
652
|
})
|
|
653
653
|
resolve(res)
|
|
654
654
|
} else {
|
|
655
655
|
console.error('[common]松果小程序登录失败', res.errMsg)
|
|
656
656
|
reject()
|
|
657
657
|
}
|
|
658
658
|
},
|
|
659
659
|
fail: res => {
|
|
660
660
|
console.error('[common]松果小程序登录失败', res.errMsg)
|
|
661
661
|
reject()
|
|
662
662
|
},
|
|
663
663
|
})
|
|
664
664
|
})
|
|
665
665
|
}
|
|
666
666
|
|
|
667
667
|
getLoginCookie(updateKey = 'wxapp') {
|
|
668
668
|
return new Promise(resolve => {
|
|
669
669
|
console.log('开始获取更新wxapp中的cookie信息', updateKey)
|
|
670
670
|
if (
|
|
671
671
|
this.config.wqCookie &&
|
|
672
672
|
this.config.wqCookieStr &&
|
|
673
673
|
this.config.getWqCookieKey === updateKey
|
|
674
674
|
) {
|
|
675
675
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config)
|
|
676
676
|
resolve({
|
|
677
677
|
wqCookie: this.config.wqCookie,
|
|
678
678
|
wqCookieStr: this.config.wqCookieStr,
|
|
679
679
|
})
|
|
680
680
|
} else {
|
|
681
681
|
if (isPublishToWxapp) {
|
|
682
682
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
683
683
|
if (getWxappCookieObj) {
|
|
684
684
|
const getCookieObj = getWxappCookieObj['_data']
|
|
685
685
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
686
686
|
const {
|
|
687
687
|
pin = '',
|
|
688
688
|
visitkey = '-1',
|
|
689
689
|
wq_unionid = '',
|
|
690
690
|
wxapp_openid = '',
|
|
691
691
|
} = wqCookie
|
|
692
692
|
this.info.loginState = true
|
|
693
693
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
694
694
|
this.info.userInfo.wqVisitkey = visitkey
|
|
695
695
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
696
696
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
697
697
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
698
698
|
if (getUserAddress) {
|
|
699
699
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
700
700
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
|
|
701
701
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
702
702
|
: ''
|
|
703
703
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
704
704
|
Taro.eventCenter.trigger(
|
|
705
705
|
TaroEventType.USER_AREA_UPDATE,
|
|
706
706
|
this.info.pageInfo.address,
|
|
707
707
|
)
|
|
708
708
|
}
|
|
709
709
|
if (this.miniAppLogInstance) {
|
|
710
710
|
this.miniAppLogInstance.set({
|
|
711
711
|
account: pin,
|
|
712
712
|
unionid: wq_unionid,
|
|
713
713
|
openid: wxapp_openid,
|
|
714
714
|
})
|
|
715
715
|
}
|
|
716
716
|
this.config.wqCookie = wqCookie
|
|
717
717
|
this.config.wqCookieStr = wqCookieStr
|
|
718
718
|
this.config.getWqCookieKey = updateKey
|
|
719
719
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config)
|
|
720
720
|
resolve({
|
|
721
721
|
wqCookie,
|
|
722
722
|
wqCookieStr,
|
|
723
723
|
})
|
|
724
724
|
} else {
|
|
725
725
|
console.log(
|
|
726
726
|
'解析wxapp中的cookie信息异常,返回异常结果',
|
|
727
727
|
this.config,
|
|
728
728
|
)
|
|
729
729
|
resolve({
|
|
730
730
|
wqCookie: false,
|
|
731
731
|
wqCookieStr: false,
|
|
732
732
|
})
|
|
733
733
|
}
|
|
734
734
|
} else {
|
|
735
735
|
resolve({
|
|
736
736
|
wqCookie: false,
|
|
737
737
|
wqCookieStr: false,
|
|
738
738
|
})
|
|
739
739
|
}
|
|
740
740
|
}
|
|
741
741
|
})
|
|
742
742
|
}
|
|
743
743
|
|
|
744
744
|
|
|
745
745
|
checkLoginStatus() {
|
|
746
746
|
return this.getLoginCookie()
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
getAddressCachePromise = () => {
|
|
750
750
|
return Promise.reject('该方法只在APP内适用')
|
|
751
751
|
}
|
|
752
752
|
|
|
753
753
|
getDynamicConfig(key: string) {
|
|
754
754
|
console.warn(
|
|
755
755
|
'调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!',
|
|
756
756
|
)
|
|
757
757
|
return null
|
|
758
758
|
}
|
|
759
759
|
|
|
760
760
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
761
761
|
const createUpdateQueryInfo: {
|
|
762
762
|
query: {
|
|
763
763
|
shopId?: string | number
|
|
764
764
|
venderId?: string | number
|
|
765
765
|
}
|
|
766
766
|
updateShopInfoState: boolean
|
|
767
767
|
} = Object.assign(
|
|
768
768
|
{},
|
|
769
769
|
{
|
|
770
770
|
query: {},
|
|
771
771
|
updateShopInfoState: false,
|
|
772
772
|
},
|
|
773
773
|
updateQuery,
|
|
774
774
|
)
|
|
775
775
|
console.log(
|
|
776
776
|
'获取当前下发的店铺查询参数',
|
|
777
777
|
updateQuery,
|
|
778
778
|
'获取之前保存的shopInfo店铺查询参数',
|
|
779
779
|
this.info?.shopInfo,
|
|
780
780
|
)
|
|
781
781
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
782
782
|
const { shopId, venderId } = query
|
|
783
783
|
if (updateShopInfoState) {
|
|
784
784
|
this.info.queryInfo = {
|
|
785
785
|
...this.info.queryInfo,
|
|
786
786
|
...query,
|
|
787
787
|
}
|
|
788
788
|
if (shopId && venderId) {
|
|
789
789
|
this.info.shopInfo = {
|
|
790
790
|
shopId: `${shopId}`,
|
|
791
791
|
venderId: `${venderId}`,
|
|
792
792
|
}
|
|
793
793
|
}
|
|
794
794
|
} else {
|
|
795
795
|
this.info.queryInfo = {
|
|
796
796
|
...query,
|
|
797
797
|
}
|
|
798
798
|
this.info.originQueryInfo = {
|
|
799
799
|
...query,
|
|
800
800
|
}
|
|
801
801
|
if (
|
|
802
802
|
this.info.shopInfo?.shopId &&
|
|
803
803
|
this.info.shopInfo?.venderId &&
|
|
804
804
|
(this.info.shopInfo.shopId == shopId ||
|
|
805
805
|
this.info.shopInfo.venderId == venderId)
|
|
806
806
|
) {
|
|
807
807
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
808
808
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
809
809
|
console.log(
|
|
810
810
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
811
811
|
this.info.queryInfo,
|
|
812
812
|
)
|
|
813
813
|
}
|
|
814
814
|
}
|
|
815
815
|
this.info.queryInfo['shopId'] &&
|
|
816
816
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
817
817
|
this.info.queryInfo['venderId'] &&
|
|
818
818
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
819
819
|
console.log(
|
|
820
820
|
'weapp===获取店铺下发查询参数\n',
|
|
821
821
|
query,
|
|
822
822
|
'\n获取店铺最后查询参数\n',
|
|
823
823
|
this.info.queryInfo,
|
|
824
824
|
'\n是否为更新店铺状态\n',
|
|
825
825
|
updateShopInfoState,
|
|
826
826
|
)
|
|
827
827
|
}
|