96009bc9
hexiaodong
hxd
|
1
2
3
4
5
6
|
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>绿纤拓客数据录入</title>
|
96009bc9
hexiaodong
hxd
|
7
|
<script src="config.js"></script>
|
96009bc9
hexiaodong
hxd
|
8
9
10
11
12
13
14
15
|
<script src="auth-utils.js"></script>
<style>
*, *::before, *::after { box-sizing: border-box; }
body {
font-family: 'PingFang SC', 'Microsoft YaHei', Arial, sans-serif;
margin: 0;
min-height: 100vh;
background: linear-gradient(135deg, #e8f5e9 0%, #b2dfdb 100%);
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
16
|
padding: 20px;
|
96009bc9
hexiaodong
hxd
|
17
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
18
|
|
96009bc9
hexiaodong
hxd
|
19
|
.container {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
20
|
width: 100%;
|
96009bc9
hexiaodong
hxd
|
21
|
max-width: 480px;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
22
|
margin: 0 auto;
|
96009bc9
hexiaodong
hxd
|
23
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
24
|
|
96009bc9
hexiaodong
hxd
|
25
26
27
28
29
30
|
h2 {
text-align: center;
color: #388e3c;
margin-bottom: 18px;
letter-spacing: 2px;
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
.form-card {
background: #fff;
border-radius: 20px;
box-shadow: 0 8px 32px 0 rgba(76, 175, 80, 0.15);
border: 1px solid #e8f5e9;
overflow: hidden;
}
.form-content {
padding: 32px;
}
.form-group {
margin-bottom: 24px;
}
.form-group:last-child {
margin-bottom: 0;
}
|
96009bc9
hexiaodong
hxd
|
52
53
|
label {
display: block;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
54
55
56
57
|
margin-bottom: 10px;
font-weight: 600;
color: #2e7d32;
letter-spacing: 0.5px;
|
96009bc9
hexiaodong
hxd
|
58
|
font-size: 0.95em;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
59
60
61
62
63
64
65
66
67
68
69
70
71
|
}
.input-wrapper {
position: relative;
}
.input-icon {
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
width: 20px;
height: 20px;
|
96009bc9
hexiaodong
hxd
|
72
|
color: #6a9c6a;
|
96009bc9
hexiaodong
hxd
|
73
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
74
75
|
input, .select-input, textarea, select {
|
96009bc9
hexiaodong
hxd
|
76
|
width: 100%;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
77
|
padding: 12px;
|
96009bc9
hexiaodong
hxd
|
78
|
border: 1.5px solid #c8e6c9;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
79
|
border-radius: 10px;
|
96009bc9
hexiaodong
hxd
|
80
|
font-size: 1em;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
81
|
transition: all 0.2s ease;
|
96009bc9
hexiaodong
hxd
|
82
|
background: #f9fff9;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
color: #2e7d32;
font-family: inherit;
}
textarea {
min-height: 100px;
resize: vertical;
padding: 16px;
line-height: 1.5;
}
select {
cursor: pointer;
background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236a9c6a' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
background-position: right 12px center;
background-repeat: no-repeat;
background-size: 16px;
padding-right: 40px;
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
}
select:focus {
|
96009bc9
hexiaodong
hxd
|
107
|
outline: none;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
108
109
110
|
border-color: #43a047;
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
background-color: #fff;
|
96009bc9
hexiaodong
hxd
|
111
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
112
113
114
|
input:focus, .select-input:focus, textarea:focus {
outline: none;
|
96009bc9
hexiaodong
hxd
|
115
|
border-color: #43a047;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
116
|
box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
|
96009bc9
hexiaodong
hxd
|
117
118
|
background: #fff;
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
119
120
121
122
123
|
input:disabled {
background: #f5f5f5;
color: #666;
cursor: not-allowed;
|
96009bc9
hexiaodong
hxd
|
124
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
125
126
|
.select-input {
|
96009bc9
hexiaodong
hxd
|
127
|
cursor: pointer;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
128
|
position: relative;
|
96009bc9
hexiaodong
hxd
|
129
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
130
131
132
133
134
135
136
137
138
|
.select-input::after {
content: '▼';
position: absolute;
right: 12px;
top: 50%;
transform: translateY(-50%);
color: #6a9c6a;
font-size: 0.8em;
|
96009bc9
hexiaodong
hxd
|
139
140
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
.btn {
width: 100%;
padding: 16px 20px;
border: none;
border-radius: 12px;
font-size: 1.1em;
font-weight: 600;
cursor: pointer;
transition: all 0.3s ease;
letter-spacing: 1px;
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
color: #fff;
box-shadow: 0 4px 16px rgba(67, 233, 123, 0.3);
margin-top: 32px;
|
96009bc9
hexiaodong
hxd
|
155
|
}
|
96009bc9
hexiaodong
hxd
|
156
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
157
158
159
|
.btn:hover {
box-shadow: 0 6px 24px rgba(67, 233, 123, 0.4);
transform: translateY(-2px);
|
96009bc9
hexiaodong
hxd
|
160
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
161
162
163
|
.btn:active {
transform: translateY(0);
|
96009bc9
hexiaodong
hxd
|
164
165
|
}
|
96009bc9
hexiaodong
hxd
|
166
167
168
169
|
.modal-overlay {
position: fixed;
top: 0;
left: 0;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
170
171
|
right: 0;
bottom: 0;
|
96009bc9
hexiaodong
hxd
|
172
173
|
background: rgba(0, 0, 0, 0.5);
display: none;
|
96009bc9
hexiaodong
hxd
|
174
|
align-items: center;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
175
|
justify-content: center;
|
96009bc9
hexiaodong
hxd
|
176
|
z-index: 1000;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
177
|
padding: 20px;
|
96009bc9
hexiaodong
hxd
|
178
179
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
180
|
.modal-content {
|
96009bc9
hexiaodong
hxd
|
181
|
background: #fff;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
182
183
184
185
|
border-radius: 18px;
width: 100%;
max-width: 400px;
max-height: 80vh;
|
96009bc9
hexiaodong
hxd
|
186
|
overflow: hidden;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
187
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
|
96009bc9
hexiaodong
hxd
|
188
189
190
191
|
}
.modal-header {
background: linear-gradient(120deg, #43e97b 0%, #38f9d7 100%);
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
192
|
padding: 20px;
|
96009bc9
hexiaodong
hxd
|
193
|
text-align: center;
|
96009bc9
hexiaodong
hxd
|
194
195
196
197
198
199
200
201
202
203
|
}
.modal-title {
color: #fff;
font-size: 1.2em;
font-weight: bold;
margin: 0;
letter-spacing: 1px;
}
|
96009bc9
hexiaodong
hxd
|
204
|
.modal-body {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
205
|
padding: 20px;
|
96009bc9
hexiaodong
hxd
|
206
207
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
208
209
210
211
212
213
214
215
|
.search-input {
width: 100%;
padding: 12px;
border: 1.5px solid #c8e6c9;
border-radius: 10px;
font-size: 1em;
margin-bottom: 16px;
background: #f9fff9;
|
96009bc9
hexiaodong
hxd
|
216
217
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
218
219
220
221
222
|
.option-list {
max-height: 300px;
overflow-y: auto;
border: 1px solid #e0e0e0;
border-radius: 8px;
|
96009bc9
hexiaodong
hxd
|
223
224
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
225
226
227
228
229
|
.option-item {
padding: 12px 16px;
border-bottom: 1px solid #f0f0f0;
cursor: pointer;
transition: background 0.2s ease;
|
96009bc9
hexiaodong
hxd
|
230
231
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
232
233
|
.option-item:hover {
background: #f5f5f5;
|
96009bc9
hexiaodong
hxd
|
234
235
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
236
237
238
239
|
.option-item.selected {
background: #e8f5e9;
color: #2e7d32;
font-weight: bold;
|
96009bc9
hexiaodong
hxd
|
240
241
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
242
243
244
|
.modal-footer {
padding: 16px 20px;
border-top: 1px solid #e0e0e0;
|
96009bc9
hexiaodong
hxd
|
245
246
|
display: flex;
gap: 12px;
|
96009bc9
hexiaodong
hxd
|
247
248
249
|
}
.modal-btn {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
250
251
|
flex: 1;
padding: 10px 16px;
|
96009bc9
hexiaodong
hxd
|
252
253
|
border: none;
border-radius: 8px;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
254
|
font-size: 0.95em;
|
96009bc9
hexiaodong
hxd
|
255
|
cursor: pointer;
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
256
|
transition: all 0.2s ease;
|
96009bc9
hexiaodong
hxd
|
257
258
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
259
260
|
.modal-btn-primary {
background: #43a047;
|
96009bc9
hexiaodong
hxd
|
261
|
color: #fff;
|
96009bc9
hexiaodong
hxd
|
262
263
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
264
|
.modal-btn-secondary {
|
96009bc9
hexiaodong
hxd
|
265
266
267
268
269
|
background: #f5f5f5;
color: #666;
border: 1px solid #ddd;
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
270
271
272
273
274
275
276
277
278
279
280
281
282
283
|
.message-toast {
position: fixed;
top: 20px;
right: 20px;
max-width: 300px;
padding: 16px 20px;
border-radius: 10px;
color: #fff;
font-weight: 500;
z-index: 2000;
transform: translateX(200%);
transition: all 0.3s ease;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
text-align: center;
|
96009bc9
hexiaodong
hxd
|
284
285
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
286
287
288
289
|
.message-toast.show {
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-100%);
|
96009bc9
hexiaodong
hxd
|
290
291
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
292
293
|
.message-toast.success {
background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
|
96009bc9
hexiaodong
hxd
|
294
295
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
296
297
|
.message-toast.error {
background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
|
96009bc9
hexiaodong
hxd
|
298
299
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
300
301
|
.message-toast.warning {
background: linear-gradient(135deg, #ff9800 0%, #ffb74d 100%);
|
96009bc9
hexiaodong
hxd
|
302
303
304
|
}
@media (max-width: 520px) {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
305
306
307
308
|
.container { max-width: 100%; }
.form-content { padding: 24px; }
.form-group { margin-bottom: 20px; }
.btn { margin-top: 24px; }
|
96009bc9
hexiaodong
hxd
|
309
310
311
312
313
314
315
|
}
</style>
</head>
<body>
<div class="container">
<h2>绿纤拓客数据录入</h2>
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
<div class="form-card">
<div class="form-content">
<form id="expansionForm">
<div class="form-group">
<label for="hd">拓客活动</label>
<div class="input-wrapper">
<select id="hd" name="hd" class="select-input">
<option value="">请选择拓客活动</option>
</select>
</div>
</div>
<div class="form-group">
<label for="tksj">拓客时间</label>
<div class="input-wrapper">
<input type="datetime-local" id="tksj">
</div>
</div>
<div class="form-group">
<label for="gkxm">顾客姓名</label>
<div class="input-wrapper">
<input type="text" id="gkxm" placeholder="请输入顾客姓名">
</div>
</div>
<div class="form-group">
<label for="dhhm">电话号码</label>
<div class="input-wrapper">
<input type="text" id="dhhm" placeholder="请输入电话号码">
</div>
</div>
<div class="form-group">
<label for="gmzs">购买张数</label>
<div class="input-wrapper">
<!-- <input type="text" id="gmzs" placeholder="请输入购买张数"> -->
<input type="number" id="gmzs" name="gmzs" min="1" value="1" placeholder="请输入购买张数" required>
</div>
</div>
<div class="form-group">
<label for="zffs">支付方式</label>
<div class="input-wrapper">
<select id="zffs" name="zffs" class="select-input">
<option value="">请选择支付方式</option>
<option value="微信">微信</option>
<option value="支付宝">支付宝</option>
<option value="现金">现金</option>
<option value="银行转账">银行转账</option>
</select>
</div>
</div>
<div class="form-group">
<label for="sfjwx">是否加微信</label>
<div class="input-wrapper">
<select id="sfjwx" name="sfjwx" class="select-input">
<option value="">请选择是否加微信</option>
<option value="是">是</option>
<option value="否">否</option>
</select>
</div>
|
96009bc9
hexiaodong
hxd
|
379
|
</div>
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
380
381
382
383
384
385
|
<div class="form-group">
<label for="bz">备注</label>
<div class="input-wrapper">
<textarea id="bz" placeholder="请输入备注信息"></textarea>
</div>
|
96009bc9
hexiaodong
hxd
|
386
|
</div>
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
387
388
389
|
<button type="submit" class="btn">保存</button>
</form>
|
96009bc9
hexiaodong
hxd
|
390
391
|
</div>
</div>
|
96009bc9
hexiaodong
hxd
|
392
|
</div>
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
393
394
395
|
<div id="messageToast" class="message-toast"></div>
|
96009bc9
hexiaodong
hxd
|
396
397
|
<script>
// 全局变量
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
398
399
400
401
402
403
404
405
406
407
408
409
410
411
|
let userInfo = null;
let currentEventId = null;
// 表单字段配置
const FORM_FIELDS = {
hd: { required: true, type: 'select', label: '拓客活动' },
tksj: { required: true, type: 'datetime', label: '拓客时间' },
gkxm: { required: true, type: 'text', label: '顾客姓名' },
dhhm: { required: true, type: 'text', label: '电话号码' },
gmzs: { required: true, type: 'text', label: '购买张数' },
zffs: { required: true, type: 'select', label: '支付方式' },
sfjwx: { required: true, type: 'select', label: '是否加微信' },
bz: { required: false, type: 'textarea', label: '备注' }
};
|
96009bc9
hexiaodong
hxd
|
412
413
414
|
// 页面加载完成后初始化
document.addEventListener('DOMContentLoaded', function() {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
415
416
|
initializePage();
bindEvents();
|
96009bc9
hexiaodong
hxd
|
417
418
|
});
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
419
420
421
422
423
424
425
|
// 初始化页面
async function initializePage() {
try {
// 获取当前登录用户
userInfo = JSON.parse(localStorage.getItem('userInfo'));
if (!userInfo || Object.keys(userInfo).length === 0) {
window.location.href = 'login.html';
|
96009bc9
hexiaodong
hxd
|
426
427
|
return;
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
428
429
430
431
432
433
434
435
436
437
|
console.log('用户信息:', userInfo);
// 设置默认时间
setDefaultDateTime();
// 获取当前活动
await getCurrentEvent();
} catch (error) {
console.error('页面初始化失败:', error);
showMessage('页面初始化失败,请刷新重试', 'error');
|
96009bc9
hexiaodong
hxd
|
438
|
}
|
96009bc9
hexiaodong
hxd
|
439
440
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
441
442
443
444
|
// 设置默认时间
function setDefaultDateTime() {
const now = new Date();
const localDateTime = new Date(now.getTime() - now.getTimezoneOffset() * 60000).toISOString().slice(0, 16);
|
96009bc9
hexiaodong
hxd
|
445
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
446
447
|
// 设置拓客时间
document.getElementById('tksj').value = localDateTime;
|
96009bc9
hexiaodong
hxd
|
448
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
449
450
451
452
453
454
455
456
|
// 设置默认购买张数
document.getElementById('gmzs').value = '1';
// 设置默认支付方式
document.getElementById('zffs').value = '微信';
// 设置默认是否加微信
document.getElementById('sfjwx').value = '否';
|
96009bc9
hexiaodong
hxd
|
457
458
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
459
460
461
462
463
464
465
466
467
468
|
// 获取当前活动
async function getCurrentEvent() {
try {
const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/lqevent/user/${userInfo.userId}/current`;
const response = await fetch(apiUrl, {
method: 'GET',
headers: {
'Authorization': `${getAuthToken()}`,
'Content-Type': 'application/json'
}
|
96009bc9
hexiaodong
hxd
|
469
|
});
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
|
if (response.ok) {
const result = await response.json();
if (result.code === 200 && result.data && result.data.length > 0) {
// 填充活动下拉选项
const eventSelect = document.getElementById('hd');
eventSelect.innerHTML = '<option value="">请选择拓客活动</option>';
result.data.forEach(event => {
const option = document.createElement('option');
option.value = event.EventId;
option.textContent = event.EventName;
eventSelect.appendChild(option);
});
// 默认选择第一个活动
if (result.data.length > 0) {
currentEventId = result.data[0].EventId;
eventSelect.value = currentEventId;
console.log('当前活动ID:', currentEventId);
}
} else {
console.warn('未找到当前活动');
}
}
} catch (error) {
console.error('获取当前活动失败:', error);
|
96009bc9
hexiaodong
hxd
|
497
498
499
|
}
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
500
501
502
|
// 获取当前活动ID
function getCurrentEventId() {
return currentEventId;
|
96009bc9
hexiaodong
hxd
|
503
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
504
|
|
96009bc9
hexiaodong
hxd
|
505
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
506
507
|
function bindEvents() {
document.getElementById('expansionForm').addEventListener('submit', handleFormSubmit);
|
96009bc9
hexiaodong
hxd
|
508
509
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
510
511
512
|
// 表单验证
async function validateForm() {
const errors = [];
|
96009bc9
hexiaodong
hxd
|
513
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
514
515
516
|
// 验证必填字段
if (!document.getElementById('hd').value) {
errors.push('请选择拓客活动');
|
96009bc9
hexiaodong
hxd
|
517
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
518
519
|
if (!document.getElementById('tksj').value) {
errors.push('请选择拓客时间');
|
96009bc9
hexiaodong
hxd
|
520
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
521
522
|
if (!document.getElementById('gkxm').value.trim()) {
errors.push('请输入顾客姓名');
|
96009bc9
hexiaodong
hxd
|
523
|
}
|
96009bc9
hexiaodong
hxd
|
524
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
525
526
527
|
const phoneNumber = document.getElementById('dhhm').value.trim();
if (!phoneNumber) {
errors.push('请输入电话号码');
|
96009bc9
hexiaodong
hxd
|
528
|
} else {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
529
530
531
532
|
// 验证手机号格式
const phoneRegex = /^1[3-9]\d{9}$/;
if (!phoneRegex.test(phoneNumber)) {
errors.push('请输入正确的手机号码');
|
96009bc9
hexiaodong
hxd
|
533
534
535
|
}
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
536
537
538
539
540
|
const buyCount = document.getElementById('gmzs').value.trim();
if (!buyCount) {
errors.push('请输入购买张数');
} else if (parseInt(buyCount) < 1) {
errors.push('购买张数必须大于0');
|
96009bc9
hexiaodong
hxd
|
541
542
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
543
544
545
546
547
|
if (!document.getElementById('zffs').value) {
errors.push('请选择支付方式');
}
if (!document.getElementById('sfjwx').value) {
errors.push('请选择是否加微信');
|
96009bc9
hexiaodong
hxd
|
548
549
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
550
|
return errors;
|
96009bc9
hexiaodong
hxd
|
551
552
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
553
554
|
// 收集表单数据
function collectFormData() {
|
96009bc9
hexiaodong
hxd
|
555
|
return {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
556
557
558
559
560
561
562
563
564
|
expansionTime: new Date(document.getElementById('tksj').value).getTime(),
customerName: document.getElementById('gkxm').value.trim(),
customerPhone: document.getElementById('dhhm').value.trim(),
buyNumber: parseInt(document.getElementById('gmzs').value) || 1,
paymentMethod: document.getElementById('zffs').value,
isAddWeChat: document.getElementById('sfjwx').value,
remarks: document.getElementById('bz').value.trim(),
expansionUserId: userInfo.userId,
eventId: document.getElementById('hd').value, // 从下拉框获取活动ID
|
96009bc9
hexiaodong
hxd
|
565
566
567
|
};
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
568
569
570
|
// 处理表单提交
async function handleFormSubmit(event) {
event.preventDefault();
|
96009bc9
hexiaodong
hxd
|
571
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
572
573
574
575
576
|
// 验证表单
const errors = await validateForm();
if (errors.length > 0) {
showMessage(errors[0], 'error');
return;
|
96009bc9
hexiaodong
hxd
|
577
578
|
}
|
96009bc9
hexiaodong
hxd
|
579
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
580
581
582
|
// 收集表单数据
const formData = collectFormData();
console.log('表单数据:', formData);
|
96009bc9
hexiaodong
hxd
|
583
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
584
585
|
// 提交数据
submitExpansion(formData);
|
96009bc9
hexiaodong
hxd
|
586
587
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
588
589
|
// API请求工具函数
async function apiRequest(url, options = {}) {
|
96009bc9
hexiaodong
hxd
|
590
|
try {
|
96009bc9
hexiaodong
hxd
|
591
|
const response = await fetch(url, {
|
96009bc9
hexiaodong
hxd
|
592
|
headers: {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
593
594
595
596
597
|
'Content-Type': 'application/json',
'Authorization': `${getAuthToken()}`,
...options.headers
},
...options
|
96009bc9
hexiaodong
hxd
|
598
599
|
});
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
600
601
|
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
96009bc9
hexiaodong
hxd
|
602
603
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
604
605
|
const result = await response.json();
return result;
|
96009bc9
hexiaodong
hxd
|
606
|
} catch (error) {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
607
608
|
console.error('API请求失败:', error);
throw error;
|
96009bc9
hexiaodong
hxd
|
609
610
611
|
}
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
612
613
|
// 提交扩展邀约数据
async function submitExpansion(data) {
|
96009bc9
hexiaodong
hxd
|
614
|
try {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
615
|
showMessage('正在提交...', 'info');
|
96009bc9
hexiaodong
hxd
|
616
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
617
618
619
620
|
const apiUrl = `${APP_CONFIG.getApiBaseUrl()}/api/Extend/LqTkjlb`;
const result = await apiRequest(apiUrl, {
method: 'POST',
body: JSON.stringify(data)
|
96009bc9
hexiaodong
hxd
|
621
622
|
});
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
|
if (result.code === 200) {
showMessage('拓客数据提交成功!', 'success');
// 格式化时间
const formatTime = (timestamp) => {
const date = new Date(timestamp);
return date.toLocaleString('zh-CN', {
year: 'numeric',
month: '2-digit',
day: '2-digit',
hour: '2-digit',
minute: '2-digit'
});
};
let datanew = {
"webhookUrl": "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6f8686ec-5011-4c1d-bae9-d82a2a2f4d83",
"content": `🎉 拓客记录
⏩顾客姓名:${data.customerName}
⏩电话号码:${data.customerPhone}
⏩拓客时间:${formatTime(data.expansionTime)}
⏩购买张数:${data.buyNumber}
⏩支付方式:${data.paymentMethod}
⏩是否加微信:${data.isAddWeChat}
⏩备注:${data.remarks}
⏩拓客人员:${userInfo.userName || '未知'}
`
};
const resultnew = await apiRequest('http://wx.lvqianmeiye.com/api/Bot/send-text', {
method: 'POST',
body: JSON.stringify(datanew)
});
clearForm();
|
96009bc9
hexiaodong
hxd
|
655
|
} else {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
656
|
showMessage(`添加失败:${result.message || '未知错误'}`, 'error');
|
96009bc9
hexiaodong
hxd
|
657
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
658
659
660
|
} catch (error) {
console.error('提交失败:', error);
showMessage('网络错误,请稍后重试', 'error');
|
96009bc9
hexiaodong
hxd
|
661
662
663
|
}
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
664
665
|
// 清空表单
function clearForm() {
|
96009bc9
hexiaodong
hxd
|
666
|
try {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
667
668
|
// 重置表单
document.getElementById('expansionForm').reset();
|
96009bc9
hexiaodong
hxd
|
669
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
670
671
|
// 重新设置默认值
setDefaultDateTime();
|
96009bc9
hexiaodong
hxd
|
672
|
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
673
674
675
|
// 重新设置活动选择
if (currentEventId) {
document.getElementById('hd').value = currentEventId;
|
96009bc9
hexiaodong
hxd
|
676
677
|
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
678
|
console.log('表单已清空');
|
96009bc9
hexiaodong
hxd
|
679
|
} catch (error) {
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
680
|
console.error('清空表单失败:', error);
|
96009bc9
hexiaodong
hxd
|
681
682
|
}
}
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
683
684
685
686
687
688
689
690
691
692
693
694
695
696
|
function showMessage(message, type = 'info') {
const toast = document.getElementById('messageToast');
toast.textContent = message;
toast.className = `message-toast ${type}`;
setTimeout(() => {
toast.classList.add('show');
}, 100);
setTimeout(() => {
toast.classList.remove('show');
}, 3000);
}
|
96009bc9
hexiaodong
hxd
|
697
698
|
</script>
</body>
|
e94f4f10
“wangming”
feat: 实现给金三角添加用户绑...
|
699
|
</html>
|