samlax12 commited on
Commit
e318da8
·
verified ·
1 Parent(s): c01d589

Upload 4 files

Browse files
Files changed (4) hide show
  1. QR.py +191 -128
  2. avatar.jpg +0 -0
  3. index.html +402 -316
  4. wechat_pay.jpg +0 -0
QR.py CHANGED
@@ -1,7 +1,7 @@
1
  import cv2
2
  import numpy as np
3
  from pyzbar.pyzbar import decode
4
- from PIL import Image
5
  import requests
6
  from io import BytesIO
7
  import os
@@ -9,13 +9,81 @@ import sys
9
 
10
  # 设置默认编码为UTF-8
11
  if sys.platform.startswith('win'):
12
- # Windows系统下处理中文路径
13
  import locale
14
  locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')
15
 
16
- def parse_qr_code_from_file(file_path):
17
  """
18
- 从本地文件解析二维码
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
  参数:
21
  file_path: 二维码图片的本地路径
@@ -28,122 +96,122 @@ def parse_qr_code_from_file(file_path):
28
  if not os.path.exists(file_path):
29
  print(f"错误:文件不存在 - {file_path}")
30
  return None
31
-
32
- # 使用PIL读取图片以更好地处理中文路径
33
  pil_image = Image.open(file_path)
34
 
35
- # 转换为RGB格式(如果需要)
36
  if pil_image.mode != 'RGB':
37
  pil_image = pil_image.convert('RGB')
38
 
39
  # 转换为numpy数组
40
  image_array = np.array(pil_image)
41
 
42
- # 如果是RGB,转换为BGR(OpenCV格式)
43
- if len(image_array.shape) == 3:
44
- image_array = cv2.cvtColor(image_array, cv2.COLOR_RGB2BGR)
45
 
46
- # 解码二维码
47
- decoded_objects = decode(image_array)
 
48
 
49
- if decoded_objects:
50
- # 返回第一个解析到的内容
51
- result = decoded_objects[0].data.decode('utf-8')
52
- return result
53
- else:
54
- print("未能识别二维码,尝试图像预处理...")
55
 
56
- # 转换为灰度图
57
- if len(image_array.shape) == 3:
58
- gray = cv2.cvtColor(image_array, cv2.COLOR_BGR2GRAY)
 
 
 
 
 
 
59
  else:
60
- gray = image_array
61
 
62
- # 尝试不同的预处理方法
63
  preprocessing_methods = [
64
- # 方法1:简单二值化
65
- lambda img: cv2.threshold(img, 127, 255, cv2.THRESH_BINARY)[1],
66
- # 方法2:自适应阈值
67
- lambda img: cv2.adaptiveThreshold(img, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11, 2),
68
- # 方法3:OTSU阈值
69
- lambda img: cv2.threshold(img, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1],
70
- # 方法4:反转图像
71
- lambda img: cv2.bitwise_not(img)
72
- ]
73
-
74
- for i, preprocess in enumerate(preprocessing_methods):
75
- processed = preprocess(gray)
76
- decoded_objects = decode(processed)
77
- if decoded_objects:
78
- print(f"使用预处理方法{i+1}成功解析")
79
- return decoded_objects[0].data.decode('utf-8')
80
-
81
- # 如果所有方法都失败,尝试使用PIL直接解码
82
- try:
83
- from PIL import ImageEnhance
84
-
85
  # 增强对比度
86
- enhancer = ImageEnhance.Contrast(pil_image)
87
- enhanced = enhancer.enhance(2.0)
88
-
89
- # 再次尝试解码
90
- decoded_objects = decode(np.array(enhanced))
91
- if decoded_objects:
92
- print("使用PIL增强后成功解析")
93
- return decoded_objects[0].data.decode('utf-8')
94
- except:
95
- pass
96
-
97
- return None
 
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  except Exception as e:
100
  print(f"解析二维码时出错: {e}")
101
  import traceback
102
  traceback.print_exc()
103
  return None
104
 
105
- def parse_qr_code_from_url(url):
106
  """
107
- 从URL解析二维码
108
 
109
  参数:
110
- url: 二维码图片的URL
111
-
112
- 返回:
113
- 解析出的链接或文本
114
- """
115
- try:
116
- # 下载图片
117
- response = requests.get(url)
118
- image = Image.open(BytesIO(response.content))
119
-
120
- # 转换为numpy数组
121
- image_array = np.array(image)
122
-
123
- # 解码二维码
124
- decoded_objects = decode(image_array)
125
-
126
- if decoded_objects:
127
- return decoded_objects[0].data.decode('utf-8')
128
- else:
129
- return None
130
-
131
- except Exception as e:
132
- print(f"解析二维码时出错: {e}")
133
- return None
134
-
135
- def test_with_multiple_files():
136
- """
137
- 测试函数,尝试解析当前目录下的所有图片文件
138
  """
139
- image_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.gif']
140
- current_dir = os.getcwd()
141
 
142
- print(f"当前目录: {current_dir}")
143
- print("正在查找图片文件...\n")
 
 
144
 
145
  found_images = []
146
- for file in os.listdir(current_dir):
147
  if any(file.lower().endswith(ext) for ext in image_extensions):
148
  found_images.append(file)
149
 
@@ -151,47 +219,42 @@ def test_with_multiple_files():
151
  print("未找到图片文件")
152
  return
153
 
154
- print(f"找到 {len(found_images)} 个图片文件:")
155
- for i, img in enumerate(found_images):
156
- print(f"{i+1}. {img}")
157
-
158
- print("\n开始解析...\n")
159
 
160
- for img_file in found_images:
161
- print(f"正在解析: {img_file}")
162
- full_path = os.path.join(current_dir, img_file)
163
- result = parse_qr_code_from_file(full_path)
 
 
 
164
 
165
  if result:
166
- print(f"✓ 解析成功!")
167
- print(f" 内容: {result}")
 
 
 
 
 
 
 
168
  else:
169
- print(f" 无法解析此文件")
170
- print("-" * 50)
 
 
 
171
 
172
  # 使用示例
173
  if __name__ == "__main__":
174
- # 方式1:自动查找并解析当前目录下的所有图片
175
- print("=== 自动扫描模式 ===")
176
- test_with_multiple_files()
177
-
178
- print("\n=== 手动指定文件模式 ===")
179
- # 方式2:手动指定文件名(请根据实际情况修改)
180
- # 注意:使用原始字符串(r"")或正斜杠(/)来避免路径问题
181
-
182
- # 示例路径(请替换为您的实际文件名)
183
- test_files = [
184
- "微信图片_20250609201923.jpg", # 直接使用文件名
185
- r"E:\收款web\微信图片_20250609201923.jpg", # 完整路径示例
186
- ]
187
-
188
- for file_path in test_files:
189
- if os.path.exists(file_path):
190
- print(f"\n尝试解析: {file_path}")
191
- result = parse_qr_code_from_file(file_path)
192
- if result:
193
- print(f"解析成功!内容: {result}")
194
- else:
195
- print("无法解析此二维码")
196
- else:
197
- print(f"\n文件不存在: {file_path}")
 
1
  import cv2
2
  import numpy as np
3
  from pyzbar.pyzbar import decode
4
+ from PIL import Image, ImageDraw
5
  import requests
6
  from io import BytesIO
7
  import os
 
9
 
10
  # 设置默认编码为UTF-8
11
  if sys.platform.startswith('win'):
 
12
  import locale
13
  locale.setlocale(locale.LC_ALL, 'zh_CN.UTF-8')
14
 
15
+ def detect_and_extract_circular_qr(image):
16
  """
