@dolphinweex/weex-harmony 0.1.65 → 0.1.66
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/package.json
CHANGED
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<
|
|
4
|
-
|
|
3
|
+
<!-- <text v-if="progressText.length > 0">{{progressText}}</text> -->
|
|
4
|
+
<iframe
|
|
5
|
+
:id="embedId"
|
|
5
6
|
v-if="url.length > 0 && pluginType != 'old-h5'"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@
|
|
10
|
-
>
|
|
11
|
-
<iframe
|
|
12
|
-
:id="embedId"
|
|
13
|
-
:src="url"
|
|
14
|
-
:style="{
|
|
15
|
-
backgroundColor: backgroundColor,
|
|
16
|
-
height: height,
|
|
17
|
-
}"
|
|
18
|
-
ref="iframe"
|
|
19
|
-
@load="onPageFinish"
|
|
20
|
-
></iframe>
|
|
21
|
-
</div>
|
|
7
|
+
:src="url"
|
|
8
|
+
:style="{ backgroundColor: backgroundColor, height: height }"
|
|
9
|
+
ref="iframe"
|
|
10
|
+
@load="onPageFinish"
|
|
11
|
+
></iframe>
|
|
22
12
|
|
|
23
13
|
<BaseSameLayer
|
|
24
14
|
class="common-view-iframe"
|
|
@@ -47,9 +37,7 @@ export default {
|
|
|
47
37
|
embedId: `embedId_iframe_${
|
|
48
38
|
Date.now().toString(36) + Math.random().toString(36).substring(2)
|
|
49
39
|
}`,
|
|
50
|
-
height:
|
|
51
|
-
_wrapperTouchParams: null, // wrapper触摸参数
|
|
52
|
-
_parentScroller: null, // 父级scroller元素引用
|
|
40
|
+
height: "100%",
|
|
53
41
|
};
|
|
54
42
|
},
|
|
55
43
|
components: {
|
|
@@ -135,7 +123,7 @@ export default {
|
|
|
135
123
|
};
|
|
136
124
|
this._wrapperEl = findWrapperFromParent(); // 保存容器引用
|
|
137
125
|
this._onMessage = (event) => {
|
|
138
|
-
if
|
|
126
|
+
if(event.data.type==='IFRAME_CONTENT_HEIGHT'){
|
|
139
127
|
const h = Number(event.data.height) || 0;
|
|
140
128
|
if (!h) {
|
|
141
129
|
return;
|
|
@@ -153,100 +141,16 @@ export default {
|
|
|
153
141
|
},
|
|
154
142
|
methods: {
|
|
155
143
|
onPageFinish() {
|
|
156
|
-
if (this.$refs[
|
|
157
|
-
this.$refs[
|
|
144
|
+
if (this.$refs["iframe"]) {
|
|
145
|
+
this.$refs["iframe"].contentWindow.$midea_harmony_native =
|
|
158
146
|
window.$midea_harmony_native;
|
|
159
|
-
this.$refs[
|
|
160
|
-
this.$refs[
|
|
147
|
+
this.$refs["iframe"].contentWindow.isIframe = true;
|
|
148
|
+
this.$refs["iframe"].contentWindow.postMessage(
|
|
161
149
|
JSON.stringify(window.$midea_harmony_native),
|
|
162
|
-
|
|
150
|
+
"*"
|
|
163
151
|
);
|
|
164
152
|
}
|
|
165
153
|
},
|
|
166
|
-
|
|
167
|
-
handleWrapperTouchStart(e) {
|
|
168
|
-
// iframe会接收到事件并处理自己的滚动
|
|
169
|
-
// 找到父级scroller(轮播图容器)或者气他?
|
|
170
|
-
this._findParentScroller();
|
|
171
|
-
// 如果找到了父级scroller,手动触发它的touchstart处理QxQ
|
|
172
|
-
if (this._parentScroller) {
|
|
173
|
-
this._forwardEventToParent(e, 'touchstart');
|
|
174
|
-
}
|
|
175
|
-
const touch = e.touches[0];
|
|
176
|
-
this._wrapperTouchParams = {
|
|
177
|
-
startX: touch.pageX,
|
|
178
|
-
startY: touch.pageY,
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
handleWrapperTouchMove(e) {
|
|
183
|
-
if (!this._wrapperTouchParams) return;
|
|
184
|
-
// iframe正在处理自己的滚动(不阻止)同时转发事件给父级scroller
|
|
185
|
-
if (this._parentScroller) {
|
|
186
|
-
this._forwardEventToParent(e, 'touchmove');
|
|
187
|
-
}
|
|
188
|
-
const touch = e.touches[0];
|
|
189
|
-
const offsetX = touch.pageX - this._wrapperTouchParams.startX;
|
|
190
|
-
const offsetY = touch.pageY - this._wrapperTouchParams.startY;
|
|
191
|
-
const absX = Math.abs(offsetX);
|
|
192
|
-
const absY = Math.abs(offsetY);
|
|
193
|
-
|
|
194
|
-
if (absX > absY && absX > 10) {
|
|
195
|
-
console.log('📱 横向滑动:iframe内滚动 + 父级轮播图同时响应');
|
|
196
|
-
} else if (absY > absX && absY > 10) {
|
|
197
|
-
console.log('📜 纵向滑动:iframe内容滚动');
|
|
198
|
-
}
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
handleWrapperTouchEnd(e) {
|
|
202
|
-
// 转发touchend事件给父级
|
|
203
|
-
if (this._parentScroller) {
|
|
204
|
-
this._forwardEventToParent(e, 'touchend');
|
|
205
|
-
}
|
|
206
|
-
this._wrapperTouchParams = null;
|
|
207
|
-
},
|
|
208
|
-
|
|
209
|
-
// 查找父级scroller元素
|
|
210
|
-
_findParentScroller() {
|
|
211
|
-
if (this._parentScroller) return;
|
|
212
|
-
let parent = this.$parent;
|
|
213
|
-
while (parent) {
|
|
214
|
-
const el = parent.$el;
|
|
215
|
-
if (
|
|
216
|
-
el &&
|
|
217
|
-
el.classList &&
|
|
218
|
-
(el.classList.contains('weex-scroller') ||
|
|
219
|
-
el.classList.contains('weex-slider') ||
|
|
220
|
-
el.classList.contains('weex-list'))
|
|
221
|
-
) {
|
|
222
|
-
this._parentScroller = el;
|
|
223
|
-
console.log('✅ 找到父级scroller,将转发事件');
|
|
224
|
-
return;
|
|
225
|
-
}
|
|
226
|
-
parent = parent.$parent;
|
|
227
|
-
}
|
|
228
|
-
console.warn('⚠️ 未找到父级scroller');
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
// 手动转发事件到父级scroller
|
|
232
|
-
_forwardEventToParent(originalEvent, eventType) {
|
|
233
|
-
if (!this._parentScroller) return;
|
|
234
|
-
try {
|
|
235
|
-
const newEvent = new TouchEvent(eventType, {
|
|
236
|
-
bubbles: true,
|
|
237
|
-
cancelable: true,
|
|
238
|
-
touches: originalEvent.touches,
|
|
239
|
-
targetTouches: originalEvent.targetTouches,
|
|
240
|
-
changedTouches: originalEvent.changedTouches,
|
|
241
|
-
view: window,
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
// 直接触发到父级scroller元素
|
|
245
|
-
this._parentScroller.dispatchEvent(newEvent);
|
|
246
|
-
} catch (err) {
|
|
247
|
-
console.warn('无法转发触摸事件', err);
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
154
|
},
|
|
251
155
|
};
|
|
252
156
|
</script>
|