-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1122.html
More file actions
230 lines (202 loc) · 6.82 KB
/
Copy path1122.html
File metadata and controls
230 lines (202 loc) · 6.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>客户旅程流程</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f9f9f9;
margin: 0;
padding: 0;
color: #333;
}
.container {
display: flex;
justify-content: center;
padding: 20px;
}
.canvas {
min-height: 300px;
position: relative;
margin-top: 30px;
background: #ffffff;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
padding: 20px;
width: 90%;
overflow-x: scroll;
display: flex;
gap: 20px;
align-items: center;
flex-wrap: nowrap;
}
.stage {
width: 200px;
height: 120px;
background: linear-gradient(145deg, #ffffff, #f1f1f1);
border: 2px solid #ddd;
border-radius: 10px;
margin: 10px;
text-align: center;
padding-top: 30px;
cursor: pointer;
position: relative;
transition: transform 0.3s ease, box-shadow 0.3s ease;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
.stage.dragging {
opacity: 0.6;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}
.stage input {
width: 100%;
border: none;
background: transparent;
text-align: center;
font-size: 18px;
font-weight: bold;
margin-top: -5px;
cursor: pointer;
font-family: 'Arial', sans-serif;
}
.stage input:focus {
outline: none;
color: #007bff;
}
.connector {
position: absolute;
top: 50%;
left: 100%;
width: 30px;
height: 2px;
background-color: #777;
cursor: pointer;
z-index: -1;
}
.add-stage {
background-color: #007bff;
color: white;
border: none;
padding: 10px 20px;
border-radius: 20px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
.add-stage:hover {
background-color: #0056b3;
}
.stage-wrapper {
display: flex;
flex-wrap: nowrap;
gap: 20px;
}
.canvas-wrapper {
display: flex;
justify-content: center;
gap: 20px;
align-items: center;
}
</style>
</head>
<body>
<div class="container">
<div class="canvas-wrapper">
<button class="add-stage" onclick="addStage()">添加阶段</button>
</div>
</div>
<div class="canvas" id="canvas">
<div class="stage" draggable="true" id="stage-1" data-stage="认知">
<input type="text" value="认知" />
</div>
<div class="stage" draggable="true" id="stage-2" data-stage="考虑">
<input type="text" value="考虑" />
</div>
<div class="stage" draggable="true" id="stage-3" data-stage="决策">
<input type="text" value="决策" />
</div>
<div class="stage" draggable="true" id="stage-4" data-stage="购买">
<input type="text" value="购买" />
</div>
</div>
<script>
const canvas = document.getElementById('canvas');
let draggingElement = null;
let stageCount = 4;
const stages = document.querySelectorAll('.stage');
// 更新连接线
function updateConnections() {
const stageElements = document.querySelectorAll('.stage');
stageElements.forEach((stage, index) => {
const nextStage = stageElements[index + 1];
if (nextStage) {
createConnection(stage, nextStage);
}
});
}
function createConnection(fromStage, toStage) {
const fromRect = fromStage.getBoundingClientRect();
const toRect = toStage.getBoundingClientRect();
const connector = document.createElement('div');
connector.classList.add('connector');
const left = fromRect.right;
const top = fromRect.top + fromRect.height / 2;
const height = toRect.top - fromRect.top;
connector.style.top = top + 'px';
connector.style.left = left + 'px';
connector.style.height = height + 'px';
canvas.appendChild(connector);
}
function addStage() {
stageCount++;
const newStage = document.createElement('div');
newStage.classList.add('stage');
newStage.setAttribute('draggable', 'true');
newStage.setAttribute('id', `stage-${stageCount}`);
newStage.setAttribute('data-stage', `阶段${stageCount}`);
newStage.innerHTML = `<input type="text" value="阶段${stageCount}" />`;
canvas.appendChild(newStage);
updateConnections();
addDragEventListeners(newStage);
}
// 拖拽事件
function addDragEventListeners(stage) {
stage.addEventListener('dragstart', (e) => {
draggingElement = e.target;
draggingElement.classList.add('dragging');
});
stage.addEventListener('dragend', () => {
draggingElement.classList.remove('dragging');
draggingElement = null;
});
stage.addEventListener('dragover', (e) => {
e.preventDefault();
const rect = canvas.getBoundingClientRect();
const yPos = e.clientY - rect.top;
const stageHeight = stage.offsetHeight;
if (yPos < stageHeight / 2) {
stage.style.transform = 'translateY(-10px)';
} else {
stage.style.transform = 'translateY(10px)';
}
});
stage.addEventListener('dragleave', () => {
stage.style.transform = 'translateY(0px)';
});
stage.addEventListener('drop', (e) => {
e.preventDefault();
stage.style.transform = 'translateY(0px)';
canvas.appendChild(draggingElement);
updateConnections();
});
}
// 初始阶段拖拽事件
stages.forEach(stage => {
addDragEventListeners(stage);
});
updateConnections(); // 初始化连接线
</script>
</body>
</html>