17
+ 检测并提取圆形二维码区域
18
+
19
+ 参数:
20
+ image: numpy数组格式的图像
21
+
22
+ 返回:
23
+ 处理后的图像列表
24
+ """
25
+ processed_images = []
26
+
27
+ # 转换为灰度图
28
+ if len(image.shape) == 3:
29
+ gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
30
+ else:
31
+ gray = image.copy()
32
+
33
+ # 使用霍夫圆检测
34
+ circles = cv2.HoughCircles(
35
+ gray,
36
+ cv2.HOUGH_GRADIENT,
37
+ dp=1,
38
+ minDist=50,
39
+ param1=50,
40
+ param2=30,
41
+ minRadius=50,
42
+ maxRadius=500
43
+ )
44
+
45
+ if circles is not None:
46
+ circles = np.uint16(np.around(circles))
47
+
48
+ for circle in circles[0, :]:
49
+ x, y, r = circle
50
+
51
+ # 创建掩码
52
+ mask = np.zeros(gray.shape, np.uint8)
53
+ cv2.circle(mask, (x, y), r, 255, -1)
54
+
55
+ # 提取圆形区域
56
+ circular_region = cv2.bitwise_and(image, image, mask=mask)
57
+
58
+ # 裁剪到包含圆形的最小矩形
59
+ x_min = max(0, x - r)
60
+ x_max = min(image.shape[1], x + r)
61
+ y_min = max(0, y - r)
62
+ y_max = min(image.shape[0], y + r)
63
+
64
+ cropped = circular_region[y_min:y_max, x_min:x_max]
65
+ processed_images.append(cropped)
66
+
67
+ # 同时添加将圆形区域转换为方形的版本
68
+ square_size = 2 * r
69
+ square_region = np.zeros((square_size, square_size, 3), dtype=np.uint8)
70
+ square_region[:] = 255 # 白色背景
71
+
72
+ # 将圆形内容复制到方形图像中心
73
+ if cropped.shape[0] > 0 and cropped.shape[1] > 0:
74
+ y_offset = (square_size - cropped.shape[0]) // 2
75
+ x_offset = (square_size - cropped.shape[1]) // 2
76
+
77
+ if y_offset >= 0 and x_offset >= 0:
78
+ square_region[y_offset:y_offset+cropped.shape[0],
79
+ x_offset:x_offset+cropped.shape[1]] = cropped
80
+ processed_images.append(square_region)
81
+
82
+ return processed_images
83
+
84
+ def parse_qr_code_advanced(file_path):
85
+ """
86
+ 高级二维码解析函数,支持各种形状的二维码
87
 
88
  参数:
89
  file_path: 二维码图片的本地路径
 
96
  if not os.path.exists(file_path):
97
  print(f"错误:文件不存在 - {file_path}")
98
  return None
99
+
100
+ # 使用PIL读取图片
101
  pil_image = Image.open(file_path)
102
 
103
+ # 转换为RGB格式
104
  if pil_image.mode != 'RGB':
105
  pil_image = pil_image.convert('RGB')
106
 
107
  # 转换为numpy数组
108
  image_array = np.array(pil_image)
109
 
110
+ # 准备多个版本的图像进行尝试
111
+ images_to_try = [image_array]
 
112
 
113
+ # 检测并提取圆形二维码
114
+ circular_extracts = detect_and_extract_circular_qr(image_array)
115
+ images_to_try.extend(circular_extracts)
116
 
117
+ # 尝试各种预处理方法
118
+ for idx, img in enumerate(images_to_try):
119
+ print(f"尝试方法 {idx + 1}/{len(images_to_try)}...")
 
 
 
120
 
121
+ # 直接尝试解码
122
+ decoded_objects = decode(img)
123
+ if decoded_objects:
124
+ print(f"✓ 方法 {idx + 1} 成功解析!")
125
+ return decoded_objects[0].data.decode('utf-8')
126
+
127
+ # 转换为灰度图并尝试多种预处理
128
+ if len(img.shape) == 3:
129
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
130
  else:
131
+ gray = img
132
 
133
+ # 预处理方法列表
134
  preprocessing_methods = [
135
+ # 简单二值化
136
+ lambda g: cv2.threshold(g, 127, 255, cv2.THRESH_BINARY)[1],
137
+ # OTSU阈值
138
+ lambda g: cv2.threshold(g, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)[1],
139
+ # 自适应阈值
140
+ lambda g: cv2.adaptiveThreshold(g, 255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
141
+ cv2.THRESH_BINARY, 11, 2),
142
+ # 反转颜色
143
+ lambda g: cv2.bitwise_not(g),
 
 
 
 
 
 
 
 
 
 
 
 
144
  # 增强对比度
145
+ lambda g: cv2.convertScaleAbs(g, alpha=2.0, beta=0),
146
+ # 形态学操作 - 闭运算
147
+ lambda g: cv2.morphologyEx(
148
+ cv2.threshold(g, 127, 255, cv2.THRESH_BINARY)[1],
149
+ cv2.MORPH_CLOSE,
150
+ cv2.getStructuringElement(cv2.MORPH_RECT, (3, 3))
151
+ ),
152
+ # 高斯模糊后二值化
153
+ lambda g: cv2.threshold(
154
+ cv2.GaussianBlur(g, (5, 5), 0),
155
+ 127, 255, cv2.THRESH_BINARY
156
+ )[1]
157
+ ]
158
 
