@conecli/cone-render 0.9.1-shop2.0 → 0.9.1-shop2.2
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/index.h5.ts +1 -1
- package/dist/components/base/CommonFloorHead/index.tsx +1 -1
- package/dist/components/floorItem.tsx +1 -1
- package/dist/components/isv/Floor/index.tsx +1 -1
- package/dist/components/remoteFloorItem.tsx +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/index.h5.ts +1 -1
- package/dist/jumpEventReport/jumpUrlConfig/base.ts +1 -1
- package/dist/jumpEventReport/web.base.ts +1 -1
- package/dist/jumpEventReport/web.pc.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/taroRenderUtil.ts +1 -1
- package/dist/utils/utils.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import global from '../common'
|
|
2
|
BUSINESS_TYPE,
|
|
1
3
|
SHOP_MENU_ID_TYPE,
|
|
2
4
|
SHOP_MENU_ID_NAME,
|
|
3
5
|
SECTION_HOME_TAB_TYPE,
|
|
4
6
|
SECTION_HOME_TAB_NAME_TYPE,
|
|
5
7
|
objectToUrlEncode,
|
|
6
8
|
parseQueryUrlString,
|
|
7
9
|
filterUrlQueryData,
|
|
8
10
|
routerInfo: {
|
|
9
11
|
params: {},
|
|
10
12
|
},
|
|
11
13
|
nativeEvent: null,
|
|
12
14
|
jumpConfig: {
|
|
13
15
|
venderId: null,
|
|
14
16
|
shopId: null,
|
|
15
17
|
sourceValue: '',
|
|
16
18
|
sourceType: 'M-H5',
|
|
17
19
|
activityType: 'shopx',
|
|
18
20
|
moduleId: 'none',
|
|
19
21
|
entrance: 'none',
|
|
20
22
|
},
|
|
21
23
|
logPageParamStr: '',
|
|
22
24
|
public logPageId: string
|
|
23
25
|
public jumpConfig: JumpEventReportInterFace.JumpH5ReportConfig
|
|
24
26
|
getConfig(opt) {
|
|
25
27
|
return Object.assign(this, {}, defaultConfig, opt)
|
|
26
28
|
}
|
|
27
29
|
updateInfo(
|
|
28
30
|
routerInfo,
|
|
29
31
|
logPname = LogPnameInfo.HOME,
|
|
30
32
|
pageId = LogPageIdInfo.APP,
|
|
31
33
|
) {
|
|
32
34
|
this.routerInfo = routerInfo
|
|
33
35
|
this.logPname = logPname
|
|
34
36
|
this.jumpConfig = Object.assign(
|
|
35
37
|
{},
|
|
36
38
|
this.jumpConfig,
|
|
37
39
|
filterUrlQueryData(routerInfo?.params || {}),
|
|
38
40
|
)
|
|
39
41
|
this.logPageId = pageId
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
jdJumpToProduct(skuIds, logEventInfo) {
|
|
43
45
|
skuIds = skuIds.toString().trim()
|
|
44
46
|
const getSkuId = skuIds.indexOf(',') !== -1 ? skuIds.split(',')[0] : skuIds
|
|
45
47
|
let url = `${this.jumpWebUrl.pcDetail}${getSkuId}.html`
|
|
46
48
|
this.jdNavigateToNative(url, logEventInfo)
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
jdJumpToShopHome(shopInfo: JumpEventReportInterFace.ShopIdsInfo = {}) {
|
|
50
52
|
const getInfo = Object.assign(
|
|
51
53
|
{},
|
|
52
54
|
{
|
|
53
55
|
shopId: global.info.queryInfo.shopId,
|
|
54
56
|
venderId: global.info.queryInfo.venderId,
|
|
55
57
|
},
|
|
56
58
|
shopInfo,
|
|
57
59
|
)
|
|
58
60
|
let url = `${this.jumpWebUrl.pages}/index-${global.info.queryInfo.shopId}.html`
|
|
59
61
|
this.jdNavigateToNative(url, {
|
|
60
62
|
...getInfo,
|
|
61
63
|
})
|
|
62
64
|
}
|
|
63
65
|
|
|
64
66
|
getPcSearchUrl = (cateId) => {
|
|
65
67
|
const flag = document.querySelector('#JSHOP_CHANNEL_FLAG')?.value
|
|
66
68
|
const appId =
|
|
67
69
|
document.querySelector('#J_AppId')?.value ||
|
|
68
70
|
document.querySelector('#pageInstance_appId')?.value
|
|
69
71
|
return flag === 'yao'
|
|
70
72
|
? this.jumpWebUrl.pages + '/view_shop_search-' + appId + '.html'
|
|
71
73
|
: this.jumpWebUrl.pages +
|
|
72
74
|
'/view_search-' +
|
|
73
75
|
appId +
|
|
74
76
|
'-' +
|
|
75
77
|
cateId +
|
|
76
78
|
'-99-1-20-1.html'
|
|
77
79
|
}
|
|
78
80
|
|
|
79
81
|
jdJumpToShopSearch(shopInfo) {
|
|
80
82
|
const getInfo = Object.assign(
|
|
81
83
|
{},
|
|
82
84
|
{
|
|
83
85
|
shopId: global.info.queryInfo.shopId,
|
|
84
86
|
venderId: global.info.queryInfo.venderId,
|
|
85
87
|
},
|
|
86
88
|
shopInfo,
|
|
87
89
|
)
|
|
88
90
|
const { categoryId } = getInfo
|
|
89
91
|
const url = `${this.getPcSearchUrl(categoryId)}`
|
|
90
92
|
this.jdJumpToWeb(url, getInfo)
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
jdJumpToTabAllProduct(shopId, venderId, logEventInfo = {}) {
|
|
94
96
|
console.log('web.base.ts - jdJumpToTabAllProduct')
|
|
95
97
|
if (typeof shopId === 'undefined') shopId = global.info.queryInfo.shopId
|
|
96
98
|
if (typeof venderId === 'undefined')
|
|
97
99
|
venderId = global.info.queryInfo.venderId
|
|
98
100
|
const url = `${this.jumpWebUrl.pages}/index-${shopId}.html`
|
|
99
101
|
this.jdJumpToWeb(url, logEventInfo)
|
|
100
102
|
}
|
|
101
103
|
|
|
102
104
|
jdJumpToCouponSearchProductList(couponId, logEventInfo = {}) {
|
|
103
105
|
const url = `${this.jumpWebUrl.couponSearch}?couponbatch=${couponId}&sceneval=2`
|
|
104
106
|
this.jdJumpToWeb(url, logEventInfo)
|
|
105
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import Taro from '@tarojs/taro'
|
|
2
1
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
|
|
3
2
|
displayHeight: 1920,
|
|
4
3
|
offSetY: 0
|
|
5
4
|
}
|
|
6
5
|
console.log('>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:', Date.now(), 'res:', options)
|
|
7
6
|
if(options){
|
|
8
7
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
|
|
9
8
|
}
|
|
10
9
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
11
10
|
const { shopHomeExtendInfo } = options
|
|
12
11
|
if(shopHomeExtendInfo) {
|
|
13
12
|
Taro.eventCenter.trigger(TaroEventType.UPDATE_SHOP_HOME_EXTEND_DATA,shopHomeExtendInfo)
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
window && window.scrollTo(0, 0);
|
|
17
16
|
}
|
|
18
17
|
PAGE_PV_PARAM: 'pagePvParam',
|
|
19
18
|
NATIVE_SCORLL_VIEW: 'nativeScrollControl',
|
|
20
19
|
NATIVE_PUSH_NATIVE_PAGE: 'pushNativePage',
|
|
21
20
|
UPDATE_NATIVE_DATA: 'updateNativeData',
|
|
22
21
|
H5_TO_SCROLL_TOP: 'h5ToScrollTop',
|
|
23
22
|
OPEN: 'open',
|
|
24
23
|
newHomePage: true,
|
|
25
24
|
case Message_Type.UPDATE_NATIVE_DATA:
|
|
26
25
|
console.log('接收到原生通知 UPDATE_NATIVE_DATA',messageData)
|
|
27
26
|
console.log('接收到原生通知 UPDATE_NATIVE_DATA getSendJsonData',getSendJsonData)
|
|
28
27
|
taroEventUpdateNativeData(getSendJsonData)
|
|
29
28
|
break;
|
|
30
29
|
case Message_Type.H5_TO_SCROLL_TOP:
|
|
31
30
|
taroEventH5ToScrollTop()
|
|
32
31
|
nativePageRegisterMessage(Message_Type.NATIVE_PUSH_NATIVE_PAGE, {
|
|
33
32
|
data: params,
|
|
34
33
|
})
|
|
35
34
|
const { displayHeight, offSetY } = res
|
|
36
35
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined') return
|
|
37
36
|
if (isIosDevice) return res
|
|
38
37
|
if (isAndroidDevice) {
|
|
39
38
|
const deviceRatio = window.devicePixelRatio
|
|
40
39
|
const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
|
|
41
40
|
const cssOffsetY = Math.ceil(offSetY / deviceRatio)
|
|
42
41
|
return {
|
|
43
42
|
displayHeight: cssDisplayHeight,
|
|
44
43
|
offSetY: cssOffsetY
|
|
45
44
|
}
|
|
46
45
|
}
|
|
46
|
+
import Taro from '@tarojs/taro'
|
|
47
47
|
isH5AndJdShopView,
|
|
48
48
|
isJdApp,
|
|
49
49
|
isIosDevice,
|
|
50
50
|
isAndroidDevice,
|
|
51
51
|
isJdAndAndroidDevice,
|
|
52
52
|
(window.JDJshopViewInfo = {
|
|
53
53
|
androidTouchSlop: 5,
|
|
54
54
|
getAndroidTouchSlopState: false,
|
|
55
55
|
})
|
|
56
56
|
if (!isJdApp) {
|
|
57
57
|
if (isH5) {
|
|
58
58
|
|
|
59
59
|
const documentHandleVisibilityChange = () => {
|
|
60
60
|
const state = document.hidden
|
|
61
61
|
console.log(
|
|
62
62
|
'浏览器document.hidden状态,是否可以开始下发window.startDocumentVisibilityChange,可见性下发同步1-可见,0-不可见',
|
|
63
63
|
state,
|
|
64
64
|
window.startDocumentVisibilityChange,
|
|
65
65
|
state ? 0 : 1,
|
|
66
66
|
)
|
|
67
67
|
window.startDocumentVisibilityChange &&
|
|
68
68
|
Taro.eventCenter.trigger(
|
|
69
69
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
70
70
|
state ? 0 : 1,
|
|
71
71
|
)
|
|
72
72
|
}
|
|
73
73
|
document.removeEventListener(
|
|
74
74
|
'visibilitychange',
|
|
75
75
|
documentHandleVisibilityChange,
|
|
76
76
|
)
|
|
77
77
|
console.log('每次进入页面先清除浏览器visibilitychange监听事件')
|
|
78
78
|
setTimeout(() => {
|
|
79
79
|
document.addEventListener(
|
|
80
80
|
'visibilitychange',
|
|
81
81
|
documentHandleVisibilityChange,
|
|
82
82
|
false,
|
|
83
83
|
)
|
|
84
84
|
window.startDocumentVisibilityChange = true
|
|
85
85
|
}, 3000)
|
|
86
86
|
}
|
|
87
87
|
} else {
|
|
88
88
|
|
|
89
89
|
!window.webviewVisible &&
|
|
90
90
|
(window.webviewVisible = (state) => {
|
|
91
91
|
console.log(
|
|
92
92
|
'IOS Android 获取原生可见性下发,是否可以开始下发window.startDocumentVisibilityChange,1-可见,0-不可见',
|
|
93
93
|
window.startDocumentVisibilityChange,
|
|
94
94
|
state,
|
|
95
95
|
)
|
|
96
96
|
window.startDocumentVisibilityChange &&
|
|
97
97
|
Taro.eventCenter.trigger(
|
|
98
98
|
TaroEventType.PAGE_DOCUMENT_VISIBILITY_CHANGE,
|
|
99
99
|
state,
|
|
100
100
|
)
|
|
101
101
|
state === 1 && taroEventSendPageScrollInfo()
|
|
102
102
|
})
|
|
103
103
|
setTimeout(() => {
|
|
104
104
|
window.startDocumentVisibilityChange = true
|
|
105
105
|
}, 3000)
|
|
106
106
|
!window.floatReceiveData && (window.floatReceiveData = () => {})
|
|
107
107
|
}
|
|
108
108
|
MESSAGE_HOME_INIT: 'messageHomeInitPageData',
|
|
109
109
|
[Message_CallBack_Name.MESSAGE_HOME_INIT]: {},
|
|
110
110
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = {
|
|
111
111
|
displayHeight: 1920,
|
|
112
112
|
offSetY: 0,
|
|
113
113
|
}
|
|
114
114
|
console.log(
|
|
115
115
|
'>>>>>>>>>>>>>>>>>>> render taroEventSendPageScrollInfo origin time:',
|
|
116
116
|
Date.now(),
|
|
117
117
|
'res:',
|
|
118
118
|
options,
|
|
119
119
|
)
|
|
120
120
|
if (options) {
|
|
121
121
|
latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] = options
|
|
122
122
|
}
|
|
123
123
|
const latestRes = latestFromNativeMsgStorage[TaroEventType.PAGE_SCROLL] || {}
|
|
124
124
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL, options || latestRes)
|
|
125
125
|
console.log('PageScrollEnd fire')
|
|
126
126
|
Taro.eventCenter.trigger(TaroEventType.PAGE_SCROLL_END, options)
|
|
127
127
|
const { businessType } = options
|
|
128
128
|
switch (businessType) {
|
|
129
129
|
case H5_MSG_TO_H5_BUSINESSTYPE.JOIN_MEMBER_SUCCESS:
|
|
130
130
|
Taro.eventCenter.trigger(TaroEventType.JOIN_MEMBER_SUCCESS, options)
|
|
131
131
|
break
|
|
132
132
|
default:
|
|
133
133
|
break
|
|
134
134
|
}
|
|
135
135
|
const { shopHomeExtendInfo } = options
|
|
136
136
|
if (shopHomeExtendInfo) {
|
|
137
137
|
Taro.eventCenter.trigger(
|
|
138
138
|
TaroEventType.UPDATE_SHOP_HOME_EXTEND_DATA,
|
|
139
139
|
shopHomeExtendInfo,
|
|
140
140
|
)
|
|
141
141
|
}
|
|
142
142
|
window && window.scrollTo(0, 0)
|
|
143
143
|
Taro.eventCenter.trigger(TaroEventType.PAGE_INIT_EXPOSURE, options)
|
|
144
144
|
NATIVE_PAGE_READ: 'pageReady',
|
|
145
145
|
NATIVE_PAGE_FINISH: 'pageFinish',
|
|
146
146
|
NATIVE_INFO_DATA: 'nativeInfoData',
|
|
147
147
|
NATIVE_PAGE_SCROLL: 'pageScroll',
|
|
148
148
|
NATIVE_PAGE_SCROLL_END: 'pageScrollEnd',
|
|
149
149
|
NATIVE_GET_SCROLL_TOP: 'nativeGetScrollTop',
|
|
150
150
|
NATIVE_TO_SCROLL_TOP: 'nativeToScrollTop',
|
|
151
151
|
NATIVE_CLOSE_SCROLL_MESSAGE: 'nativeCloseScrollMessage',
|
|
152
152
|
NATIVE_SHOW_TOAST: 'showToast',
|
|
153
153
|
NATIVE_SHOW_DIALOG: 'showDialog',
|
|
154
154
|
NATIVE_PAGE_LAYOUT_CHANGE: 'pageLayoutChange',
|
|
155
155
|
NATIVE_HOME_PAGING_ENABLE: 'homePagingEnable',
|
|
156
156
|
NATIVE_GET_SCALED_TOUCH_SLOP: 'getScaledTouchSlop',
|
|
157
157
|
NATIVE_ADD_CART: 'addCart',
|
|
158
158
|
NATIVE_OPEN_FLOAT: 'openFloat',
|
|
159
159
|
NATIVE_INJECT_JS_FILE: 'needIsvPackage',
|
|
160
160
|
NAVTIVE_FLOAT_READY: 'floatReady',
|
|
161
161
|
NATIVE_REFRESH_PAGE: 'refreshPage',
|
|
162
162
|
PAGE_PV_PARAM: 'pagePvParam',
|
|
163
163
|
NATIVE_SCORLL_VIEW: 'nativeScrollControl',
|
|
164
164
|
NATIVE_POP_WEBVIEW: 'popWebview',
|
|
165
165
|
NATIVE_H5_SEND_MSG_TO_H5: 'h5SendMsgToH5',
|
|
166
166
|
NATIVE_PUSH_NATIVE_PAGE: 'pushNativePage',
|
|
167
167
|
UPDATE_NATIVE_DATA: 'updateNativeData',
|
|
168
168
|
H5_TO_SCROLL_TOP: 'h5ToScrollTop',
|
|
169
169
|
OPEN: 'open',
|
|
170
170
|
CLOSE: 'close',
|
|
171
171
|
JOIN_MEMBER_SUCCESS: 'joinMemberSuccess',
|
|
172
172
|
type = Message_Type.NATIVE_PAGE_READ,
|
|
173
173
|
sendData: null | object = null,
|
|
174
174
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
175
175
|
console.log(
|
|
176
176
|
'初始化nativePageRegisterMessage-type-sendData-isJdApp-isH5AndJdShopView',
|
|
177
177
|
type,
|
|
178
178
|
sendData,
|
|
179
179
|
isJdApp,
|
|
180
180
|
isH5AndJdShopView,
|
|
181
181
|
)
|
|
182
182
|
if (isJdApp && isH5AndJdShopView) {
|
|
183
183
|
const getCallBackName = `window.${callBackName}`
|
|
184
184
|
let getRouterParam = {
|
|
185
185
|
type,
|
|
186
186
|
callBackName: getCallBackName,
|
|
187
187
|
newHomePage: true,
|
|
188
188
|
}
|
|
189
189
|
if (sendData) {
|
|
190
190
|
getRouterParam = Object.assign({}, getRouterParam, sendData)
|
|
191
191
|
}
|
|
192
192
|
isIosDevice &&
|
|
193
193
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
194
194
|
method: 'callRouterModuleWithParams',
|
|
195
195
|
params: {
|
|
196
196
|
routerURL: 'router://JDShopModule/wrtNative',
|
|
197
197
|
routerParam: JSON.stringify(getRouterParam),
|
|
198
198
|
callBackName: getCallBackName,
|
|
199
199
|
callBackId: `${callBackName}Ios`,
|
|
200
200
|
},
|
|
201
201
|
})
|
|
202
202
|
isAndroidDevice &&
|
|
203
203
|
window?.JDJshop?.wrtNative(
|
|
204
204
|
JSON.stringify({
|
|
205
205
|
routerParam: JSON.stringify(getRouterParam),
|
|
206
206
|
callBackName: getCallBackName,
|
|
207
207
|
callBackId: `${callBackName}Android`,
|
|
208
208
|
}),
|
|
209
209
|
)
|
|
210
210
|
return true
|
|
211
211
|
}
|
|
212
212
|
return false
|
|
213
213
|
console.log(
|
|
214
214
|
'closeXView, isJdApp:',
|
|
215
215
|
isJdApp,
|
|
216
216
|
',isH5AndJdShopView:',
|
|
217
217
|
isH5AndJdShopView,
|
|
218
218
|
',isIosDevice:',
|
|
219
219
|
isIosDevice,
|
|
220
220
|
',isAndroidDevice:',
|
|
221
221
|
isAndroidDevice,
|
|
222
222
|
)
|
|
223
223
|
if (isJdApp && isH5AndJdShopView) {
|
|
224
224
|
if (isIosDevice) {
|
|
225
225
|
window?.webkit?.messageHandlers?.MobileNavi?.postMessage({
|
|
226
226
|
method: 'close',
|
|
227
227
|
})
|
|
228
228
|
} else if (isAndroidDevice) {
|
|
229
229
|
window?.XView && window?.XView.close()
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
callBack &&
|
|
233
233
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
234
234
|
Message_Type.NATIVE_INFO_DATA
|
|
235
235
|
] = callBack)
|
|
236
236
|
console.log(`nativePageLoadReady:${JSON.stringify(sendData)}`)
|
|
237
237
|
nativePageRegisterMessage(
|
|
238
238
|
Message_Type.NATIVE_PAGE_READ,
|
|
239
239
|
sendData,
|
|
240
240
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
241
241
|
)
|
|
242
242
|
console.log('通信原始数据', sendData)
|
|
243
243
|
return nativePageGetMessageInitCallBack()
|
|
244
244
|
return nativePageRegisterMessage(
|
|
245
245
|
Message_Type.NATIVE_PAGE_FINISH,
|
|
246
246
|
null,
|
|
247
247
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
248
248
|
)
|
|
249
249
|
callBack &&
|
|
250
250
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
251
251
|
Message_Type.NATIVE_GET_SCROLL_TOP
|
|
252
252
|
] = callBack)
|
|
253
253
|
return nativePageRegisterMessage(
|
|
254
254
|
Message_Type.NATIVE_GET_SCROLL_TOP,
|
|
255
255
|
null,
|
|
256
256
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
257
257
|
)
|
|
258
258
|
callBack &&
|
|
259
259
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
260
260
|
Message_Type.NATIVE_TO_SCROLL_TOP
|
|
261
261
|
] = callBack)
|
|
262
262
|
nativePageRegisterMessage(
|
|
263
263
|
Message_Type.NATIVE_TO_SCROLL_TOP,
|
|
264
264
|
{
|
|
265
265
|
data: {
|
|
266
266
|
scrollTop,
|
|
267
267
|
},
|
|
268
268
|
},
|
|
269
269
|
Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
270
270
|
)
|
|
271
271
|
nativePageRegisterMessage(Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE)
|
|
272
272
|
if (isJdAndAndroidDevice) {
|
|
273
273
|
callBack &&
|
|
274
274
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
275
275
|
Message_Type.NATIVE_HOME_PAGING_ENABLE
|
|
276
276
|
] = callBack)
|
|
277
277
|
nativePageRegisterMessage(Message_Type.NATIVE_HOME_PAGING_ENABLE, {
|
|
278
278
|
data: {
|
|
279
279
|
enable: enable,
|
|
280
280
|
},
|
|
281
281
|
})
|
|
282
282
|
}
|
|
283
283
|
if (isJdAndAndroidDevice) {
|
|
284
284
|
callBack &&
|
|
285
285
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
286
286
|
Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP
|
|
287
287
|
] = callBack)
|
|
288
288
|
nativePageRegisterMessage(Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP)
|
|
289
289
|
}
|
|
290
290
|
SUCCESS: 'success',
|
|
291
291
|
FAIL: 'fail',
|
|
292
292
|
NORMAL: 'normal',
|
|
293
293
|
SUCCESS: 2,
|
|
294
294
|
FAIL: 3,
|
|
295
295
|
NORMAL: 1,
|
|
296
296
|
SUCCESS: 2,
|
|
297
297
|
FAIL: 3,
|
|
298
298
|
NORMAL: 1,
|
|
299
299
|
nativePageRegisterMessage(Message_Type.NATIVE_SHOW_TOAST, {
|
|
300
300
|
data: {
|
|
301
301
|
message: title,
|
|
302
302
|
iconType: showType,
|
|
303
303
|
duration,
|
|
304
304
|
},
|
|
305
305
|
})
|
|
306
306
|
console.log('showToastByRouter:', title, showType)
|
|
307
307
|
if (isJdApp && isH5AndJdShopView) {
|
|
308
308
|
const routerParam = {
|
|
309
309
|
message: title,
|
|
310
310
|
iconType: showType,
|
|
311
311
|
duration,
|
|
312
312
|
}
|
|
313
313
|
if (isIosDevice) {
|
|
314
314
|
callRouterIOS({
|
|
315
315
|
routerURL: 'router://JDShopModule/showToast',
|
|
316
316
|
routerParam,
|
|
317
317
|
})
|
|
318
318
|
} else if (isAndroidDevice) {
|
|
319
319
|
callRouterAndroid({
|
|
320
320
|
routerURL: 'router://JDJShopModule/showToast',
|
|
321
321
|
routerParam,
|
|
322
322
|
})
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
routerURL,
|
|
326
326
|
routerParam,
|
|
327
327
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
328
328
|
console.log(
|
|
329
329
|
'callRouterIOS routerURL:',
|
|
330
330
|
routerURL,
|
|
331
331
|
',routerParam:',
|
|
332
332
|
routerParam,
|
|
333
333
|
)
|
|
334
334
|
const getCallBackName = `window.${callBackName}`
|
|
335
335
|
const params = {
|
|
336
336
|
routerURL,
|
|
337
337
|
routerParam,
|
|
338
338
|
callBackName: getCallBackName,
|
|
339
339
|
callBackId: `${callBackName}Ios`,
|
|
340
340
|
}
|
|
341
341
|
window?.webkit?.messageHandlers?.JDAppUnite?.postMessage({
|
|
342
342
|
method: 'callRouterModuleWithParams',
|
|
343
343
|
params: JSON.stringify(params),
|
|
344
344
|
})
|
|
345
345
|
routerURL,
|
|
346
346
|
routerParam,
|
|
347
347
|
callBackName = Message_CallBack_Name.MESSAGE_HOME_INIT,
|
|
348
348
|
console.log(
|
|
349
349
|
'callRouterAndroid routerURL:',
|
|
350
350
|
routerURL,
|
|
351
351
|
',routerParam:',
|
|
352
352
|
routerParam,
|
|
353
353
|
)
|
|
354
354
|
const getCallBackName = `window.${callBackName}`
|
|
355
355
|
var params = {
|
|
356
356
|
jdRouter: '1',
|
|
357
357
|
routerURL,
|
|
358
358
|
routerParam,
|
|
359
359
|
callBackName: getCallBackName,
|
|
360
360
|
callBackId: `${callBackName}Android`,
|
|
361
361
|
}
|
|
362
362
|
window?.JDAppUnite?.callRouterModuleWithParams(JSON.stringify(params))
|
|
363
363
|
callBack &&
|
|
364
364
|
(Message_Trigger_CallBackFuncObj[Message_CallBack_Name.MESSAGE_HOME_INIT][
|
|
365
365
|
Message_Type.NATIVE_SHOW_DIALOG
|
|
366
366
|
] = callBack)
|
|
367
367
|
return nativePageRegisterMessage(Message_Type.NATIVE_SHOW_DIALOG, {
|
|
368
368
|
data: params,
|
|
369
369
|
})
|
|
370
370
|
if (!window[Message_CallBack_Name.MESSAGE_HOME_INIT]) {
|
|
371
371
|
window[Message_CallBack_Name.MESSAGE_HOME_INIT] = (messageData) => {
|
|
372
372
|
try {
|
|
373
373
|
const getMessageJsonData =
|
|
374
374
|
typeof messageData === 'string'
|
|
375
375
|
? JSON.parse(messageData)
|
|
376
376
|
: messageData
|
|
377
377
|
const { status } = getMessageJsonData
|
|
378
378
|
if (status == '0') {
|
|
379
379
|
const { type, data } = getMessageJsonData?.data
|
|
380
380
|
const getSendJsonData =
|
|
381
381
|
typeof data === 'string' ? JSON.parse(data) : data
|
|
382
382
|
switch (type) {
|
|
383
383
|
case Message_Type.NATIVE_INFO_DATA:
|
|
384
384
|
case Message_Type.NATIVE_PAGE_FINISH:
|
|
385
385
|
case Message_Type.NATIVE_GET_SCROLL_TOP:
|
|
386
386
|
case Message_Type.NATIVE_TO_SCROLL_TOP:
|
|
387
387
|
case Message_Type.NATIVE_CLOSE_SCROLL_MESSAGE:
|
|
388
388
|
case Message_Type.NATIVE_GET_SCALED_TOUCH_SLOP:
|
|
389
389
|
const getTypeCallBack =
|
|
390
390
|
Message_Trigger_CallBackFuncObj[
|
|
391
391
|
Message_CallBack_Name.MESSAGE_HOME_INIT
|
|
392
392
|
][type]
|
|
393
393
|
if (getTypeCallBack) {
|
|
394
394
|
const isCallBackFunc = typeof getTypeCallBack === 'function'
|
|
395
395
|
console.log(
|
|
396
396
|
`获取${type}类型数据数据type isCallBackFunc getMessageJsonData `,
|
|
397
397
|
type,
|
|
398
398
|
isCallBackFunc,
|
|
399
399
|
getMessageJsonData,
|
|
400
400
|
)
|
|
401
401
|
isCallBackFunc && getTypeCallBack(getSendJsonData)
|
|
402
402
|
}
|
|
403
403
|
break
|
|
404
404
|
case Message_Type.NATIVE_SHOW_DIALOG:
|
|
405
405
|
const showDialogCallBack =
|
|
406
406
|
Message_Trigger_CallBackFuncObj[
|
|
407
407
|
Message_CallBack_Name.MESSAGE_HOME_INIT
|
|
408
408
|
][type]
|
|
409
409
|
if (showDialogCallBack) {
|
|
410
410
|
const isCallBackFunc = typeof showDialogCallBack === 'function'
|
|
411
411
|
console.log(
|
|
412
412
|
`获取${type}类型数据数据type isCallBackFunc getMessageJsonData `,
|
|
413
413
|
type,
|
|
414
414
|
isCallBackFunc,
|
|
415
415
|
getMessageJsonData,
|
|
416
416
|
)
|
|
417
417
|
isCallBackFunc && showDialogCallBack(getMessageJsonData?.data)
|
|
418
418
|
}
|
|
419
419
|
break
|
|
420
420
|
case Message_Type.NATIVE_PAGE_SCROLL:
|
|
421
421
|
taroEventSendPageScrollInfo(data)
|
|
422
422
|
break
|
|
423
423
|
case Message_Type.NATIVE_PAGE_SCROLL_END:
|
|
424
424
|
taroEventSendPageScrollEndInfo(data)
|
|
425
425
|
break
|
|
426
426
|
case Message_Type.NATIVE_H5_SEND_MSG_TO_H5:
|
|
427
427
|
console.log('接收到原生通知 NATIVE_H5_SEND_MSG_TO_H5', data)
|
|
428
428
|
taroEventH5SendMsgToH5(getSendJsonData)
|
|
429
429
|
break
|
|
430
430
|
case Message_Type.UPDATE_NATIVE_DATA:
|
|
431
431
|
console.log('接收到原生通知 UPDATE_NATIVE_DATA', messageData)
|
|
432
432
|
console.log(
|
|
433
433
|
'接收到原生通知 UPDATE_NATIVE_DATA getSendJsonData',
|
|
434
434
|
getSendJsonData,
|
|
435
435
|
)
|
|
436
436
|
taroEventUpdateNativeData(getSendJsonData)
|
|
437
437
|
break
|
|
438
438
|
case Message_Type.H5_TO_SCROLL_TOP:
|
|
439
439
|
taroEventH5ToScrollTop()
|
|
440
440
|
default:
|
|
441
441
|
}
|
|
442
442
|
} else {
|
|
443
443
|
console.log('传递数据获取异常', getMessageJsonData)
|
|
444
444
|
}
|
|
445
445
|
} catch (e) {
|
|
446
446
|
console.log('获取转换异常结果', e)
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
449
|
}
|
|
450
450
|
nativePageRegisterMessage(Message_Type.NATIVE_OPEN_FLOAT, {
|
|
451
451
|
data: params,
|
|
452
452
|
})
|
|
453
453
|
console.log('nativeOpenPopWebView height:', DEFAULT_POP_WEBVIEW_HEIGHT)
|
|
454
454
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
455
455
|
data: {
|
|
456
456
|
type: NATIVE_POP_WEBVIEW_TYPE.OPEN,
|
|
457
457
|
height: DEFAULT_POP_WEBVIEW_HEIGHT,
|
|
458
458
|
...params,
|
|
459
459
|
},
|
|
460
460
|
})
|
|
461
461
|
nativePageRegisterMessage(Message_Type.NATIVE_POP_WEBVIEW, {
|
|
462
462
|
data: {
|
|
463
463
|
type: NATIVE_POP_WEBVIEW_TYPE.CLOSE,
|
|
464
464
|
...params,
|
|
465
465
|
},
|
|
466
466
|
})
|
|
467
467
|
Taro.eventCenter.off(TaroEventType.JOIN_MEMBER_SUCCESS)
|
|
468
468
|
console.log('popWebview关闭')
|
|
469
469
|
nativePageRegisterMessage(Message_Type.NATIVE_H5_SEND_MSG_TO_H5, {
|
|
470
470
|
data: params,
|
|
471
471
|
})
|
|
472
472
|
nativePageRegisterMessage(Message_Type.NATIVE_PUSH_NATIVE_PAGE, {
|
|
473
473
|
data: params,
|
|
474
474
|
})
|
|
475
475
|
window &&
|
|
476
476
|
(window.location.href = `xview://search?request={"action":"${Message_Type.NAVTIVE_FLOAT_READY}"}`)
|
|
477
477
|
res: UtilsInterFace.nativePageScrollRes,
|
|
478
478
|
const { displayHeight, offSetY } = res
|
|
479
479
|
if (typeof displayHeight === 'undefined' || typeof offSetY === 'undefined')
|
|
480
480
|
return
|
|
481
481
|
if (isIosDevice) return res
|
|
482
482
|
if (isAndroidDevice) {
|
|
483
483
|
const deviceRatio = window.devicePixelRatio
|
|
484
484
|
const cssDisplayHeight = Math.ceil(displayHeight / deviceRatio)
|
|
485
485
|
const cssOffsetY = Math.ceil(offSetY / deviceRatio)
|
|
486
486
|
return {
|
|
487
487
|
displayHeight: cssDisplayHeight,
|
|
488
488
|
offSetY: cssOffsetY,
|
|
489
489
|
}
|
|
490
490
|
}
|