@conecli/cone-render 0.10.1-isv2.1 → 0.10.1-isv2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.ts +1 -1
- package/dist/common/const.ts +1 -1
- package/dist/common/environmentType.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 -1
- package/dist/common/sgmCustomCode.ts +1 -1
- package/dist/common/token/index.h5.ts +1 -1
- package/dist/common/token/token.jd.ts +1 -1
- package/dist/common/wxappApi.ts +1 -1
- package/dist/components/ErrorBoundary.tsx +1 -1
- package/dist/components/base/CommonFloorHead/index.module.scss +126 -111
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/base/CountDown/index.module.scss +49 -44
- package/dist/components/base/CountDown/index.tsx +1 -1
- package/dist/components/base/CustomScrollView/index-back.tsx +1 -0
- package/dist/components/base/CustomScrollView/index.tsx +1 -1
- package/dist/components/base/CustomVideo/common.ts +1 -0
- package/dist/components/base/CustomVideo/index.tsx +1 -1
- package/dist/components/base/Dialog/index.module.scss +11 -0
- package/dist/components/base/ExposureSmart/index.h5.module.scss +12 -2
- package/dist/components/base/ExposureSmart/index.h5.tsx +1 -1
- package/dist/components/base/ExposureSmart/reporter.tsx +1 -1
- package/dist/components/base/InOrOutViewObserver/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.tsx +1 -1
- package/dist/components/base/InViewRender/index.weapp.tsx +1 -1
- package/dist/components/base/ItemViewExposureSmart/index.module.scss +2 -2
- package/dist/components/base/ItemViewExposureSmart/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.tsx +1 -1
- package/dist/components/base/LazyLayoutLoad/index.weapp.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.h5.module.scss +11 -3
- package/dist/components/base/LazyLoadImage/index.h5.tsx +1 -1
- package/dist/components/base/LazyLoadImage/index.tsx +1 -1
- package/dist/components/base/MobileCommonHeader/index.tsx +1 -1
- package/dist/components/base/NetworkDataError/index.module.scss +3 -0
- package/dist/components/base/NetworkDataError/index.tsx +1 -1
- package/dist/components/base/Price/Base/index.tsx +1 -1
- package/dist/components/base/Price/Double/index.module.scss +8 -0
- package/dist/components/base/Price/Double/index.tsx +1 -1
- package/dist/components/debug/DebugLayout/index.module.scss +2 -2
- package/dist/components/decorate/DecorateFloorModule/index.module.scss +11 -0
- package/dist/components/decorate/DecorateFloorModule/index.tsx +1 -1
- package/dist/components/decorate/EmptyFloorModule/index.tsx +1 -1
- package/dist/components/decorate/PlaceHolder/index.tsx +1 -1
- package/dist/components/floorItem.jd.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/floorItem.weapp.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +1 -1
- package/dist/interface/common.ts +1 -1
- package/dist/interface/component.ts +1 -1
- package/dist/interface/jumpEventReport.ts +1 -1
- package/dist/interface/service.ts +1 -1
- package/dist/jumpEventReport/base.ts +1 -1
- package/dist/jumpEventReport/const.ts +1 -1
- package/dist/jumpEventReport/index.jd.ts +1 -1
- package/dist/jumpEventReport/index.weapp.ts +1 -1
- package/dist/jumpEventReport/jdJumpJdApp.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/logEventConfig.ts +1 -1
- package/dist/jumpEventReport/web/report.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.jd.ts +1 -1
- package/dist/jumpEventReport/web.jdb.ts +1 -1
- package/dist/jumpEventReport/web.jdjch.ts +1 -1
- package/dist/jumpEventReport/web.jxwxapp.ts +1 -1
- package/dist/jumpEventReport/web.pc.ts +1 -1
- package/dist/jumpEventReport/web.tjapp.ts +1 -1
- package/dist/jumpEventReport/web.tjm.ts +1 -1
- package/dist/jumpEventReport/web.wxapp.ts +1 -1
- package/dist/libs/taroAppReport.js +2 -2
- package/dist/modules/ContainerFloorList/index.h5.module.scss +66 -52
- package/dist/modules/ContainerFloorList/index.h5.tsx +1 -1
- package/dist/modules/ContainerFloorList/index.tsx +1 -1
- package/dist/open/api/device.ts +1 -1
- package/dist/open/api/environment.ts +1 -1
- package/dist/open/api/request.ts +1 -1
- package/dist/open/api/shopMember.ts +1 -1
- package/dist/open/api/util.ts +1 -1
- package/dist/open/components/index.ts +1 -1
- package/dist/sass/app.h5.scss +275 -221
- package/dist/sass/base.scss +183 -137
- package/dist/service/fetchGateway.ts +1 -1
- package/dist/service/fetchGateway.weapp.ts +1 -0
- package/dist/service/http/colorSign.ts +1 -1
- package/dist/service/http/const.ts +1 -1
- package/dist/service/http/h5Http.ts +1 -0
- package/dist/service/http/index.h5.ts +1 -0
- package/dist/service/requestServer.h5.ts +1 -0
- package/dist/service/requestServer.ts +1 -1
- package/dist/service/requestServer.weapp.ts +1 -0
- package/dist/utils/connectNativeJsBridge.ts +1 -1
- package/dist/utils/connectNativeJsBridge.weapp.ts +1 -1
- package/dist/utils/h5Utils.ts +1 -1
- package/dist/utils/index.h5.ts +1 -1
- package/dist/utils/index.ts +1 -1
- package/dist/utils/index.weapp.ts +1 -1
- package/dist/utils/jumpExtMapUtil.h5.ts +1 -0
- package/dist/utils/jumpExtMapUtil.ts +1 -0
- package/dist/utils/log.ts +1 -0
- package/dist/utils/sColor.js +1 -0
- package/dist/utils/sgmCodeUtils.ts +1 -1
- package/dist/utils/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/dist/wxapp/common/address_api/address_api_v2.js +1 -0
- package/dist/wxapp/common/user_info.js +1 -1
- package/package.json +158 -135
- package/dist/utils/memberFormatUtils.js +0 -1
|
@@ -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
|
WXAPP_SUBS_GUIDER,
|
|
11
10
|
BUSINESS_TYPE,
|
|
12
11
|
SHOP_MENU_ID_TYPE,
|
|
13
12
|
SHOP_MENU_ID_NAME,
|
|
14
13
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
15
14
|
SECTION_HOME_TAB_TYPE,
|
|
16
15
|
TaroEventType,
|
|
17
16
|
WX_BUSINESS_TYPE,
|
|
18
17
|
WXAPP_BIZ_KEY,
|
|
19
18
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
20
19
|
getSystemInfos,
|
|
21
20
|
getTaroStorageKeyValue,
|
|
22
21
|
getWxAppCookieStr,
|
|
23
22
|
objectToUrlEncode,
|
|
24
23
|
loginState: jdUserLoginState,
|
|
25
24
|
cookiesStr: '',
|
|
26
25
|
userInfo: userPinKey,
|
|
27
26
|
pageInfo: {
|
|
28
27
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
29
28
|
address: '',
|
|
30
29
|
addressCommaStr: '',
|
|
31
30
|
un_area: '',
|
|
32
31
|
vapptype: '1',
|
|
33
32
|
pageType: 'home',
|
|
34
33
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
35
34
|
floorExposureInfo: {},
|
|
36
35
|
floorVideInfo: {},
|
|
37
36
|
productVideInfo: {},
|
|
38
37
|
tabsLoadAllDataInfo: {
|
|
39
38
|
[SECTION_HOME_TAB_NAME_TYPE[
|
|
40
39
|
SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN
|
|
41
40
|
]]: false,
|
|
42
41
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
43
42
|
},
|
|
44
43
|
updateShopInfosAllState: false,
|
|
45
44
|
isVipShop: false,
|
|
46
45
|
isJdShowNativeImmersivePlayer: false,
|
|
47
46
|
...shopConfig,
|
|
48
47
|
pageScrollTop: 0,
|
|
49
48
|
pageIdxHeightInfo: {
|
|
50
49
|
list: [],
|
|
51
50
|
},
|
|
52
51
|
shopNavBarHeight: 0,
|
|
53
52
|
},
|
|
54
53
|
defaultQueryLogInfo: {
|
|
55
54
|
sourceType: 'JDshop',
|
|
56
55
|
sourceValue: '',
|
|
57
56
|
moduleId: 'none',
|
|
58
57
|
entrance: 'none',
|
|
59
58
|
},
|
|
60
59
|
originQueryInfo: {},
|
|
61
60
|
sysInfo: {
|
|
62
61
|
windowWidth: 0,
|
|
63
62
|
windowHeight: 0,
|
|
64
63
|
netWorkType: '4g',
|
|
65
64
|
jdBottomBarHeight: 0,
|
|
66
65
|
jdNativeHeaderHeight: 0,
|
|
67
66
|
},
|
|
68
67
|
queryInfo: {},
|
|
69
68
|
shopInfo: {},
|
|
70
69
|
openAppData: {},
|
|
71
70
|
public info: CommonInterFace.BaseConfigInfo
|
|
72
71
|
public config: {
|
|
73
72
|
[key: string]: any
|
|
74
73
|
}
|
|
75
74
|
public lazyContainer: CommonInterFace.lazyContainer
|
|
76
75
|
public rootEleNode: HTMLElement | null
|
|
77
76
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil
|
|
78
77
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null
|
|
79
78
|
public checkStatusAndLoginPromise: object | null
|
|
80
79
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin
|
|
81
80
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo
|
|
82
81
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo
|
|
83
82
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage
|
|
84
83
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT
|
|
85
84
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator
|
|
86
85
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign
|
|
87
86
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign
|
|
88
87
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign
|
|
89
88
|
constructor(opt) {
|
|
90
89
|
this.info = this._getConfig(opt)
|
|
91
90
|
this.config = {}
|
|
92
91
|
this.lazyContainer = {
|
|
93
92
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
94
93
|
appLazyContainerList: [],
|
|
95
94
|
appLazyFinishContainerList: [],
|
|
96
95
|
},
|
|
97
96
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
98
97
|
appLazyContainerList: [],
|
|
99
98
|
appLazyFinishContainerList: [],
|
|
100
99
|
},
|
|
101
100
|
}
|
|
102
101
|
this.rootEleNode = null
|
|
103
102
|
this.miniApplogUtil = MiniAppLogUtil
|
|
104
103
|
this.miniAppLogInstance = null
|
|
105
104
|
this.checkStatusAndLoginPromise = null
|
|
106
105
|
this.wxAppLoginInstance = WXAPP_LOGIN
|
|
107
106
|
this.wxAppBizInstance = WXAPP_BIZ
|
|
108
107
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO
|
|
109
108
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE
|
|
110
109
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT
|
|
111
110
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR
|
|
112
111
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN
|
|
113
112
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT
|
|
114
113
|
? new WXAPP_FINGER_REPORT()
|
|
115
114
|
: {}
|
|
116
115
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER
|
|
117
116
|
}
|
|
118
117
|
_getConfig(opt) {
|
|
119
118
|
return Object.assign({}, DefaultConfig, opt)
|
|
120
119
|
}
|
|
121
120
|
|
|
122
121
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
123
122
|
return new Promise(resolve => {
|
|
124
123
|
setTimeout(() => {
|
|
125
124
|
const getCallBackRes = typeof callBack === 'function' && callBack()
|
|
126
125
|
return resolve(getCallBackRes || false)
|
|
127
126
|
}, timeout)
|
|
128
127
|
})
|
|
129
128
|
}
|
|
130
129
|
|
|
131
130
|
updateBusinessDomainAndApi(domain, api) {
|
|
132
131
|
console.log('=================>', 'updateBusinessDomainAndApi')
|
|
133
132
|
}
|
|
134
133
|
|
|
135
134
|
getFullScreenHeight(systemInfo) {
|
|
136
135
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo
|
|
137
136
|
let result = screenHeight
|
|
138
137
|
if (statusBarHeight > 20 && isAndroid) {
|
|
139
138
|
result = screenHeight + statusBarHeight
|
|
140
139
|
}
|
|
141
140
|
return result
|
|
142
141
|
}
|
|
143
142
|
|
|
144
143
|
getTabBarHeight(systemInfo) {
|
|
145
144
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo
|
|
146
145
|
let result = 50
|
|
147
146
|
if (statusBarHeight > 20) {
|
|
148
147
|
if (isIOS) {
|
|
149
148
|
result = 84
|
|
150
149
|
} else if (isAndroid) {
|
|
151
150
|
result = 53
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
return result
|
|
155
154
|
}
|
|
156
155
|
|
|
157
156
|
getSystemInfo() {
|
|
158
157
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {}
|
|
159
158
|
const actualNavBarHeight =
|
|
160
159
|
(info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0)
|
|
161
160
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0)
|
|
162
161
|
const fullScreenHeight = this.getFullScreenHeight(info)
|
|
163
162
|
const tabBarHeight = this.getTabBarHeight(info)
|
|
164
163
|
const safeContentHeight = fullScreenHeight - headerHeight
|
|
165
164
|
this.info.sysInfo = {
|
|
166
165
|
...this.info.sysInfo,
|
|
167
166
|
...info,
|
|
168
167
|
actualNavBarHeight,
|
|
169
168
|
headerHeight,
|
|
170
169
|
fullScreenHeight,
|
|
171
170
|
tabBarHeight,
|
|
172
171
|
safeContentHeight,
|
|
173
172
|
}
|
|
174
173
|
if (this.info.sysInfo['hostVersionName']) {
|
|
175
174
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
176
175
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
177
176
|
)
|
|
178
177
|
}
|
|
179
178
|
this.info.sysInfo['wifiVideoAutoPlay'] = false
|
|
180
179
|
this.getNetWorkType()
|
|
181
180
|
console.log('获取系统信息', this.info.sysInfo)
|
|
182
181
|
}
|
|
183
182
|
async updateMPaasConfig() {}
|
|
184
183
|
|
|
185
184
|
getNetWorkType() {
|
|
186
185
|
Taro.getNetworkType().then(getRes => {
|
|
187
186
|
getRes &&
|
|
188
187
|
getRes.networkType &&
|
|
189
188
|
(this.info.sysInfo['netWorkType'] = getRes.networkType)
|
|
190
189
|
})
|
|
191
190
|
}
|
|
192
191
|
|
|
193
192
|
checkStatusAndLogin(options = {}) {
|
|
194
193
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
195
194
|
console.log(
|
|
196
195
|
'微信小程序登录状态及获取cookie状态的promise,之前登录状态',
|
|
197
196
|
this.info.loginState,
|
|
198
197
|
)
|
|
199
198
|
this.toLogin(options)
|
|
200
199
|
.then(res => {
|
|
201
200
|
console.log('微信小程序登录状态结果,成功', res)
|
|
202
201
|
this.info.loginState = true
|
|
203
202
|
resolve(res)
|
|
204
203
|
})
|
|
205
204
|
.catch(err => {
|
|
206
205
|
console.log('微信小程序登录异常状态结果', err)
|
|
207
206
|
this.doLogin(options)
|
|
208
207
|
.then(res2 => {
|
|
209
208
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2)
|
|
210
209
|
this.info.loginState = true
|
|
211
210
|
resolve(res2)
|
|
212
211
|
})
|
|
213
212
|
.catch(err2 => {
|
|
214
213
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2)
|
|
215
214
|
this.checkStatusAndLoginPromise = null
|
|
216
215
|
reject(err2)
|
|
217
216
|
})
|
|
218
217
|
})
|
|
219
218
|
})
|
|
220
219
|
return this.checkStatusAndLoginPromise
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
checkJdStatusAndLogin(
|
|
224
223
|
options = {
|
|
225
224
|
loginColor: {
|
|
226
225
|
bzi: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
227
226
|
dpin: 0,
|
|
228
227
|
},
|
|
229
228
|
},
|
|
230
229
|
) {
|
|
231
230
|
return this.checkStatusAndLogin(options)
|
|
232
231
|
}
|
|
233
232
|
|
|
234
233
|
toLogin(options = {}): Promise<any> {
|
|
235
234
|
return this.wxAppLoginInstance
|
|
236
235
|
.getLoginPromise({
|
|
237
236
|
mode: 'silent',
|
|
238
237
|
loginColor: {
|
|
239
238
|
bzi: WXAPP_BIZ_KEY,
|
|
240
239
|
dpin: 1,
|
|
241
240
|
},
|
|
242
241
|
...options,
|
|
243
242
|
})
|
|
244
243
|
.then(res => {
|
|
245
244
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res)
|
|
246
245
|
setTimeout(() => {
|
|
247
246
|
console.log(
|
|
248
247
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
249
248
|
)
|
|
250
249
|
this.getLoginCookie(`${Date.now()}`)
|
|
251
250
|
}, 500)
|
|
252
251
|
})
|
|
253
252
|
.catch(err => {
|
|
254
253
|
console.log('微信app登录异常返回信息,也获取cookie', err)
|
|
255
254
|
this.getLoginCookie(`${Date.now()}`)
|
|
256
255
|
})
|
|
257
256
|
}
|
|
258
257
|
|
|
259
258
|
doLogin(options = {}) {
|
|
260
259
|
const getParams = {
|
|
261
260
|
loginColor: {
|
|
262
261
|
bzi: WXAPP_BIZ_KEY,
|
|
263
262
|
dpin: 1,
|
|
264
263
|
},
|
|
265
264
|
...options,
|
|
266
265
|
}
|
|
267
266
|
if (isPublishToWxapp) {
|
|
268
267
|
getParams[
|
|
269
268
|
'returnUrl'
|
|
270
269
|
] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
271
270
|
...this.info.originQueryInfo,
|
|
272
271
|
loadShopxType: 'redirect',
|
|
273
272
|
})}`
|
|
274
273
|
}
|
|
275
274
|
return this.wxAppLoginInstance.doLogin(getParams).then(res => {
|
|
276
275
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res)
|
|
277
276
|
setTimeout(() => {
|
|
278
277
|
console.log(
|
|
279
278
|
'微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
280
279
|
)
|
|
281
280
|
this.getLoginCookie(`${Date.now()}`)
|
|
282
281
|
}, 500)
|
|
283
282
|
return res
|
|
284
283
|
})
|
|
285
284
|
}
|
|
286
285
|
|
|
287
286
|
doLoginForJdPin(options = {}) {
|
|
288
287
|
return this.doLogin({
|
|
289
288
|
loginColor: {
|
|
290
289
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
291
290
|
dpin: 0,
|
|
292
291
|
},
|
|
293
292
|
...options,
|
|
294
293
|
})
|
|
295
294
|
}
|
|
296
295
|
|
|
297
296
|
getLoginCookie(updateKey = 'wxapp') {
|
|
298
297
|
return new Promise(resolve => {
|
|
299
298
|
console.log('开始获取更新wxapp中的cookie信息', updateKey)
|
|
300
299
|
if (
|
|
301
300
|
this.config.wqCookie &&
|
|
302
301
|
this.config.wqCookieStr &&
|
|
303
302
|
this.config.getWqCookieKey === updateKey
|
|
304
303
|
) {
|
|
305
304
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config)
|
|
306
305
|
resolve({
|
|
307
306
|
wqCookie: this.config.wqCookie,
|
|
308
307
|
wqCookieStr: this.config.wqCookieStr,
|
|
309
308
|
})
|
|
310
309
|
} else {
|
|
311
310
|
if (isPublishToWxapp) {
|
|
312
311
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null
|
|
313
312
|
if (getWxappCookieObj) {
|
|
314
313
|
const getCookieObj = getWxappCookieObj['_data']
|
|
315
314
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj)
|
|
316
315
|
const {
|
|
317
316
|
pin = '',
|
|
318
317
|
visitkey = '-1',
|
|
319
318
|
wq_unionid = '',
|
|
320
319
|
wxapp_openid = '',
|
|
321
320
|
} = wqCookie
|
|
322
321
|
this.info.loginState = true
|
|
323
322
|
this.info.userInfo.wqCookie = wqCookieStr
|
|
324
323
|
this.info.userInfo.wqVisitkey = visitkey
|
|
325
324
|
console.log('获取用户完整cookie信息', getCookieObj)
|
|
326
325
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress()
|
|
327
326
|
console.log('获取微信用户地址信息', getUserAddress)
|
|
328
327
|
if (getUserAddress) {
|
|
329
328
|
this.info.pageInfo.address = getUserAddress?.areaId
|
|
330
329
|
this.info.pageInfo.addressCommaStr = this.info.pageInfo.address
|
|
331
330
|
? this.info.pageInfo.address.replace(/_/g, ',')
|
|
332
331
|
: ''
|
|
333
332
|
this.info.pageInfo.un_area = this.info.pageInfo.address
|
|
334
333
|
Taro.eventCenter.trigger(
|
|
335
334
|
TaroEventType.USER_AREA_UPDATE,
|
|
336
335
|
this.info.pageInfo.address,
|
|
337
336
|
)
|
|
338
337
|
}
|
|
339
338
|
if (this.miniAppLogInstance) {
|
|
340
339
|
this.miniAppLogInstance.set({
|
|
341
340
|
account: pin,
|
|
342
341
|
unionid: wq_unionid,
|
|
343
342
|
openid: wxapp_openid,
|
|
344
343
|
})
|
|
345
344
|
}
|
|
346
345
|
this.config.wqCookie = wqCookie
|
|
347
346
|
this.config.wqCookieStr = wqCookieStr
|
|
348
347
|
this.config.getWqCookieKey = updateKey
|
|
349
348
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config)
|
|
350
349
|
resolve({
|
|
351
350
|
wqCookie,
|
|
352
351
|
wqCookieStr,
|
|
353
352
|
})
|
|
354
353
|
} else {
|
|
355
354
|
console.log(
|
|
356
355
|
'解析wxapp中的cookie信息异常,返回异常结果',
|
|
357
356
|
this.config,
|
|
358
357
|
)
|
|
359
358
|
resolve({
|
|
360
359
|
wqCookie: false,
|
|
361
360
|
wqCookieStr: false,
|
|
362
361
|
})
|
|
363
362
|
}
|
|
364
363
|
} else {
|
|
365
364
|
resolve({
|
|
366
365
|
wqCookie: false,
|
|
367
366
|
wqCookieStr: false,
|
|
368
367
|
})
|
|
369
368
|
}
|
|
370
369
|
}
|
|
371
370
|
})
|
|
372
371
|
}
|
|
373
372
|
|
|
374
373
|
|
|
375
374
|
checkLoginStatus() {
|
|
376
375
|
return this.getLoginCookie()
|
|
377
376
|
}
|
|
378
377
|
|
|
379
378
|
getAddressCachePromise = () => {
|
|
380
379
|
return Promise.reject('该方法只在APP内适用')
|
|
381
380
|
}
|
|
382
381
|
|
|
383
382
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
384
383
|
const createUpdateQueryInfo: {
|
|
385
384
|
query: {
|
|
386
385
|
shopId?: string | number
|
|
387
386
|
venderId?: string | number
|
|
388
387
|
}
|
|
389
388
|
updateShopInfoState: boolean
|
|
390
389
|
} = Object.assign(
|
|
391
390
|
{},
|
|
392
391
|
{
|
|
393
392
|
query: {},
|
|
394
393
|
updateShopInfoState: false,
|
|
395
394
|
},
|
|
396
395
|
updateQuery,
|
|
397
396
|
)
|
|
398
397
|
console.log(
|
|
399
398
|
'获取当前下发的店铺查询参数',
|
|
400
399
|
updateQuery,
|
|
401
400
|
'获取之前保存的shopInfo店铺查询参数',
|
|
402
401
|
this.info?.shopInfo,
|
|
403
402
|
)
|
|
404
403
|
const { query, updateShopInfoState } = createUpdateQueryInfo
|
|
405
404
|
const { shopId, venderId } = query
|
|
406
405
|
if (updateShopInfoState) {
|
|
407
406
|
this.info.queryInfo = {
|
|
408
407
|
...this.info.queryInfo,
|
|
409
408
|
...query,
|
|
410
409
|
}
|
|
411
410
|
if (shopId && venderId) {
|
|
412
411
|
this.info.shopInfo = {
|
|
413
412
|
shopId: `${shopId}`,
|
|
414
413
|
venderId: `${venderId}`,
|
|
415
414
|
}
|
|
416
415
|
}
|
|
417
416
|
} else {
|
|
418
417
|
this.info.queryInfo = {
|
|
419
418
|
...query,
|
|
420
419
|
}
|
|
421
420
|
this.info.originQueryInfo = {
|
|
422
421
|
...query,
|
|
423
422
|
}
|
|
424
423
|
if (
|
|
425
424
|
this.info.shopInfo?.shopId &&
|
|
426
425
|
this.info.shopInfo?.venderId &&
|
|
427
426
|
(this.info.shopInfo.shopId == shopId ||
|
|
428
427
|
this.info.shopInfo.venderId == venderId)
|
|
429
428
|
) {
|
|
430
429
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId
|
|
431
430
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId
|
|
432
431
|
console.log(
|
|
433
432
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
434
433
|
this.info.queryInfo,
|
|
435
434
|
)
|
|
436
435
|
}
|
|
437
436
|
}
|
|
438
437
|
this.info.queryInfo['shopId'] &&
|
|
439
438
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`)
|
|
440
439
|
this.info.queryInfo['venderId'] &&
|
|
441
440
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`)
|
|
442
441
|
console.log(
|
|
443
442
|
'weapp===获取店铺下发查询参数\n',
|
|
444
443
|
query,
|
|
445
444
|
'\n获取店铺最后查询参数\n',
|
|
446
445
|
this.info.queryInfo,
|
|
447
446
|
'\n是否为更新店铺状态\n',
|
|
448
447
|
updateShopInfoState,
|
|
449
448
|
)
|
|
450
449
|
}
|
|
451
450
|
|
|
452
451
|
getDynamicConfig(key: string) {
|
|
453
452
|
console.warn(
|
|
454
453
|
'调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!',
|
|
455
454
|
)
|
|
456
455
|
return null
|
|
457
456
|
}
|
|
457
|
+
import Taro from '@tarojs/taro';
|
|
458
458
|
WXAPP_LOGIN,
|
|
459
459
|
WXAPP_BIZ,
|
|
460
460
|
WXAPP_USER_INFO,
|
|
461
461
|
WXAPP_NAVIGATOR,
|
|
462
462
|
WXAPP_REPORT_GDT,
|
|
463
463
|
WXAPP_PARAMS_SIGN,
|
|
464
464
|
WXAPP_FINGER_REPORT,
|
|
465
465
|
WXAPP_REPORT_MANAGE,
|
|
466
466
|
WXAPP_SUBS_GUIDER,
|
|
467
467
|
WXAPP_ADDRESS_V2_API,
|
|
468
468
|
BUSINESS_TYPE,
|
|
469
469
|
SHOP_MENU_ID_TYPE,
|
|
470
470
|
SHOP_MENU_ID_NAME,
|
|
471
471
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
472
472
|
SECTION_HOME_TAB_TYPE,
|
|
473
473
|
TaroEventType,
|
|
474
474
|
WX_BUSINESS_TYPE,
|
|
475
475
|
WXAPP_BIZ_KEY,
|
|
476
476
|
WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
477
477
|
getSystemInfos,
|
|
478
478
|
getTaroStorageKeyValue,
|
|
479
479
|
getWxAppCookieStr,
|
|
480
480
|
objectToUrlEncode,
|
|
481
481
|
abTestLabels: {},
|
|
482
482
|
nonSellableSkuids: {},
|
|
483
483
|
loginState: jdUserLoginState,
|
|
484
484
|
cookiesStr: '',
|
|
485
485
|
userInfo: userPinKey,
|
|
486
486
|
isImmersive: false,
|
|
487
487
|
pageInfo: {
|
|
488
488
|
wxBusinessType: WX_BUSINESS_TYPE.SHOP,
|
|
489
489
|
address: '',
|
|
490
490
|
addressCommaStr: '',
|
|
491
491
|
un_area: '',
|
|
492
492
|
userLbsAddress: '',
|
|
493
493
|
vapptype: '1',
|
|
494
494
|
pageType: 'home',
|
|
495
495
|
dataType: BUSINESS_TYPE.ONLINE,
|
|
496
496
|
floorExposureInfo: {},
|
|
497
497
|
floorVideInfo: {},
|
|
498
498
|
productVideInfo: {},
|
|
499
499
|
tabsLoadAllDataInfo: {
|
|
500
500
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: false,
|
|
501
501
|
[SHOP_MENU_ID_NAME[SHOP_MENU_ID_TYPE.CLASSIFY]]: true,
|
|
502
502
|
},
|
|
503
503
|
updateShopInfosAllState: false,
|
|
504
504
|
isVipShop: false,
|
|
505
505
|
isJdShowNativeImmersivePlayer: false,
|
|
506
506
|
...shopConfig,
|
|
507
507
|
pageScrollTop: 0,
|
|
508
508
|
pageIdxHeightInfo: {
|
|
509
509
|
list: [],
|
|
510
510
|
},
|
|
511
511
|
shopNavBarHeight: 0,
|
|
512
512
|
},
|
|
513
513
|
defaultQueryLogInfo: {
|
|
514
514
|
sourceType: 'JDshop',
|
|
515
515
|
sourceValue: '',
|
|
516
516
|
moduleId: 'none',
|
|
517
517
|
entrance: 'none',
|
|
518
518
|
},
|
|
519
519
|
originQueryInfo: {},
|
|
520
520
|
sysInfo: {
|
|
521
521
|
windowWidth: 0,
|
|
522
522
|
windowHeight: 0,
|
|
523
523
|
netWorkType: '4g',
|
|
524
524
|
jdBottomBarHeight: 0,
|
|
525
525
|
jdNativeHeaderHeight: 0,
|
|
526
526
|
},
|
|
527
527
|
queryInfo: {},
|
|
528
528
|
shopInfo: {},
|
|
529
529
|
openAppData: {},
|
|
530
530
|
public info: CommonInterFace.BaseConfigInfo;
|
|
531
531
|
public config: {
|
|
532
532
|
[key: string]: any;
|
|
533
533
|
};
|
|
534
534
|
public lazyContainer: CommonInterFace.lazyContainer;
|
|
535
535
|
public rootEleNode: HTMLElement | null;
|
|
536
536
|
public miniApplogUtil: CommonInterFace.MiniApplogUtil;
|
|
537
537
|
public miniAppLogInstance: CommonInterFace.MiniAppLog | null;
|
|
538
538
|
public checkStatusAndLoginPromise: object | null;
|
|
539
539
|
public wxAppLoginInstance: CommonInterFace.WxAppLogin;
|
|
540
540
|
public wxAppBizInstance: CommonInterFace.WxAppUserInfo;
|
|
541
541
|
public wxAppUserInfoInstance: CommonInterFace.WxAppUserInfo;
|
|
542
542
|
public wxAppReportManageInstance: CommonInterFace.wxAppReportManage;
|
|
543
543
|
public wxAppReportGDTInstance: CommonInterFace.WxAppReportGDT;
|
|
544
544
|
public wxAppNavigatorInstance: CommonInterFace.WxAppNavigator;
|
|
545
545
|
public wxAppParamsSignInstance: CommonInterFace.wxAppParamsSign;
|
|
546
546
|
public wxAppFingerReportInstance: CommonInterFace.wxAppParamsSign;
|
|
547
547
|
public wxAppSubsGuider: CommonInterFace.wxAppParamsSign;
|
|
548
548
|
public wxAppAddressV2apiInstance: CommonInterFace.wxAppAddressV2api;
|
|
549
549
|
public loadJsSdkList: Array<any>;
|
|
550
550
|
public loadJsSdkListCachePromise: any;
|
|
551
551
|
public lbsAddressCachePromise: Promise<any> | null;
|
|
552
552
|
constructor(opt) {
|
|
553
553
|
this.info = this._getConfig(opt);
|
|
554
554
|
this.config = {};
|
|
555
555
|
this.lazyContainer = {
|
|
556
556
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_WELL_CHOSEN]]: {
|
|
557
557
|
appLazyContainerList: [],
|
|
558
558
|
appLazyFinishContainerList: [],
|
|
559
559
|
},
|
|
560
560
|
[SECTION_HOME_TAB_NAME_TYPE[SECTION_HOME_TAB_TYPE.HOME_PROMOTION]]: {
|
|
561
561
|
appLazyContainerList: [],
|
|
562
562
|
appLazyFinishContainerList: [],
|
|
563
563
|
},
|
|
564
564
|
};
|
|
565
565
|
this.loadJsSdkList = [];
|
|
566
566
|
this.loadJsSdkListCachePromise = {};
|
|
567
567
|
this.rootEleNode = null;
|
|
568
568
|
this.miniApplogUtil = MiniAppLogUtil;
|
|
569
569
|
this.miniAppLogInstance = null;
|
|
570
570
|
this.checkStatusAndLoginPromise = null;
|
|
571
571
|
this.wxAppLoginInstance = WXAPP_LOGIN;
|
|
572
572
|
this.wxAppBizInstance = WXAPP_BIZ;
|
|
573
573
|
this.wxAppUserInfoInstance = WXAPP_USER_INFO;
|
|
574
574
|
this.wxAppReportManageInstance = WXAPP_REPORT_MANAGE;
|
|
575
575
|
this.wxAppReportGDTInstance = WXAPP_REPORT_GDT;
|
|
576
576
|
this.wxAppNavigatorInstance = WXAPP_NAVIGATOR;
|
|
577
577
|
this.wxAppParamsSignInstance = WXAPP_PARAMS_SIGN;
|
|
578
578
|
this.wxAppFingerReportInstance = WXAPP_FINGER_REPORT ? new WXAPP_FINGER_REPORT() : {};
|
|
579
579
|
this.wxAppSubsGuider = WXAPP_SUBS_GUIDER;
|
|
580
580
|
this.wxAppAddressV2apiInstance = WXAPP_ADDRESS_V2_API;
|
|
581
581
|
this.lbsAddressCachePromise = null;
|
|
582
582
|
}
|
|
583
583
|
_getConfig(opt) {
|
|
584
584
|
return Object.assign({}, DefaultConfig, opt);
|
|
585
585
|
}
|
|
586
586
|
|
|
587
587
|
taskTimeoutPromise(callBack, timeout = 2000) {
|
|
588
588
|
return new Promise((resolve) => {
|
|
589
589
|
setTimeout(() => {
|
|
590
590
|
const getCallBackRes = typeof callBack === 'function' && callBack();
|
|
591
591
|
return resolve(getCallBackRes || false);
|
|
592
592
|
}, timeout);
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
595
|
|
|
596
596
|
updateBusinessDomainAndApi(domain, api) {
|
|
597
597
|
console.log('=================>', 'updateBusinessDomainAndApi');
|
|
598
598
|
}
|
|
599
599
|
|
|
600
600
|
getFullScreenHeight(systemInfo) {
|
|
601
601
|
const { screenHeight, statusBarHeight, isAndroid } = systemInfo;
|
|
602
602
|
let result = screenHeight;
|
|
603
603
|
if (statusBarHeight > 20 && isAndroid) {
|
|
604
604
|
result = screenHeight + statusBarHeight;
|
|
605
605
|
}
|
|
606
606
|
return result;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
609
|
getTabBarHeight(systemInfo) {
|
|
610
610
|
const { statusBarHeight, isAndroid, isIOS } = systemInfo;
|
|
611
611
|
let result = 50;
|
|
612
612
|
if (statusBarHeight > 20) {
|
|
613
613
|
if (isIOS) {
|
|
614
614
|
result = 84;
|
|
615
615
|
} else if (isAndroid) {
|
|
616
616
|
result = 53;
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
return result;
|
|
620
620
|
}
|
|
621
621
|
|
|
622
622
|
getSystemInfo() {
|
|
623
623
|
const info: UtilsInterFace.taroGetSystemInfoSyncRes = getSystemInfos() || {};
|
|
624
624
|
const actualNavBarHeight = (info?.navBarHeight || 0) + (info?.navBarExtendHeight || 0);
|
|
625
625
|
const headerHeight = actualNavBarHeight + (info?.statusBarHeight || 0);
|
|
626
626
|
const fullScreenHeight = this.getFullScreenHeight(info);
|
|
627
627
|
const tabBarHeight = this.getTabBarHeight(info);
|
|
628
628
|
const safeContentHeight = fullScreenHeight - headerHeight;
|
|
629
629
|
this.info.sysInfo = {
|
|
630
630
|
...this.info.sysInfo,
|
|
631
631
|
...info,
|
|
632
632
|
actualNavBarHeight,
|
|
633
633
|
headerHeight,
|
|
634
634
|
fullScreenHeight,
|
|
635
635
|
tabBarHeight,
|
|
636
636
|
safeContentHeight,
|
|
637
637
|
};
|
|
638
638
|
if (this.info.sysInfo['hostVersionName']) {
|
|
639
639
|
this.info.sysInfo['hostAppVersion'] = Number(
|
|
640
640
|
this.info.sysInfo['hostVersionName'].replace(/\./g, ''),
|
|
641
641
|
);
|
|
642
642
|
}
|
|
643
643
|
if (isPublishToWxapp) {
|
|
644
644
|
this.getAddressCachePromise();
|
|
645
645
|
this.getLbsAddressCachePromise();
|
|
646
646
|
}
|
|
647
647
|
this.info.sysInfo['wifiVideoAutoPlay'] = false;
|
|
648
648
|
this.getNetWorkType();
|
|
649
649
|
console.log('获取系统信息', this.info.sysInfo);
|
|
650
650
|
}
|
|
651
651
|
async updateMPaasConfig() {}
|
|
652
652
|
|
|
653
653
|
getNetWorkType() {
|
|
654
654
|
Taro.getNetworkType().then((getRes) => {
|
|
655
655
|
getRes && getRes.networkType && (this.info.sysInfo['netWorkType'] = getRes.networkType);
|
|
656
656
|
});
|
|
657
657
|
}
|
|
658
658
|
getAPPUseStraightCorner() {
|
|
659
659
|
return Promise.resolve(false);
|
|
660
660
|
}
|
|
661
661
|
|
|
662
662
|
checkStatusAndLogin(options = {}) {
|
|
663
663
|
this.checkStatusAndLoginPromise = new Promise((resolve, reject) => {
|
|
664
664
|
console.log('微信小程序登录状态及获取cookie状态的promise,之前登录状态', this.info.loginState);
|
|
665
665
|
this.toLogin(options)
|
|
666
666
|
.then((res) => {
|
|
667
667
|
console.log('微信小程序登录状态结果,成功', res);
|
|
668
668
|
this.info.loginState = true;
|
|
669
669
|
resolve(res);
|
|
670
670
|
})
|
|
671
671
|
.catch((err) => {
|
|
672
672
|
console.log('微信小程序登录异常状态结果', err);
|
|
673
673
|
this.doLogin(options)
|
|
674
674
|
.then((res2) => {
|
|
675
675
|
console.log('微信小程序wxDoLogin强制登陆成功:', res2);
|
|
676
676
|
this.info.loginState = true;
|
|
677
677
|
resolve(res2);
|
|
678
678
|
})
|
|
679
679
|
.catch((err2) => {
|
|
680
680
|
console.log('微信小程序wxDoLogin强制登陆失败:', err2);
|
|
681
681
|
this.checkStatusAndLoginPromise = null;
|
|
682
682
|
reject(err2);
|
|
683
683
|
});
|
|
684
684
|
});
|
|
685
685
|
});
|
|
686
686
|
return this.checkStatusAndLoginPromise;
|
|
687
687
|
}
|
|
688
688
|
|
|
689
689
|
checkJdStatusAndLogin(
|
|
690
690
|
options = {
|
|
691
691
|
loginColor: {
|
|
692
692
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
693
693
|
dpin: 0,
|
|
694
694
|
},
|
|
695
695
|
},
|
|
696
696
|
) {
|
|
697
697
|
return this.checkStatusAndLogin(options);
|
|
698
698
|
}
|
|
699
699
|
|
|
700
700
|
toLogin(options = {}): Promise<any> {
|
|
701
701
|
return this.wxAppLoginInstance
|
|
702
702
|
.getLoginPromise({
|
|
703
703
|
mode: 'common',
|
|
704
704
|
loginColor: {
|
|
705
705
|
biz: WXAPP_BIZ_KEY,
|
|
706
706
|
dpin: 1,
|
|
707
707
|
},
|
|
708
708
|
...options,
|
|
709
709
|
})
|
|
710
710
|
.then((res) => {
|
|
711
711
|
console.log('微信app登录返回信息,微信侧返回code为0表示成功', res);
|
|
712
712
|
setTimeout(() => {
|
|
713
713
|
console.log(
|
|
714
714
|
'微信app登录返回成功后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie',
|
|
715
715
|
);
|
|
716
716
|
this.getLoginCookie(`${Date.now()}`);
|
|
717
717
|
}, 500);
|
|
718
718
|
})
|
|
719
719
|
.catch((err) => {
|
|
720
720
|
console.log('微信app登录异常返回信息,也获取cookie', err);
|
|
721
721
|
this.getLoginCookie(`${Date.now()}`);
|
|
722
722
|
});
|
|
723
723
|
}
|
|
724
724
|
|
|
725
725
|
doLogin(options = {}) {
|
|
726
726
|
const getParams = {
|
|
727
727
|
loginColor: {
|
|
728
728
|
biz: WXAPP_BIZ_KEY,
|
|
729
729
|
dpin: 1,
|
|
730
730
|
},
|
|
731
731
|
...options,
|
|
732
732
|
};
|
|
733
733
|
if (isPublishToWxapp) {
|
|
734
734
|
getParams['returnUrl'] = `/pages/shopx/pages/index/index?${objectToUrlEncode({
|
|
735
735
|
...this.info.originQueryInfo,
|
|
736
736
|
loadShopxType: 'redirect',
|
|
737
737
|
})}`;
|
|
738
738
|
}
|
|
739
739
|
return this.wxAppLoginInstance.doLogin(getParams).then((res) => {
|
|
740
740
|
console.log('微信小程序强制登录返回信息,微信侧返回code为0表示成功', res);
|
|
741
741
|
setTimeout(() => {
|
|
742
742
|
console.log('微信强制登录后,后台会写入cookie,有延迟,这里延迟500ms去获取最新cookie');
|
|
743
743
|
this.getLoginCookie(`${Date.now()}`);
|
|
744
744
|
}, 500);
|
|
745
745
|
return res;
|
|
746
746
|
});
|
|
747
747
|
}
|
|
748
748
|
|
|
749
749
|
doLoginForJdPin(options = {}) {
|
|
750
750
|
return this.doLogin({
|
|
751
751
|
loginColor: {
|
|
752
752
|
biz: WXAPP_BIZ_SHOP_LIGHT_KEY,
|
|
753
753
|
dpin: 0,
|
|
754
754
|
},
|
|
755
755
|
...options,
|
|
756
756
|
});
|
|
757
757
|
}
|
|
758
758
|
|
|
759
759
|
getLoginCookie(updateKey = 'wxapp') {
|
|
760
760
|
return new Promise(async (resolve) => {
|
|
761
761
|
console.log('开始获取更新wxapp中的cookie信息', updateKey);
|
|
762
762
|
if (
|
|
763
763
|
this.config.wqCookie &&
|
|
764
764
|
this.config.wqCookieStr &&
|
|
765
765
|
this.config.getWqCookieKey === updateKey
|
|
766
766
|
) {
|
|
767
767
|
console.log('已有存储wxapp中的cookie信息,直接返回', this.config);
|
|
768
768
|
resolve({
|
|
769
769
|
wqCookie: this.config.wqCookie,
|
|
770
770
|
wqCookieStr: this.config.wqCookieStr,
|
|
771
771
|
});
|
|
772
772
|
} else {
|
|
773
773
|
if (isPublishToWxapp) {
|
|
774
774
|
const getWxappCookieObj = getTaroStorageKeyValue('cookies') || null;
|
|
775
775
|
if (getWxappCookieObj) {
|
|
776
776
|
const getCookieObj = getWxappCookieObj['_data'];
|
|
777
777
|
const { wqCookie, wqCookieStr } = getWxAppCookieStr(getCookieObj);
|
|
778
778
|
const { pin = '', visitkey = '-1', wq_unionid = '', wxapp_openid = '' } = wqCookie;
|
|
779
779
|
this.info.loginState = true;
|
|
780
780
|
this.info.userInfo.wqCookie = wqCookieStr;
|
|
781
781
|
this.info.userInfo.wqVisitkey = visitkey;
|
|
782
782
|
console.log('获取用户完整cookie信息', getCookieObj);
|
|
783
783
|
if (this.miniAppLogInstance) {
|
|
784
784
|
this.miniAppLogInstance.set({
|
|
785
785
|
account: pin,
|
|
786
786
|
unionid: wq_unionid,
|
|
787
787
|
openid: wxapp_openid,
|
|
788
788
|
});
|
|
789
789
|
}
|
|
790
790
|
this.config.wqCookie = wqCookie;
|
|
791
791
|
this.config.wqCookieStr = wqCookieStr;
|
|
792
792
|
this.config.getWqCookieKey = updateKey;
|
|
793
793
|
console.log('解析wxapp中的cookie信息成功,返回后存储', this.config);
|
|
794
794
|
resolve({
|
|
795
795
|
wqCookie,
|
|
796
796
|
wqCookieStr,
|
|
797
797
|
});
|
|
798
798
|
} else {
|
|
799
799
|
console.log('解析wxapp中的cookie信息异常,返回异常结果', this.config);
|
|
800
800
|
resolve({
|
|
801
801
|
wqCookie: false,
|
|
802
802
|
wqCookieStr: false,
|
|
803
803
|
});
|
|
804
804
|
}
|
|
805
805
|
} else {
|
|
806
806
|
resolve({
|
|
807
807
|
wqCookie: false,
|
|
808
808
|
wqCookieStr: false,
|
|
809
809
|
});
|
|
810
810
|
}
|
|
811
811
|
}
|
|
812
812
|
});
|
|
813
813
|
}
|
|
814
814
|
|
|
815
815
|
|
|
816
816
|
checkLoginStatus() {
|
|
817
817
|
return this.getLoginCookie();
|
|
818
818
|
}
|
|
819
819
|
|
|
820
820
|
getAddressCachePromise = () => {
|
|
821
821
|
return new Promise((resolve) => {
|
|
822
822
|
if (this.info.sysInfo?.area) {
|
|
823
823
|
resolve({
|
|
824
824
|
lat: this.info.sysInfo?.lat,
|
|
825
825
|
lng: this.info.sysInfo?.lng,
|
|
826
826
|
area: this.info.sysInfo?.area,
|
|
827
827
|
});
|
|
828
828
|
} else {
|
|
829
829
|
const getUserAddress = this.wxAppUserInfoInstance.getAddress();
|
|
830
830
|
console.info('京购原生获取用户基地址信息', getUserAddress);
|
|
831
831
|
if (getUserAddress) {
|
|
832
832
|
const { areaId = '', latitude, longitude } = getUserAddress;
|
|
833
833
|
this.info.sysInfo['lat'] = `${latitude || ''}`;
|
|
834
834
|
this.info.sysInfo['lng'] = `${longitude || ''}`;
|
|
835
835
|
if (areaId && areaId !== '') {
|
|
836
836
|
this.info.pageInfo.address = areaId;
|
|
837
837
|
this.info.pageInfo.addressCommaStr = areaId.replace(/_/g, ',');
|
|
838
838
|
this.info.pageInfo.un_area = areaId;
|
|
839
839
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
840
840
|
area: areaId,
|
|
841
841
|
});
|
|
842
842
|
this.info.sysInfo['area'] = areaId;
|
|
843
843
|
}
|
|
844
844
|
resolve({
|
|
845
845
|
lat: this.info.sysInfo['lat'],
|
|
846
846
|
lng: this.info.sysInfo['lng'],
|
|
847
847
|
area: areaId,
|
|
848
848
|
});
|
|
849
849
|
} else {
|
|
850
850
|
resolve({ lat: '', lng: '', area: '' });
|
|
851
851
|
}
|
|
852
852
|
}
|
|
853
853
|
});
|
|
854
854
|
};
|
|
855
855
|
|
|
856
856
|
getLbsAddressCachePromise(): Promise<{
|
|
857
857
|
ok: boolean;
|
|
858
858
|
msg?: string;
|
|
859
859
|
realTimeArea: string;
|
|
860
860
|
data?: any;
|
|
861
861
|
}> {
|
|
862
862
|
if (!this.lbsAddressCachePromise) {
|
|
863
863
|
this.lbsAddressCachePromise = new Promise((resolve) => {
|
|
864
864
|
const getWxappLbsAddressInfo = this.wxAppUserInfoInstance.getLbsAddress();
|
|
865
865
|
console.info('京购原生获取用户基于lbs的缓存地址信息', getWxappLbsAddressInfo);
|
|
866
866
|
if (getWxappLbsAddressInfo && getWxappLbsAddressInfo?.areaId !== '') {
|
|
867
867
|
this.info.pageInfo.userLbsAddress = getWxappLbsAddressInfo?.areaId;
|
|
868
868
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
869
869
|
realTimeArea: this.info.pageInfo.userLbsAddress,
|
|
870
870
|
});
|
|
871
871
|
resolve({
|
|
872
872
|
ok: true,
|
|
873
873
|
realTimeArea: getWxappLbsAddressInfo?.areaId || '',
|
|
874
874
|
});
|
|
875
875
|
} else {
|
|
876
876
|
this.wxAppAddressV2apiInstance
|
|
877
877
|
.fetchLbsAddr({
|
|
878
878
|
token: 'W23b9sUlcnhCPZxQ2daYMkDqrTL0TeDw9tbDm5lVMVA=',
|
|
879
879
|
from: 'wxapp_shop_real_area',
|
|
880
880
|
})
|
|
881
881
|
.then((res) => {
|
|
882
882
|
console.info('微信京购里面获取静默实时lbs地址信息结果', res);
|
|
883
883
|
const { provinceId, cityId, countyId, townId } = res;
|
|
884
884
|
let realTimeArea = '';
|
|
885
885
|
if (provinceId) {
|
|
886
886
|
realTimeArea = `${provinceId}_${cityId || 0}_${countyId || 0}_${townId || 0}`;
|
|
887
887
|
this.info.pageInfo.userLbsAddress = realTimeArea;
|
|
888
888
|
Taro.eventCenter.trigger(TaroEventType.USER_AREA_UPDATE, {
|
|
889
889
|
realTimeArea: realTimeArea,
|
|
890
890
|
});
|
|
891
891
|
} else {
|
|
892
892
|
this.lbsAddressCachePromise = null;
|
|
893
893
|
}
|
|
894
894
|
const getValidRealTimeArea = realTimeArea !== '';
|
|
895
895
|
resolve({
|
|
896
896
|
ok: getValidRealTimeArea,
|
|
897
897
|
msg: getValidRealTimeArea
|
|
898
898
|
? '成功'
|
|
899
899
|
: '根据微信底层接口获取静默实时lbs地址信息异常,详情见data',
|
|
900
900
|
data: getValidRealTimeArea ? null : res,
|
|
901
901
|
realTimeArea: realTimeArea,
|
|
902
902
|
});
|
|
903
903
|
})
|
|
904
904
|
.catch((err) => {
|
|
905
905
|
console.warn('微信京购里面获取静默实时lbs地址信息异常', err);
|
|
906
906
|
this.lbsAddressCachePromise = null;
|
|
907
907
|
resolve({
|
|
908
908
|
ok: false,
|
|
909
909
|
msg: '微信京购里面获取静默实时lbs地址信息异常',
|
|
910
910
|
realTimeArea: '',
|
|
911
911
|
});
|
|
912
912
|
});
|
|
913
913
|
}
|
|
914
914
|
});
|
|
915
915
|
}
|
|
916
916
|
return this.lbsAddressCachePromise;
|
|
917
917
|
}
|
|
918
918
|
|
|
919
919
|
updatePageAndLogInfo(updateQuery = {}) {
|
|
920
920
|
const createUpdateQueryInfo: {
|
|
921
921
|
query: {
|
|
922
922
|
shopId?: string | number;
|
|
923
923
|
venderId?: string | number;
|
|
924
924
|
};
|
|
925
925
|
updateShopInfoState: boolean;
|
|
926
926
|
} = Object.assign(
|
|
927
927
|
{},
|
|
928
928
|
{
|
|
929
929
|
query: {},
|
|
930
930
|
updateShopInfoState: false,
|
|
931
931
|
},
|
|
932
932
|
updateQuery,
|
|
933
933
|
);
|
|
934
934
|
console.log(
|
|
935
935
|
'获取当前下发的店铺查询参数',
|
|
936
936
|
updateQuery,
|
|
937
937
|
'获取之前保存的shopInfo店铺查询参数',
|
|
938
938
|
this.info?.shopInfo,
|
|
939
939
|
);
|
|
940
940
|
const { query, updateShopInfoState } = createUpdateQueryInfo;
|
|
941
941
|
const { shopId, venderId } = query;
|
|
942
942
|
if (updateShopInfoState) {
|
|
943
943
|
this.info.queryInfo = {
|
|
944
944
|
...this.info.queryInfo,
|
|
945
945
|
...query,
|
|
946
946
|
};
|
|
947
947
|
if (shopId && venderId) {
|
|
948
948
|
this.info.shopInfo = {
|
|
949
949
|
shopId: `${shopId}`,
|
|
950
950
|
venderId: `${venderId}`,
|
|
951
951
|
};
|
|
952
952
|
}
|
|
953
953
|
} else {
|
|
954
954
|
this.info.queryInfo = {
|
|
955
955
|
...query,
|
|
956
956
|
};
|
|
957
957
|
this.info.originQueryInfo = {
|
|
958
958
|
...query,
|
|
959
959
|
};
|
|
960
960
|
if (
|
|
961
961
|
this.info.shopInfo?.shopId &&
|
|
962
962
|
this.info.shopInfo?.venderId &&
|
|
963
963
|
(this.info.shopInfo.shopId == shopId || this.info.shopInfo.venderId == venderId)
|
|
964
964
|
) {
|
|
965
965
|
this.info.queryInfo.shopId = this.info.shopInfo.shopId;
|
|
966
966
|
this.info.queryInfo.venderId = this.info.shopInfo.venderId;
|
|
967
967
|
console.log(
|
|
968
968
|
'当前存储的店铺shopId和venderId与下发的店铺信息shopId或者venderId为同一个,补充shopId或者venderId查询参数',
|
|
969
969
|
this.info.queryInfo,
|
|
970
970
|
);
|
|
971
971
|
}
|
|
972
972
|
}
|
|
973
973
|
this.info.queryInfo['shopId'] &&
|
|
974
974
|
(this.info.queryInfo['shopId'] = `${this.info.queryInfo['shopId']}`);
|
|
975
975
|
this.info.queryInfo['venderId'] &&
|
|
976
976
|
(this.info.queryInfo['venderId'] = `${this.info.queryInfo['venderId']}`);
|
|
977
977
|
console.log(
|
|
978
978
|
'weapp===获取店铺下发查询参数\n',
|
|
979
979
|
query,
|
|
980
980
|
'\n获取店铺最后查询参数\n',
|
|
981
981
|
this.info.queryInfo,
|
|
982
982
|
'\n是否为更新店铺状态\n',
|
|
983
983
|
updateShopInfoState,
|
|
984
984
|
);
|
|
985
985
|
}
|
|
986
986
|
|
|
987
987
|
getDynamicConfig(key: string) {
|
|
988
988
|
console.warn('调用微信小程序的 getDynamicConfig(),注意,此方法还未实现!');
|
|
989
989
|
return null;
|
|
990
990
|
}
|
|
991
991
|
renderNextTickLoadSdk() {
|
|
992
992
|
console.warn('暂未实现 index.weapp.ts');
|
|
993
993
|
}
|
|
994
994
|
loadOtherSdk() {
|
|
995
995
|
console.warn('暂未实现 index.weapp.ts');
|
|
996
996
|
}
|
|
997
997
|
loadItemSdkPromise() {
|
|
998
998
|
console.warn('暂未实现 index.weapp.ts');
|
|
999
999
|
}
|