159
+ for j, preprocess in enumerate(preprocessing_methods):
160
+ try:
161
+ processed = preprocess(gray)
162
+ decoded_objects = decode(processed)
163
+ if decoded_objects:
164
+ print(f"✓ 方法 {idx + 1} 的预处理 {j + 1} 成功解析!")
165
+ return decoded_objects[0].data.decode('utf-8')
166
+ except:
167
+ continue
168
+
169
+ # 如果所有方法都失败,尝试更激进的方法
170
+ print("尝试更多高级处理方法...")
171
+
172
+ # 尝试旋转图像
173
+ for angle in [90, 180, 270]:
174
+ rotated = cv2.rotate(image_array, angle // 90 - 1)
175
+ decoded_objects = decode(rotated)
176
+ if decoded_objects:
177
+ print(f"✓ 旋转 {angle}° 后成功解析!")
178
+ return decoded_objects[0].data.decode('utf-8')
179
+
180
+ # 尝试缩放图像
181
+ for scale in [0.5, 0.75, 1.5, 2.0]:
182
+ new_size = (int(image_array.shape[1] * scale), int(image_array.shape[0] * scale))
183
+ resized = cv2.resize(image_array, new_size, interpolation=cv2.INTER_CUBIC)
184
+ decoded_objects = decode(resized)
185
+ if decoded_objects:
186
+ print(f"✓ 缩放 {scale}x 后成功解析!")
187
+ return decoded_objects[0].data.decode('utf-8')
188
+
189
+ print("✗ 所有方法都无法解析此二维码")
190
+ return None
191
+
192
  except Exception as e:
193
  print(f"解析二维码时出错: {e}")
194
  import traceback
195
  traceback.print_exc()
196
  return None
197
 
198
+ def batch_process_directory(directory_path=None):
199
  """
200
+ 批量处理目录下的所有图片文件
201
 
202
  参数:
203
+ directory_path: 目录路径,默认为当前目录
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  """
205
+ if directory_path is None:
206
+ directory_path = os.getcwd()
207
 
208
+ image_extensions = ['.jpg', '.jpeg', '.png', '.bmp', '.gif', '.webp']
209
+
210
+ print(f"扫描目录: {directory_path}")
211
+ print("=" * 60)
212
 
213
  found_images = []
214
+ for file in os.listdir(directory_path):
215
  if any(file.lower().endswith(ext) for ext in image_extensions):
216
  found_images.append(file)
217
 
 
219
  print("未找到图片文件")
220
  return
221
 
222
+ print(f"找到 {len(found_images)} 个图片文件\n")
 
 
 
 
223
 
224
+ success_count = 0
225
+ for i, img_file in enumerate(found_images, 1):
226
+ print(f"\n[{i}/{len(found_images)}] 正在处理: {img_file}")
227
+ print("-" * 40)
228
+
229
+ full_path = os.path.join(directory_path, img_file)
230
+ result = parse_qr_code_advanced(full_path)
231
 
232
  if result:
233
+ success_count += 1
234
+ print(f"\n✅ 成功解析!")
235
+ print(f"内容: {result}")
236
+
237
+ # 如果是微信支付链接,特别标注
238
+ if result.startswith('wxp://'):
239
+ print("类型: 微信支付二维码")
240
+ elif 'weixin://' in result or 'wx.tenpay.com' in result:
241
+ print("类型: 微信相关链接")
242
  else:
243
+ print(f"\n❌ 无法解析此文件")
244
+
245
+ print("=" * 60)
246
+
247
+ print(f"\n\n总结: 成功解析 {success_count}/{len(found_images)} 个文件")
248
 
249
  # 使用示例
250
  if __name__ == "__main__":
251
+ print("=== 增强版二维码解析工具 ===")
252
+ print("支持圆形、方形等各种形状的二维码\n")
253
+
254
+ # 批量处理当前目录
255
+ batch_process_directory()
256
+
257
+ # 或者处理单个文件
258
+ # result = parse_qr_code_advanced("your_circular_qr_code.jpg")
259
+ # if result:
260
+ # print(f"解析结果: {result}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
avatar.jpg ADDED
index.html CHANGED
@@ -3,9 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
- <title>收款</title>
7
- <!-- 引入二维码解析库 -->
8
- <script src="https://cdnjs.cloudflare.com/ajax/libs/jsQR/1.4.0/jsQR.js"></script>
9
  <style>
10
  * {
11
  margin: 0;
@@ -15,50 +13,58 @@
15
 
16
  body {
17
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
18
- background-color: #f7f7f7;
19
- color: #333;
 
20
  }
21
 
22
- .header {
23
- background-color: #fff;
24
- padding: 15px 20px;
 
 
25
  display: flex;
26
- align-items: center;
27
- justify-content: space-between;
28
- box-shadow: 0 1px 1px rgba(0,0,0,0.05);
29
  }
30
 
31
- .header h1 {
32
- font-size: 18px;
33
- font-weight: normal;
34
- flex: 1;
35
  text-align: center;
 
 
36
  }
37
 
38
- .header .back, .header .more {
39
- width: 24px;
40
- height: 24px;
41
- display: flex;
42
- align-items: center;
43
- justify-content: center;
44
- cursor: pointer;
45
  }
46
 
47
- .profile {
48
- background-color: #fff;
 
49
  padding: 20px;
 
 
 
 
50
  display: flex;
51
  align-items: center;
52
- margin-top: 1px;
 
 
 
 
 
53
  }
54
 
55
  .avatar {
56
- width: 50px;
57
- height: 50px;
58
  border-radius: 50%;
59
- margin-right: 15px;
60
- background-color: #e8e8e8;
61
  overflow: hidden;
 
 
62
  }
63
 
64
  .avatar img {
@@ -67,34 +73,67 @@
67
  object-fit: cover;
68
  }
69
 
70
- .info h2 {
 
 
71
  font-size: 16px;
72
- font-weight: normal;
73
- margin-bottom: 5px;
 
 
 
 
 
 
 
74
  }
75
 
76
- .info p {
 
 
 
 
 
 
 
 
 
 
 
 
77
  font-size: 14px;
78
- color: #888;
79
  }
80
 
81
  .amount-section {
82
- background-color: #fff;
83
- padding: 30px 20px;
84
- margin-top: 10px;
 
 
 
 
 
 
 
 
85
  text-align: center;
 
86
  }
87
 
88
  .amount-label {
89
- font-size: 14px;
90
- color: #333;
91
- margin-bottom: 10px;
 
92
  }
93
 
94
- .amount {
95
- font-size: 48px;
96
- font-weight: 500;
97
- margin-bottom: 30px;
 
 
 
98
  }
99
 
100
  .payment-items {
@@ -102,291 +141,408 @@
102
  grid-template-columns: repeat(2, 1fr);
103
  gap: 10px;
104
  margin-bottom: 20px;
 
 
105
  }
106
 
107
  .payment-item {
108
- background-color: #f7f7f7;
109
- padding: 15px;
110
- border-radius: 8px;
111
  text-align: center;
112
  cursor: pointer;
113
- transition: all 0.3s ease;
114
  border: 2px solid transparent;
 
 
 
 
 
 
 
115
  }
116
 
117
  .payment-item.active {
118
- background-color: #e7f7e7;
119
- border-color: #4CAF50;
120
  }
121
 
122
  .payment-item .emoji {
123
- font-size: 24px;
124
- margin-bottom: 5px;
 
 
 
 
 
 
 
125
  }
126
 
127
  .payment-item .price {
128
- font-size: 18px;
129
- font-weight: 500;
130
- color: #333;
131
  }
132
 
133
  .payment-item .quantity {
134
  display: inline-block;
135
- background-color: #4CAF50;
136
  color: white;
137
- padding: 2px 8px;
138
- border-radius: 12px;
139
- font-size: 12px;
140
- margin-left: 5px;
 
141
  }
142
 
143
- .note {
144
- text-align: left;
145
- padding: 0 20px;
146
- margin-bottom: 20px;
147
  }
148
 
149
  .note-label {
150
- font-size: 14px;
151
- color: #888;
152
- margin-bottom: 10px;
 
153
  }
154
 
155
  .note-input {
156
  width: 100%;
157
- padding: 10px;
158
- border: 1px solid #e0e0e0;
159
- border-radius: 4px;
160
  font-size: 14px;
161
- background-color: #f7f7f7;
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  }
163
 
164
  .pay-button {
165
- background-color: #4CAF50;
166
  color: white;
167
  border: none;
168
- padding: 15px 40px;
169
- font-size: 18px;
 
170
  border-radius: 25px;
171
  cursor: pointer;
172
- width: calc(100% - 40px);
173
- margin: 20px;
174
- transition: background-color 0.3s ease;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  }
176
 
177
  .pay-button:hover {
178
- background-color: #45a049;
 
179
  }
180
 
181
  .pay-button:active {
182
- transform: scale(0.98);
183
  }
184
 
185
- /* 支付处理覆盖层 */
186
- .payment-overlay {
187
  display: none;
188
  position: fixed;
189
  top: 0;
190
  left: 0;
191
  width: 100%;
192
  height: 100%;
193
- background-color: rgba(0,0,0,0.7);
 
194
  z-index: 1000;
195
  align-items: center;
196
  justify-content: center;
197
  }
198
 
199
- .payment-processing {
200
- background-color: white;
201
- padding: 40px;
202
- border-radius: 10px;
203
  text-align: center;
204
- max-width: 350px;
205
  width: 90%;
 
 
 
206
  }
207
 
208
- .loading-spinner {
209
- width: 50px;
210
- height: 50px;
211
- margin: 20px auto;
212
- border: 3px solid #f3f3f3;
213
- border-top: 3px solid #4CAF50;
214
- border-radius: 50%;
215
- animation: spin 1s linear infinite;
 
216
  }
217
 
218
- @keyframes spin {
219
- 0% { transform: rotate(0deg); }
220
- 100% { transform: rotate(360deg); }
 
 
221
  }
222
 
223
- .payment-message {
224
- font-size: 16px;
225
- color: #333;
226
- margin: 20px 0;
 
 
 
227
  }
228
 
229
- .payment-submessage {
230
- font-size: 14px;
231
- color: #666;
232
- margin-top: 10px;
 
 
233
  }
234
 
235
- .payment-actions {
236
- margin-top: 30px;
 
 
237
  }
238
 
239
- .action-button {
240
- padding: 10px 20px;
241
- margin: 5px;
242
- border: none;
243
- border-radius: 5px;
244
- cursor: pointer;
245
- font-size: 14px;
246
- transition: all 0.3s ease;
247
  }
248
 
249
- .action-button.primary {
250
- background-color: #4CAF50;
251
- color: white;
 
 
252
  }
253
 
254
- .action-button.secondary {
255
- background-color: #f0f0f0;
256
- color: #333;
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  }
258
 
259
- .action-button:hover {
260
- opacity: 0.9;
261
- transform: translateY(-1px);
 
262
  }
263
 
264
- /* 隐藏的canvas用于二维码解析 */
265
- #qrCanvas {
266
- display: none;
 
 
 
 
267
  }
268
 
269
- /* 错误提示样式 */
270
- .error-state {
271
- display: none;
272
- padding: 20px;
273
- text-align: center;
274
- }
275
 
276
- .error-icon {
277
- font-size: 48px;
278
- color: #f44336;
279
- margin-bottom: 20px;
280
  }
281
 
282
  /* 响应式优化 */
283
- @media (max-width: 480px) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
  .payment-items {
285
- grid-template-columns: repeat(2, 1fr);
286
  gap: 8px;
287
  }
288
-
289
  .payment-item {
290
- padding: 12px;
291
  }
292
-
293
- .amount {
294
- font-size: 36px;
 
 
 
 
 
 
 
 
 
 
 
 
295
  }
296
  }
