@conecli/cone-render 0.9.1-shop2.10 → 0.9.1-shop2.12
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/jdplayerSdk.ts +1 -0
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/ExposureSmart/index.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.module.scss +8 -0
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- 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/interface/jumpEventReport.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.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 +1 -1
- 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
|
getWxAppCookieStr,
|
|
386
386
|
objectToUrlEncode,
|
|
387
387
|
loginState: jdUserLoginState,
|
|
388
388
|
cookiesStr: "",
|
|
389
389
|
userInfo: userPinKey,
|
|
390
390
|
pageInfo: {
|
|
391
391
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
392
392
|
address: "",
|
|
393
393
|
addressCommaStr: "",
|
|
394
394
|
un_area: "",
|
|
395
395
|
vapptype: "1",
|
|
396
396
|
pageType: "home",
|
|
397
397
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
398
398
|
floorExposureInfo: {},
|
|
399
399
|
floorVideInfo: {},
|
|
400
400
|
productVideInfo: {},
|
|
401
401
|
tabsLoadAllDataInfo: {
|
|
402
402
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]:
|
|
403
403
|
false,
|
|
404
404
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
405
405
|
},
|
|
406
406
|
updateShopInfosAllState: false,
|
|
407
407
|
isVipShop: false,
|
|
408
408
|
isJdShowNativeImmersivePlayer: false,
|
|
409
409
|
...shopConfig,
|
|
410
410
|
pageScrollTop: 0,
|
|
411
411
|
pageIdxHeightInfo: {
|
|
412
412
|
list: [],
|
|
413
413
|
},
|
|
414
414
|
shopNavBarHeight: 0,
|
|
415
415
|
},
|
|
416
416
|
defaultQueryLogInfo: {
|
|
417
417
|
sourceType: "JDshop",
|
|
418
418
|
sourceValue: "",
|
|
419
419
|
moduleId: "none",
|
|
420
420
|
entrance: "none",
|
|
421
421
|
},
|
|
422
422
|
originQueryInfo: {},
|
|
423
423
|
sysInfo: {
|
|
424
424
|
windowWidth: 0,
|
|
425
425
|
windowHeight: 0,
|
|
426
426
|
eid: appEid,
|
|
427
427
|
netWorkType: "4g",
|
|
428
428
|
jdBottomBarHeight: 0,
|
|
429
429
|
jdNativeHeaderHeight: 0,
|
|
430
430
|
},
|
|
431
431
|
queryInfo: {},
|
|
432
432
|
shopInfo: {},
|
|
433
433
|
openAppData: {},
|
|
434
434
|
public info: CommonInterFace.BaseConfigInfo;
|
|
435
435
|
public config: {
|
|
436
436
|
[key: string]: any;
|
|
437
437
|
};
|
|
438
438
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
439
439
|
public rootEleNode: HTMLElement | null;
|
|
440
440
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil;
|
|
441
441
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
|
|
442
442
|
public checkStatusAndLoginPromise: object | null;
|
|
443
443
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin;
|
|
444
444
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
|
|
445
445
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
|
|
446
446
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
|
|
447
447
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
|
|
448
448
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
|
|
449
449
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
|
|
450
450
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
|
|
451
451
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
|
|
452
452
|
constructor(opt) {
|
|
453
453
|
this.info = this._getConfig(opt);
|
|
454
454
|
this.config = {};
|
|
455
455
|
this.lazyContainer = {
|
|
456
456
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
457
457
|
appLazyContainerList: [],
|
|
458
458
|
appLazyFinishContainerList: [],
|
|
459
459
|
},
|
|
460
460
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
461
461
|
appLazyContainerList: [],
|
|
462
462
|
appLazyFinishContainerList: [],
|
|
463
463
|
},
|
|
464
464
|
};
|
|
465
465
|
this.rootEleNode = null;
|
|
466
466
|
this.miniApplogUtil = MiniAppLogUtil;
|
|
467
467
|
this.miniAppLogInstance = null;
|
|
468
468
|
this.checkStatusAndLoginPromise = null;
|
|
469
469
|
this.wxAppLoginInstance = WXAPP_LOGIN;
|
|
470
470
|
this.wxAppBizInstance = WXAPP_BIZ;
|
|
471
471
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO;
|
|
472
472
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
|
|
473
473
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
|
|
474
474
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
|
|
475
475
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
|
|
476
476
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
|
|
477
477
|
? new WXAPP_FINGER_REPORT()
|
|
478
478
|
: {};
|
|
479
479
|
this.wxAppSubsGuider = null;
|
|
480
480
|
}
|
|
481
481
|
_getConfig(opt) {
|
|
482
482
|
return Object.assign({}, DefaultConfig, opt);
|
|
483
483
|
}
|
|
484
484
|
|
|
485
485
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
486
486
|
return new Promise((resolve) => {
|
|
487
487
|
setTimeout(() => {
|
|
488
488
|
const getCallBackRes = typeof callBack === "function" && callBack();
|
|
489
489
|
return resolve(getCallBackRes || false);
|
|
490
490
|
}, timeout);
|
|
491
491
|
});
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
updateBusinessDomainAndApi(domain, api) {
|
|
495
495
|
}
|
|
496
496
|
|
|
497
497
|
getFullScreenHeight(systemInfo) {
|
|
498
498
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
|
|
499
499
|
let result = screenHeight;
|
|
500
500
|
if (statusBarHeight > 20 && isAndroid) {
|
|
501
501
|
result = screenHeight + statusBarHeight;
|
|
502
502
|
}
|
|
503
503
|
return result;
|
|
504
504
|
}
|
|
505
505
|
|
|
506
506
|
getTabBarHeight(systemInfo) {
|
|
507
507
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo;
|
|
508
508
|
let result = 50;
|
|
509
509
|
if (statusBarHeight > 20) {
|
|
510
510
|
if (isIOS) {
|
|
511
511
|
result = 84;
|
|
512
512
|
} else if (isAndroid) {
|
|
513
513
|
result = 53;
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
516
|
return result;
|
|
517
517
|
}
|
|
518
518
|
|
|
519
519
|
getSystemInfo() {
|
|
520
520
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes =
|
|
521
521
|
getSystemInfos() || {};
|
|
522
522
|
const actualNavBarHeight =
|
|
523
523
|
(info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
|
|
524
524
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
|
|
525
525
|
const fullScreenHeight = this.getFullScreenHeight(info);
|
|
526
526
|
const tabBarHeight = this.getTabBarHeight(info);
|
|
527
527
|
const safeContentHeight = fullScreenHeight - headerHeight;
|
|
528
528
|
this.info.sysInfo = {
|
|
529
529
|
...this.info.sysInfo,
|
|
530
530
|
...info,
|
|
531
531
|
actualNavBarHeight,
|
|
532
532
|
headerHeight,
|
|
533
533
|
fullScreenHeight,
|
|
534
534
|
tabBarHeight,
|
|
535
535
|
safeContentHeight,
|
|
536
536
|
};
|
|
537
537
|
this.getEid().then((res: { eid: string }) => {
|
|
538
538
|
res && res.eid && (this.info.sysInfo["eid"] = res.eid);
|
|
539
539
|
});
|
|
540
540
|
if (this.info.sysInfo["hostVersionName"]) {
|
|
541
541
|
this.info.sysInfo["hostAppVersion"] = Number(
|
|
542
542
|
this.info.sysInfo["hostVersionName"].replace(/\./g, "")
|
|
543
543
|
);
|
|
544
544
|
}
|
|
545
545
|
console.log("获取系统信息", this.info.sysInfo);
|
|
546
546
|
this.getNetWorkType();
|
|
547
547
|
}
|
|
548
548
|
async updateMPaasConfig() {}
|
|
549
549
|
|
|
550
550
|
getNetWorkType() {
|
|
551
551
|
Taro.getNetworkType().then((getRes) => {
|
|
552
552
|
getRes &&
|
|
553
553
|
getRes.networkType &&
|
|
554
554
|
(this.info.sysInfo["netWorkType"] = getRes.networkType);
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
557
|
|
|
558
558
|
checkStatusAndLogin(options = {}) {
|
|
559
559
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
560
560
|
console.log(
|
|
561
561
|
"微信小程序登录状态及获取cookie状态的promise,之前登录状态",
|
|
562
562
|
this.info.loginState
|
|
563
563
|
);
|
|
564
564
|
this.toLogin(options)
|
|
565
565
|
.then((res) => {
|
|
566
566
|
console.log("微信小程序登录状态结果,成功", res);
|
|
567
567
|
this.info.loginState = true;
|
|
568
568
|
resolve(res);
|
|
569
569
|
})
|
|
570
570
|
.catch((err) => {
|
|
571
571
|
console.log("微信小程序登录异常状态结果", err);
|
|
572
572
|
this.doLogin(options)
|
|
573
573
|
.then((res2) => {
|
|
574
574
|
console.log("微信小程序wxDoLogin强制登陆成功:", res2);
|
|
575
575
|
this.info.loginState = true;
|
|
576
576
|
resolve(res2);
|
|
577
577
|
})
|
|
578
578
|
.catch((err2) => {
|
|
579
579
|
console.log("微信小程序wxDoLogin强制登陆失败:", err2);
|
|
580
580
|
this.checkStatusAndLoginPromise = null;
|
|
581
581
|
reject(err2);
|
|
582
582
|
});
|
|
583
583
|
});
|
|
584
584
|
});
|
|
585
585
|
return this.checkStatusAndLoginPromise;
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
checkJdStatusAndLogin(options) {
|
|
589
589
|
return this.checkStatusAndLogin(options);
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
|
|
593
593
|
doLoginForJdPin(options = {}) {
|
|
594
594
|
return this.doLogin(options);
|
|
595
595
|
}
|
|
596
596
|
|
|
597
597
|
getEid() {
|
|
598
598
|
if (typeof jd !== "undefined" && jd.getEid) {
|
|
599
599
|
return new Promise((resolve, reject) => {
|
|
600
600
|
jd.getEid({
|
|
601
601
|
success: (res: { eid: string }) => {
|
|
602
602
|
resolve(res);
|
|
603
603
|
},
|
|
604
604
|
fail: (err: any) => {
|
|
605
605
|
reject(err);
|
|
606
606
|
},
|
|
607
607
|
});
|
|
608
608
|
});
|
|
609
609
|
} else {
|
|
610
610
|
return Promise.resolve(false);
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
613
|
|
|
614
614
|
toLogin(options = {}): Promise<any> {
|
|
615
615
|
return this.wxAppLoginInstance
|
|
616
616
|
.getLoginPromise({
|
|
617
617
|
mode: "silent",
|
|
618
618
|
loginColor: {
|
|
619
619
|
biz: WXAPP_BIZ_KEY,
|
|
620
620
|
dpin: 0,
|
|
621
621
|
},
|
|
622
622
|
...options,
|
|
623
623
|
})
|
|
624
624
|
.then((res) => {
|
|
625
625
|
console.log("微信app登录返回信息,微信侧返回code为0表示成功", res);
|
|
626
626
|
setTimeout(() => {
|
|
627
627
|
console.log(
|
|
628
628
|
"微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie"
|
|
629
629
|
);
|
|
630
630
|
this.getLoginCookie(`${Date.now()}`);
|
|
631
631
|
}, 500);
|
|
632
632
|
})
|
|
633
633
|
.catch((err) => {
|
|
634
634
|
console.log("微信app登录异常返回信息,也获取cookie", err);
|
|
635
635
|
this.getLoginCookie(`${Date.now()}`);
|
|
636
636
|
});
|
|
637
637
|
}
|
|
638
638
|
|
|
639
639
|
doLogin(options) {
|
|
640
640
|
console.log("触发松果小程序 doLogin() new new");
|
|
641
641
|
return new Promise((resolve, reject) => {
|
|
642
642
|
jd.login({
|
|
643
643
|
success: (res) => {
|
|
644
644
|
if (res.code) {
|
|
645
645
|
console.log("[common]松果小程序登录成功", res.code);
|
|
646
646
|
jd.redirectTo({
|
|
647
647
|
url: `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
648
648
|
...this.info.originQueryInfo,
|
|
649
649
|
})}`,
|
|
650
650
|
});
|
|
651
651
|
resolve(res);
|
|
652
652
|
} else {
|
|
653
653
|
console.error("[common]松果小程序登录失败", res.errMsg);
|
|
654
654
|
reject();
|
|
655
655
|
}
|
|
656
656
|
},
|
|
657
657
|
fail: (res) => {
|
|
658
658
|
console.error("[common]松果小程序登录失败", res.errMsg);
|
|
659
659
|
reject();
|
|
660
660
|
},
|
|
661
661
|
});
|
|
662
662
|
});
|
|
663
663
|
}
|
|
664
664
|
|
|
665
665
|
getLoginCookie(updateKey = "wxapp") {
|
|
666
666
|
return new Promise((resolve) => {
|
|
667
667
|
console.log("开始获取更新wxapp中的cookie信息", updateKey);
|
|
668
668
|
if (
|
|
669
669
|
this.config.wqCookie &&
|
|
670
670
|
this.config.wqCookieStr &&
|
|
671
671
|
this.config.getWqCookieKey === updateKey
|
|
672
672
|
) {
|
|
673
673
|
console.log("已有存储wxapp中的cookie信息,直接返回", this.config);
|
|
674
674
|
resolve({
|
|
675
675
|
wqCookie: this.config.wqCookie,
|
|
676
676
|
wqCookieStr: this.config.wqCookieStr,
|
|
677
677
|
});
|
|
678
678
|
} else {
|
|
679
679
|
if (isPublishToWxapp) {
|
|
680
680
|
const getWxappCookieObj = getTaroStorageKeyValue("cookies") || null;
|
|
681
681
|
if (getWxappCookieObj) {
|
|
682
682
|
const getCookieObj = getWxappCookieObj["_data"];
|
|
683
683
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
|
|
684
684
|
const {
|
|
685
685
|
pin = "",
|
|
686
686
|
visitkey = "-1",
|
|
687
687
|
wq_unionid = "",
|
|
688
688
|
wxapp_openid = "",
|
|
689
689
|
} = wqCookie;
|
|
690
690
|
this.info.loginState = true;
|
|
691
691
|
this.info.userInfo.wqCookie = wqCookieStr;
|
|
692
692
|
this.info.userInfo.wqVisitkey = visitkey;
|
|
693
693
|
console.log("获取用户完整cookie信息", getCookieObj);
|
|
694
694
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress();
|
|
695
695
|
console.log("获取微信用户地址信息", getUserAddress);
|
|
696
696
|
if (getUserAddress) {
|
|
697
697
|
this.info.pageInfo.address = getUserAddress?.areaId;
|
|
698
698
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
|
|
699
699
|
? this.info.pageInfo.address.replace(/_/g, ",")
|
|
700
700
|
: "";
|
|
701
701
|
this.info.pageInfo.un_area = this.info.pageInfo.address;
|
|
702
702
|
Taro.eventCenter.trigger(
|
|
703
703
|
TaroEventType.USER_AREA_UPDATE,
|
|
704
704
|
this.info.pageInfo.address
|
|
705
705
|
);
|
|
706
706
|
}
|
|
707
707
|
if (this.miniAppLogInstance) {
|
|
708
708
|
this.miniAppLogInstance.set({
|
|
709
709
|
account: pin,
|
|
710
710
|
unionid: wq_unionid,
|
|
711
711
|
openid: wxapp_openid,
|
|
712
712
|
});
|
|
713
713
|
}
|
|
714
714
|
this.config.wqCookie = wqCookie;
|
|
715
715
|
this.config.wqCookieStr = wqCookieStr;
|
|
716
716
|
this.config.getWqCookieKey = updateKey;
|
|
717
717
|
console.log("解析wxapp中的cookie信息成功,返回后存储", this.config);
|
|
718
718
|
resolve({
|
|
719
719
|
wqCookie,
|
|
720
720
|
wqCookieStr,
|
|
721
721
|
});
|
|
722
722
|
} else {
|
|
723
723
|
console.log(
|
|
724
724
|
"解析wxapp中的cookie信息异常,返回异常结果",
|
|
725
725
|
this.config
|
|
726
726
|
);
|
|
727
727
|
resolve({
|
|
728
728
|
wqCookie: false,
|
|
729
729
|
wqCookieStr: false,
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
732
|
} else {
|
|
733
733
|
resolve({
|
|
734
734
|
wqCookie: false,
|
|
735
735
|
wqCookieStr: false,
|
|
736
736
|
});
|
|
737
737
|
}
|
|
738
738
|
}
|
|
739
739
|
});
|
|
740
740
|
}
|
|
741
741
|
|
|
742
742
|
|
|
743
743
|
checkLoginStatus() {
|
|
744
744
|
return this.getLoginCookie();
|
|
745
745
|
}
|
|
746
746
|
|
|
747
747
|
getAddressCachePromise = () => {
|
|
748
748
|
return Promise.reject("该方法只在APP内适用");
|
|
749
749
|
};
|
|
750
750
|
|
|
751
751
|
getDynamicConfig(key: string){
|
|
752
752
|
console.warn('调用松果小程序的 getDynamicConfig(),注意,此方法还未实现!')
|
|
753
753
|
return null
|
|
754
754
|
}
|
|
755
755
|
|
|
756
756
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
757
757
|
const createUpdateQueryInfo: {
|
|
758
758
|
query: {
|
|
759
759
|
shopId?: string | number;
|
|
760
760
|
venderId?: string | number;
|
|
761
761
|
};
|
|
762
762
|
updateShopInfoState: boolean;
|
|
763
763
|
} = Object.assign(
|
|
764
764
|
{},
|
|
765
765
|
{
|
|
766
766
|
query: {},
|
|
767
767
|
updateShopInfoState: false,
|
|
768
768
|
},
|
|
769
769
|
updateQuery
|
|
770
770
|
);
|
|
771
771
|
console.log(
|
|
772
772
|
"获取当前下发的店铺查询参数",
|
|
773
773
|
updateQuery,
|
|
774
774
|
"获取之前保存的shopInfo店铺查询参数",
|
|
775
775
|
this.info?.shopInfo
|
|
776
776
|
);
|
|
777
777
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
778
778
|
const { shopId, venderId } = query;
|
|
779
779
|
if (updateShopInfoState) {
|
|
780
780
|
this.info.queryInfo = {
|
|
781
781
|
...this.info.queryInfo,
|
|
782
782
|
...query,
|
|
783
783
|
};
|
|
784
784
|
if (shopId && venderId) {
|
|
785
785
|
this.info.shopInfo = {
|
|
786
786
|
shopId: `${shopId}`,
|
|
787
787
|
venderId: `${venderId}`,
|
|
788
788
|
};
|
|
789
789
|
}
|
|
790
790
|
} else {
|
|
791
791
|
this.info.queryInfo = {
|
|
792
792
|
...query,
|
|
793
793
|
};
|
|
794
794
|
this.info.originQueryInfo = {
|
|
795
795
|
...query,
|
|
796
796
|
};
|
|
797
797
|
if (
|
|
798
798
|
this.info.shopInfo?.shopId &&
|
|
799
799
|
this.info.shopInfo?.venderId &&
|
|
800
800
|
(this.info.shopInfo.shopId == shopId ||
|
|
801
801
|
this.info.shopInfo.venderId == venderId)
|
|
802
802
|
) {
|
|
803
803
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
804
804
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
805
805
|
console.log(
|
|
806
806
|
"当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数",
|
|
807
807
|
this.info.queryInfo
|
|
808
808
|
);
|
|
809
809
|
}
|
|
810
810
|
}
|
|
811
811
|
this.info.queryInfo["shopId"] &&
|
|
812
812
|
(this.info.queryInfo["shopId"] = `${this.info.queryInfo["shopId"]}`);
|
|
813
813
|
this.info.queryInfo["venderId"] &&
|
|
814
814
|
(this.info.queryInfo["venderId"] = `${this.info.queryInfo["venderId"]}`);
|
|
815
815
|
console.log(
|
|
816
816
|
"weapp===获取店铺下发查询参数\n",
|
|
817
817
|
query,
|
|
818
818
|
"\n获取店铺最后查询参数\n",
|
|
819
819
|
this.info.queryInfo,
|
|
820
820
|
"\n是否为更新店铺状态\n",
|
|
821
821
|
updateShopInfoState
|
|
822
822
|
);
|
|
823
823
|
}
|