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