297
  </style>
298
  </head>
299
  <body>
300
- <div class="header">
301
- <div class="back" onclick="goBack()">←</div>
302
- <h1>收款</h1>
303
- <div class="more">⋯</div>
304
- </div>
305
 
306
- <div class="profile">
307
- <div class="avatar">
308
- <img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Crect width='100' height='100' fill='%23e8e8e8'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='.3em' font-size='40' fill='%23999'%3E👤%3C/text%3E%3C/svg%3E" alt="头像">
309
- </div>
310
- <div class="info">
311
- <h2>收款给 个人</h2>
312
- <p>SUNRISE(*晓)</p>
313
  </div>
314
- </div>
315
-
316
- <div class="amount-section">
317
- <div class="amount-label">付款金额</div>
318
- <div class="amount">¥<span id="totalAmount">1.00</span></div>
319
-
320
- <div class="payment-items">
321
- <div class="payment-item active" data-amount="1.00" onclick="selectItem(this)">
322
- <div class="emoji">=>v0=</div>
323
- <div class="price">¥1.00</div>
324
- <span class="quantity" id="qty-1">×1</span>
325
- </div>
326
- <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
327
- <div class="emoji">≦∴v <∸ ᴖ</div>
328
- <div class="price">¥5.20</div>
329
  </div>
