@dolphinweex/weex-harmony 0.1.12 → 0.1.14
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,6 +1,10 @@
|
|
1
1
|
<template>
|
2
|
-
<div v-on="filteredListeners"
|
2
|
+
<div v-on="filteredListeners"
|
3
|
+
@touchstart="handleTouchStart"
|
4
|
+
@touchmove="handleTouchMove"
|
5
|
+
@touchend="handleTouchEnd">
|
3
6
|
<embed
|
7
|
+
ref="embedElement"
|
4
8
|
:id="embedId"
|
5
9
|
:type="embedType"
|
6
10
|
:width="embedWidth"
|
@@ -41,12 +45,15 @@ export default {
|
|
41
45
|
},
|
42
46
|
data() {
|
43
47
|
return {
|
48
|
+
startX: 0,
|
49
|
+
startY: 0,
|
50
|
+
isHorizontalScroll: false,
|
44
51
|
embedId: `embed_${this._uid}`, // 使用Vue实例的唯一ID来生成embed元素的唯一ID
|
45
52
|
};
|
46
53
|
},
|
47
54
|
computed: {
|
48
55
|
filteredListeners() {
|
49
|
-
|
56
|
+
//指定传给父级标签的vue原生事件 尝试过外面v-on="{ 'click': $listeners.click }" 局部传但是不行
|
50
57
|
if (!this.listenEvents.length) { return {} }
|
51
58
|
const filtered = {};
|
52
59
|
Object.keys(this.$listeners).forEach(event => {
|
@@ -81,6 +88,38 @@ export default {
|
|
81
88
|
this.removeTouchEvent();
|
82
89
|
},
|
83
90
|
methods: {
|
91
|
+
// 记录起始触摸位置
|
92
|
+
handleTouchStart(e) {
|
93
|
+
this.startX = e.changedTouches[0].clientX;
|
94
|
+
this.startY = e.changedTouches[0].clientY;
|
95
|
+
this.isHorizontalScroll = false;
|
96
|
+
// 初始禁用 embed 的交互
|
97
|
+
this.$refs.embedElement.style.pointerEvents = 'none';
|
98
|
+
},
|
99
|
+
// 判断滑动方向并动态切换 pointer-events
|
100
|
+
handleTouchMove(e) {
|
101
|
+
const deltaX = e.changedTouches[0].clientX - this.startX;
|
102
|
+
const deltaY = e.changedTouches[0].clientY - this.startY;
|
103
|
+
// 判断是否为横向滑动
|
104
|
+
if (Math.abs(deltaX) > Math.abs(deltaY)) {
|
105
|
+
this.isHorizontalScroll = true;
|
106
|
+
e.preventDefault(); // 阻止默认滚动行为
|
107
|
+
this.$refs.embedElement.style.pointerEvents = 'none'; // 保持禁用
|
108
|
+
this.handleHorizontalScroll(deltaX); // 执行翻页逻辑
|
109
|
+
} else {
|
110
|
+
// 纵向滑动时恢复交互
|
111
|
+
this.$refs.embedElement.style.pointerEvents = 'auto';
|
112
|
+
}
|
113
|
+
},
|
114
|
+
// 滑动结束重置状态
|
115
|
+
handleTouchEnd() {
|
116
|
+
this.$refs.embedElement.style.pointerEvents = 'auto';
|
117
|
+
this.isHorizontalScroll = false;
|
118
|
+
},
|
119
|
+
// 横向滑动逻辑(示例:控制父容器滚动)
|
120
|
+
handleHorizontalScroll(deltaX) {
|
121
|
+
this.$el.scrollLeft -= deltaX * 0.5; // 调整滑动灵敏度
|
122
|
+
},
|
84
123
|
// 必须给embed元素添加touchstart事件监听,addEventListener的第二个参数监听事件对象置空即可(同层渲染事件处理需要)
|
85
124
|
addTouchEvent() {
|
86
125
|
const embedElement = document.getElementById(this.embedId);
|
@@ -44,7 +44,8 @@ export default {
|
|
44
44
|
pagefinish: this.onPageFinish,
|
45
45
|
pagestart: this.onPageStart,
|
46
46
|
error: this.onError,
|
47
|
-
receivedtitle: this.onReceivedTitle
|
47
|
+
receivedtitle: this.onReceivedTitle,
|
48
|
+
message: this.onMessage,
|
48
49
|
}
|
49
50
|
}
|
50
51
|
},
|
@@ -69,6 +70,10 @@ export default {
|
|
69
70
|
onReceivedTitle(res) {
|
70
71
|
console.log("[web] onReceivedTitle ", res);
|
71
72
|
this.$emit("receivedtitle", res);
|
73
|
+
},
|
74
|
+
onMessage(res){
|
75
|
+
console.log("[web] onMessage ", res);
|
76
|
+
this.$emit("message", res);
|
72
77
|
}
|
73
78
|
},
|
74
79
|
watch: {
|
@@ -45,6 +45,7 @@ export default {
|
|
45
45
|
data: this.data,
|
46
46
|
markerPick: this.markerPick,
|
47
47
|
pointPick: this.pointPick,
|
48
|
+
updateMapData: this.updateMapData,
|
48
49
|
};
|
49
50
|
},
|
50
51
|
},
|
@@ -69,6 +70,9 @@ export default {
|
|
69
70
|
pointPick(res) {
|
70
71
|
this.$emit("point-pick", res);
|
71
72
|
},
|
73
|
+
updateMapData(res) {
|
74
|
+
this.$emit("updateMapData", res);
|
75
|
+
},
|
72
76
|
},
|
73
77
|
};
|
74
78
|
</script>
|
@@ -60,7 +60,7 @@ export default {
|
|
60
60
|
},
|
61
61
|
|
62
62
|
methods: {
|
63
|
-
getListData(callback
|
63
|
+
getListData(callback) {
|
64
64
|
weexModule.callNative(
|
65
65
|
'sceneCardListHandle',
|
66
66
|
{
|
@@ -68,7 +68,6 @@ export default {
|
|
68
68
|
name: this.embedId,
|
69
69
|
},
|
70
70
|
callback,
|
71
|
-
callback
|
72
71
|
);
|
73
72
|
},
|
74
73
|
updateListItem(item) {
|