330
- <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
331
- <div class="emoji">᷈>ಞ<᷈</div>
332
- <div class="price">¥5.20</div>
333
  </div>
334
- <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
335
- <div class="emoji">☆ฺᵒᵍ☆ฺ</div>
336
- <div class="price">¥5.20</div>
 
 
 
337
  </div>
338
- <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
339
- <div class="emoji">=>ヽ<≈⊙</div>
340
- <div class="price">¥5.20</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  </div>
342
- <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
343
- <div class="emoji">ଳ∪ᴖ⊙</div>
344
- <div class="price">¥5.20</div>
 
345
  </div>
346
- </div>
347
-
348
- <div class="note">
349
- <div class="note-label">添加备注</div>
350
- <input type="text" class="note-input" placeholder="请输入备注信息">
351
  </div>
352
  </div>
353
 
354
- <button class="pay-button" onclick="processPayment()">付款</button>
355
-
356
- <!-- 支付处理覆盖层 -->
357
- <div class="payment-overlay" id="paymentOverlay">
358
- <div class="payment-processing">
359
- <!-- 加载状态 -->
360
- <div id="loadingState">
361
- <div class="loading-spinner"></div>
362
- <div class="payment-message">正在处理支付请求...</div>
363
- <div class="payment-submessage">系统正在识别支付方式</div>
364
- </div>
365
-
366
- <!-- 错误状态 -->
367
- <div id="errorState" class="error-state">
368
- <div class="error-icon">⚠️</div>
369
- <div class="payment-message">无法完成支付</div>
370
- <div class="payment-submessage">请确保您已安装微信并重试</div>
371
- <div class="payment-actions">
372
- <button class="action-button secondary" onclick="retryPayment()">重试</button>
373
- <button class="action-button secondary" onclick="cancelPayment()">取消</button>
374
  </div>
375
  </div>
 
 
 
 
 
 
 
 
376
  </div>
377
  </div>
378
 
379
- <!-- 隐藏的元素用于二维码处理 -->
380
- <canvas id="qrCanvas"></canvas>
381
- <img id="hiddenQRImage" style="display: none;">
382
-
383
  <script>
384
- // 配置项
385
- const CONFIG = {
386
- // 二维码图片文件名(与HTML同目录)
387
- qrCodeImagePath: '微信图片_20250609201923.jpg'
388
- };
389
-
390
  let selectedItems = new Set();
391
  let itemQuantities = {};
392
 
@@ -398,7 +554,7 @@
398
  const amount = element.dataset.amount;
399
 
400
  if (selectedItems.has(amount)) {
401
- // 如果已选中,增加数量
402
  itemQuantities[amount] = (itemQuantities[amount] || 1) + 1;
403
 
404
  // 更新数量显示
@@ -432,110 +588,40 @@
432
  total += parseFloat(amount) * (itemQuantities[amount] || 1);
433
  });
434
  document.getElementById('totalAmount').textContent = total.toFixed(2);
 
435
  }
436
 
437
- // 解析二维码图片
438
- function decodeQRCode(imagePath) {
439
- return new Promise((resolve, reject) => {
440
- const img = document.getElementById('hiddenQRImage');
441
- const canvas = document.getElementById('qrCanvas');
442
- const ctx = canvas.getContext('2d');
443
-
444
- img.onload = function() {
445
- // 设置canvas尺寸
446
- canvas.width = img.width;
447
- canvas.height = img.height;
448
-
449
- // 绘制图片到canvas
450
- ctx.drawImage(img, 0, 0);
451
-
452
- // 获取图像数据
453
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
454
-
455
- // 使用jsQR解析
456
- const code = jsQR(imageData.data, imageData.width, imageData.height);
457
-
458
- if (code) {
459
- resolve(code.data);
460
- } else {
461
- reject(new Error('无法识别二维码'));
462
- }
463
- };
464
-
465
- img.onerror = function() {
466
- reject(new Error('无法加载二维码图片'));
467
- };
468
-
469
- // 设置图片源
470
- img.src = imagePath;
471
- });
472
- }
473
-
474
- // 处理支付
475
- async function processPayment() {
476
- const overlay = document.getElementById('paymentOverlay');
477
- const loadingState = document.getElementById('loadingState');
478
- const errorState = document.getElementById('errorState');
479
-
480
- // 显示加载状态
481
- overlay.style.display = 'flex';
482
- loadingState.style.display = 'block';
483
- errorState.style.display = 'none';
484
-
485
- try {
486
- // 解析二维码
487
- const qrData = await decodeQRCode(CONFIG.qrCodeImagePath);
488
- console.log('二维码解析结果:', qrData);
489
-
490
- // 检查是否为微信支付链接
491
- if (qrData.startsWith('wxp://')) {
492
- // 尝试跳转到微信支付
493
- setTimeout(() => {
494
- window.location.href = qrData;
495
-
496
- // 设置超时检查
497
- setTimeout(() => {
498
- // 如果3秒后页面还在,说明跳转失败
499
- loadingState.style.display = 'none';
500
- errorState.style.display = 'block';
501
- }, 3000);
502
- }, 1000);
503
- } else if (qrData.includes('weixin://') || qrData.includes('https://wx.tenpay.com')) {
504
- // 其他微信相关链接
505
- window.location.href = qrData;
506
- } else {
507
- // 不是微信支付链接
508
- throw new Error('非微信支付二维码');
509
- }
510
- } catch (error) {
511
- console.error('处理支付时出错:', error);
512
- // 显示错误状态
513
- loadingState.style.display = 'none';
514
- errorState.style.display = 'block';
515
- }
516
  }
517
 
518
- // 重试支付
519
- function retryPayment() {
520
- processPayment();
521
- }
522
-
523
- // 取消支付
524
- function cancelPayment() {
525
- const overlay = document.getElementById('paymentOverlay');
526
- overlay.style.display = 'none';
527
-
528
- // 重置显示状态
529
- document.getElementById('loadingState').style.display = 'block';
530
- document.getElementById('errorState').style.display = 'none';
531
  }
532
 
533
- function goBack() {
534
- window.history.back();
535
- }
 
 
 
536
 
537
- // 初始化页面
538
  updateTotalAmount();
 
 
 
 
 
 
 
 
 
 
539
  </script>
540
  </body>
541
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
6
+ <title>💖 收款 💖</title>
 
 
7
  <style>
8
  * {
9
  margin: 0;
 
13
 
14
  body {
15
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
16
+ background: linear-gradient(135deg, #ffeef8 0%, #ffe0f0 35%, #fbd3e9 100%);
17
+ min-height: 100vh;
18
+ color: #5a4a5a;
19
  }
20
 
21
+ .container {
22
+ max-width: 480px;
23
+ margin: 0 auto;
24
+ padding: 15px;
25
+ min-height: 100vh;
26
  display: flex;
27
+ flex-direction: column;
 
 
28
  }
29
 
30
+ .header {
 
 
 
31
  text-align: center;
32
+ margin-bottom: 20px;
33
+ padding-top: 10px;
34
  }
35
 
36
+ .header h1 {
37
+ font-size: 24px;
38
+ color: #ff6b9d;
39
+ font-weight: 600;
40
+ text-shadow: 2px 2px 4px rgba(255, 182, 193, 0.3);
 
 
41
  }
42
 
43
+ .profile-card {
44
+ background: rgba(255, 255, 255, 0.9);
45
+ border-radius: 20px;
46
  padding: 20px;
47
+ box-shadow: 0 8px 32px rgba(255, 182, 193, 0.2);
48
+ backdrop-filter: blur(10px);
49
+ margin-bottom: 20px;
50
+ text-align: center;
51
  display: flex;
52
  align-items: center;
53
+ gap: 15px;
54
+ }
55
+
56
+ .avatar-wrapper {
57
+ position: relative;
58
+ flex-shrink: 0;
59
  }
60
 
61
  .avatar {
62
+ width: 60px;
63
+ height: 60px;
64
  border-radius: 50%;
 
 
65
  overflow: hidden;
66
+ box-shadow: 0 4px 15px rgba(255, 182, 193, 0.4);
67
+ background: #ffe0f0;
68
  }
69
 
70
  .avatar img {
 
73
  object-fit: cover;
74
  }
75
 
76
+ .sparkle {
77
+ position: absolute;
78
+ color: #ffb6c1;
79
  font-size: 16px;
80
+ animation: sparkle 2s ease-in-out infinite;
81
+ }
82
+
83
+ .sparkle:nth-child(2) { top: -8px; right: -8px; animation-delay: 0.3s; }
84
+ .sparkle:nth-child(3) { bottom: -8px; left: -8px; animation-delay: 0.6s; }
85
+
86
+ @keyframes sparkle {
87
+ 0%, 100% { opacity: 0; transform: scale(0.8); }
88
+ 50% { opacity: 1; transform: scale(1.2); }
89
  }
90
 
91
+ .profile-info {
92
+ text-align: left;
93
+ flex: 1;
94
+ }
95
+
96
+ .profile-info h2 {
97
+ font-size: 18px;
98
+ color: #ff6b9d;
99
+ margin-bottom: 3px;
100
+ }
101
+
102
+ .profile-info p {
103
+ color: #a8a8a8;
104
  font-size: 14px;
 
105
  }
106
 
107
  .amount-section {
108
+ background: rgba(255, 255, 255, 0.95);
109
+ border-radius: 20px;
110
+ padding: 20px 15px;
111
+ box-shadow: 0 8px 32px rgba(255, 182, 193, 0.2);
112
+ backdrop-filter: blur(10px);
113
+ flex: 1;
114
+ display: flex;
115
+ flex-direction: column;
116
+ }
117
+
118
+ .amount-display {
119
  text-align: center;
120
+ margin-bottom: 20px;
121
  }
122
 
123
  .amount-label {
124
+ font-size: 13px;
125
+ color: #ff9a9e;
126
+ margin-bottom: 8px;
127
+ font-weight: 500;
128
  }
129
 
130
+ .amount-value {
131
+ font-size: 36px;
132
+ font-weight: 700;
133
+ background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
134
+ -webkit-background-clip: text;
135
+ -webkit-text-fill-color: transparent;
136
+ background-clip: text;
137
  }
138
 
139
  .payment-items {
 
141
  grid-template-columns: repeat(2, 1fr);
142
  gap: 10px;
143
  margin-bottom: 20px;
144
+ flex: 1;
145
+ align-content: start;
146
  }
147
 
148
  .payment-item {
149
+ background: rgba(255, 245, 251, 0.8);
150
+ padding: 12px;
151
+ border-radius: 12px;
152
  text-align: center;
153
  cursor: pointer;
154
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
155
  border: 2px solid transparent;
156
+ position: relative;
157
+ overflow: hidden;
158
+ }
159
+
160
+ .payment-item:hover {
161
+ transform: translateY(-2px);
162
+ box-shadow: 0 4px 12px rgba(255, 182, 193, 0.25);
163
  }
164
 
165
  .payment-item.active {
166
+ border-color: #ff9a9e;
167
+ box-shadow: 0 0 0 3px rgba(255, 154, 158, 0.15);
168
  }
169
 
170
  .payment-item .emoji {
171
+ font-size: 20px;
172
+ margin-bottom: 6px;
173
+ display: block;
174
+ filter: drop-shadow(2px 2px 4px rgba(255, 182, 193, 0.3));
175
+ transition: transform 0.3s ease;
176
+ }
177
+
178
+ .payment-item:hover .emoji {
179
+ transform: scale(1.1);
180
  }
181
 
182
  .payment-item .price {
183
+ font-size: 15px;
184
+ font-weight: 600;
185
+ color: #ff6b9d;
186
  }
187
 
188
  .payment-item .quantity {
189
  display: inline-block;
190
+ background: #ff9a9e;
191
  color: white;
192
+ padding: 1px 6px;
193
+ border-radius: 8px;
194
+ font-size: 11px;
195
+ margin-left: 4px;
196
+ font-weight: 600;
197
  }
198
 
199
+ .note-section {
200
+ margin-bottom: 15px;
 
 
201
  }
202
 
203
  .note-label {
204
+ font-size: 13px;
205
+ color: #ff9a9e;
206
+ margin-bottom: 6px;
207
+ font-weight: 500;
208
  }
209
 
210
  .note-input {
211
  width: 100%;
212
+ padding: 10px 12px;
213
+ border: 2px solid #ffe0f0;
214
+ border-radius: 10px;
215
  font-size: 14px;
216
+ background: rgba(255, 255, 255, 0.8);
217
+ transition: all 0.3s ease;
218
+ color: #5a4a5a;
219
+ }
220
+
221
+ .note-input:focus {
222
+ outline: none;
223
+ border-color: #ffb6c1;
224
+ background: white;
225
+ box-shadow: 0 0 0 3px rgba(255, 182, 193, 0.2);
226
+ }
227
+
228
+ .note-input::placeholder {
229
+ color: #d4a5a5;
230
  }
231
 
232
  .pay-button {
233
+ background: linear-gradient(135deg, #ff6b9d 0%, #ff9a9e 100%);
234
  color: white;
235
  border: none;
236
+ padding: 14px 30px;
237
+ font-size: 16px;
238
+ font-weight: 600;
239
  border-radius: 25px;
240
  cursor: pointer;
241
+ width: 100%;
242
+ transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
243
+ box-shadow: 0 4px 15px rgba(255, 107, 157, 0.4);
244
+ position: relative;
245
+ overflow: hidden;
246
+ }
247
+
248
+ .pay-button::before {
249
+ content: '';
250
+ position: absolute;
251
+ top: 50%;
252
+ left: 50%;
253
+ width: 0;
254
+ height: 0;
255
+ background: rgba(255, 255, 255, 0.3);
256
+ border-radius: 50%;
257
+ transform: translate(-50%, -50%);
258
+ transition: width 0.6s, height 0.6s;
259
+ }
260
+
261
+ .pay-button:hover::before {
262
+ width: 300px;
263
+ height: 300px;
264
  }
265
 
266
  .pay-button:hover {
267
+ transform: translateY(-2px);
268
+ box-shadow: 0 6px 20px rgba(255, 107, 157, 0.5);
269
  }
270
 
271
  .pay-button:active {
272
+ transform: translateY(0);
273
  }
274
 
275
+ /* 模态框样式 */
276
+ .modal {
277
  display: none;
278
  position: fixed;
279
  top: 0;
280
  left: 0;
281
  width: 100%;
282
  height: 100%;
283
+ background: rgba(255, 182, 193, 0.95);
284
+ backdrop-filter: blur(10px);
285
  z-index: 1000;
286
  align-items: center;
287
  justify-content: center;
288
  }
289
 
290
+ .modal-content {
291
+ background: white;
292
+ padding: 30px 25px;
293
+ border-radius: 25px;
294
  text-align: center;
295
+ max-width: 320px;
296
  width: 90%;
297
+ box-shadow: 0 20px 60px rgba(255, 107, 157, 0.3);
298
+ position: relative;
299
+ animation: modalFadeIn 0.4s ease-out;
300
  }
301
 
302
+ @keyframes modalFadeIn {
303
+ from {
304
+ opacity: 0;
305
+ transform: scale(0.9) translateY(20px);
306
+ }
307
+ to {
308
+ opacity: 1;
309
+ transform: scale(1) translateY(0);
310
+ }
311
  }
312
 
313
+ .modal-title {
314
+ font-size: 18px;
315
+ color: #ff6b9d;
316
+ margin-bottom: 15px;
317
+ font-weight: 600;
318
  }
319
 
320
+ .qr-wrapper {
321
+ position: relative;
322
+ display: inline-block;
323
+ padding: 12px;
324
+ background: linear-gradient(135deg, #fff5fb 0%, #ffe0f0 100%);
325
+ border-radius: 18px;
326
+ margin-bottom: 15px;
327
  }
328
 
329
+ .qr-code-image {
330
+ width: 180px;
331
+ height: 180px;
332
+ border-radius: 12px;
333
+ overflow: hidden;
334
+ box-shadow: 0 4px 15px rgba(255, 182, 193, 0.3);
335
  }
336
 
337
+ .qr-code-image img {
338
+ width: 100%;
339
+ height: 100%;
340
+ display: block;
341
  }
342
 
343
+ .payment-tips {
344
+ font-size: 13px;
345
+ color: #a8a8a8;
346
+ line-height: 1.5;
347
+ margin-bottom: 15px;
 
 
 
348
  }
349
 
350
+ .payment-amount-display {
351
+ font-size: 22px;
352
+ color: #ff6b9d;
353
+ font-weight: 600;
354
+ margin: 10px 0;
355
  }
356
 
357
+ .close-button {
358
+ position: absolute;
359
+ top: 12px;
360
+ right: 12px;
361
+ width: 32px;
362
+ height: 32px;
363
+ border-radius: 50%;
364
+ background: #ffe0f0;
365
+ border: none;
366
+ cursor: pointer;
367
+ display: flex;
368
+ align-items: center;
369
+ justify-content: center;
370
+ font-size: 18px;
371
+ color: #ff9a9e;
372
+ transition: all 0.3s ease;
373
  }
374
 
375
+ .close-button:hover {
376
+ background: #ffb6c1;
377
+ color: white;
378
+ transform: rotate(90deg);
379
  }
380
 
381
+ /* 装饰元素 */
382
+ .decoration {
383
+ position: fixed;
384
+ pointer-events: none;
385
+ opacity: 0.5;
386
+ animation: float 6s ease-in-out infinite;
387
+ font-size: 20px;
388
  }
389
 
390
+ .decoration:nth-child(1) { top: 10%; left: 5%; animation-delay: 0s; }
391
+ .decoration:nth-child(2) { top: 20%; right: 5%; animation-delay: 1s; }
392
+ .decoration:nth-child(3) { bottom: 20%; left: 10%; animation-delay: 2s; }
393
+ .decoration:nth-child(4) { bottom: 10%; right: 10%; animation-delay: 3s; }
 
 
394
 
395
+ @keyframes float {
396
+ 0%, 100% { transform: translateY(0) rotate(0deg); }
397
+ 50% { transform: translateY(-15px) rotate(10deg); }
 
398
  }
399
 
400
  /* 响应式优化 */
401
+ @media (max-height: 700px) {
402
+ .container {
403
+ padding: 10px;
404
+ }
405
+ .header {
406
+ margin-bottom: 15px;
407
+ padding-top: 5px;
408
+ }
409
+ .header h1 {
410
+ font-size: 22px;
411
+ }
412
+ .profile-card {
413
+ padding: 15px;
414
+ margin-bottom: 15px;
415
+ }
416
+ .avatar {
417
+ width: 50px;
418
+ height: 50px;
419
+ }
420
+ .amount-section {
421
+ padding: 15px 12px;
422
+ }
423
+ .amount-value {
424
+ font-size: 32px;
425
+ }
426
  .payment-items {
 
427
  gap: 8px;
428
  }
 
429
  .payment-item {
430
+ padding: 10px;
431
  }
432
+ }
433
+
434
+ @media (max-height: 600px) {
435
+ .amount-display {
436
+ margin-bottom: 15px;
437
+ }
438
+ .payment-items {
439
+ margin-bottom: 15px;
440
+ }
441
+ .note-section {
442
+ margin-bottom: 12px;
443
+ }
444
+ .pay-button {
445
+ padding: 12px 25px;
446
+ font-size: 15px;
447
  }
448
  }
449
  </style>
450
  </head>
451
  <body>
452
+ <!-- 装饰元素 -->
453
+ <div class="decoration">💕</div>
454
+ <div class="decoration">✨</div>
455
+ <div class="decoration">🌸</div>
456
+ <div class="decoration">💖</div>
457
 
458
+ <div class="container">
459
+ <div class="header">
460
+ <h1>ଘ(੭ˊ꒳ˋ)੭ 收款页面</h1>
 
 
 
 
461
  </div>
462
+
463
+ <div class="profile-card">
464
+ <div class="avatar-wrapper">
465
+ <div class="avatar">
466
+ <!-- 自定义头像图片 -->
467
+ <img src="avatar.jpg" alt="头像" onerror="this.style.display='none'; this.parentElement.innerHTML='👧';">
468
+ </div>
469
+ <span class="sparkle">✨</span>
470
+ <span class="sparkle">✨</span>
 
 
 
 
 
 
471
  </div>
472
+ <div class="profile-info">
473
+ <h2>给小可爱的打赏</h2>
474
+ <p>鱼习习(**怡)</p>
475
  </div>
476
+ </div>
477
+
478
+ <div class="amount-section">
479
+ <div class="amount-display">
480
+ <div class="amount-label">打赏金额</div>
481
+ <div class="amount-value">¥<span id="totalAmount">1.00</span></div>
482
  </div>
483
+
484
+ <div class="payment-items">
485
+ <div class="payment-item active" data-amount="1.00" onclick="selectItem(this)">
486
+ <span class="emoji">⊂(˃̶͈̀ε ˂̶͈́ ⊂ )</span>
487
+ <div class="price">¥1.00</div>
488
+ <span class="quantity">×1</span>
489
+ </div>
490
+ <div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
491
+ <span class="emoji">ฅ՞•ﻌ•՞ฅ</span>
492
+ <div class="price">¥5.20</div>
493
+ </div>
494
+ <div class="payment-item" data-amount="6.66" onclick="selectItem(this)">
495
+ <span class="emoji">૮₍ ˃ ⤙ ˂ ₎ა</span>
496
+ <div class="price">¥6.66</div>
497
+ </div>
498
+ <div class="payment-item" data-amount="8.88" onclick="selectItem(this)">
499
+ <span class="emoji">(´・(oo)・`)</span>
500
+ <div class="price">¥8.88</div>
501
+ </div>
502
+ <div class="payment-item" data-amount="13.14" onclick="selectItem(this)">
503
+ <span class="emoji">((づ ̄ ³ ̄)づ</span>
504
+ <div class="price">¥13.14</div>
505
+ </div>
506
+ <div class="payment-item" data-amount="52.00" onclick="selectItem(this)">
507
+ <span class="emoji">(。・ω・。)ノ♡</span>
508
+ <div class="price">¥52.00</div>
509
+ </div>
510
  </div>
511
+
512
+ <div class="note-section">
513
+ <div class="note-label">💌 留言</div>
514
+ <input type="text" class="note-input" placeholder="写点什么暖心的话吧~ ♡">
515
  </div>
516
+
517
+ <button class="pay-button" onclick="showPayment()">
518
+ 💖 确认打赏 💖
519
+ </button>
 
520
  </div>
521
  </div>
522
 
523
+ <!-- 支付模态框 -->
524
+ <div class="modal" id="paymentModal">
525
+ <div class="modal-content">
526
+ <button class="close-button" onclick="closeModal()">×</button>
527
+ <h3 class="modal-title">扫码支付 (。・ω・。)ノ♡</h3>
528
+ <div class="qr-wrapper">
529
+ <div class="qr-code-image">
530
+ <!-- 微信赞赏码 -->
531
+ <img src="wechat_pay.jpg" alt="赞赏码" onerror="this.src='data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' width=\'180\' height=\'180\' viewBox=\'0 0 180 180\'%3E%3Crect width=\'180\' height=\'180\' fill=\'%23ffe0f0\'/%3E%3Ctext x=\'90\' y=\'90\' text-anchor=\'middle\' dy=\'.3em\' font-size=\'13\' fill=\'%23ff9a9e\'%3E请添加赞赏码%3C/text%3E%3C/svg%3E'">
 
 
 
 
 
 
 
 
 
 
 
532
  </div>
533
  </div>
534
+ <div class="payment-amount-display">
535
+ ¥<span id="modalAmount">0.00</span>
536
+ </div>
537
+ <p class="payment-tips">
538
+ 请使用微信扫描上方二维码<br>
539
+ 完成支付 ~ 感谢您的支持<br>
540
+ ଘ(੭ˊ꒳ˋ)੭
541
+ </p>
542
  </div>
543
  </div>
544
 
 
 
 
 
545
  <script>
 
 
 
 
 
 
546
  let selectedItems = new Set();
547
  let itemQuantities = {};
548
 
 
554
  const amount = element.dataset.amount;
555
 
556
  if (selectedItems.has(amount)) {
557
+ // 增加数量
558
  itemQuantities[amount] = (itemQuantities[amount] || 1) + 1;
559
 
560
  // 更新数量显示
 
588
  total += parseFloat(amount) * (itemQuantities[amount] || 1);
589
  });
590
  document.getElementById('totalAmount').textContent = total.toFixed(2);
591
+ document.getElementById('modalAmount').textContent = total.toFixed(2);
592
  }
593
 
594
+ function showPayment() {
595
+ document.getElementById('paymentModal').style.display = 'flex';
596
+ setTimeout(() => {
597
+ document.querySelector('.modal-content').style.animation = 'modalFadeIn 0.4s ease-out';
598
+ }, 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
599
  }
600
 
601
+ function closeModal() {
602
+ const modal = document.getElementById('paymentModal');
603
+ modal.style.display = 'none';
 
 
 
 
 
 
 
 
 
 
604
  }
605
 
606
+ // 点击模态框背景关闭
607
+ document.getElementById('paymentModal').addEventListener('click', function(e) {
608
+ if (e.target === this) {
609
+ closeModal();
610
+ }
611
+ });
612
 
613
+ // 初始化总金额
614
  updateTotalAmount();
615
+
616
+ // 添加交互效果
617
+ document.querySelectorAll('.payment-item').forEach(item => {
618
+ item.addEventListener('mouseenter', function() {
619
+ this.querySelector('.emoji').style.transform = 'scale(1.1)';
620
+ });
621
+ item.addEventListener('mouseleave', function() {
622
+ this.querySelector('.emoji').style.transform = 'scale(1)';
623
+ });
624
+ });
625
  </script>
626
  </body>
627
  </html>
wechat_pay.jpg ADDED