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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 8 |
+
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: 二维码图片的本地路径
|
| 22 |
+
|
| 23 |
+
返回:
|
| 24 |
+
解析出的链接或文本
|
| 25 |
+
"""
|
| 26 |
+
try:
|
| 27 |
+
# 检查文件是否存在
|
| 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 |
+
|
| 150 |
+
if not found_images:
|
| 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}")
|
index.html
CHANGED
|
@@ -1,19 +1,559 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="zh-CN">
|
| 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;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
| 16 |
+
background-color: #f7f7f7;
|
| 17 |
+
color: #333;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
.header {
|
| 21 |
+
background-color: #fff;
|
| 22 |
+
padding: 15px 20px;
|
| 23 |
+
display: flex;
|
| 24 |
+
align-items: center;
|
| 25 |
+
justify-content: space-between;
|
| 26 |
+
box-shadow: 0 1px 1px rgba(0,0,0,0.05);
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
.header h1 {
|
| 30 |
+
font-size: 18px;
|
| 31 |
+
font-weight: normal;
|
| 32 |
+
flex: 1;
|
| 33 |
+
text-align: center;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
.header .back, .header .more {
|
| 37 |
+
width: 24px;
|
| 38 |
+
height: 24px;
|
| 39 |
+
display: flex;
|
| 40 |
+
align-items: center;
|
| 41 |
+
justify-content: center;
|
| 42 |
+
cursor: pointer;
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
.profile {
|
| 46 |
+
background-color: #fff;
|
| 47 |
+
padding: 20px;
|
| 48 |
+
display: flex;
|
| 49 |
+
align-items: center;
|
| 50 |
+
margin-top: 1px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.avatar {
|
| 54 |
+
width: 50px;
|
| 55 |
+
height: 50px;
|
| 56 |
+
border-radius: 50%;
|
| 57 |
+
margin-right: 15px;
|
| 58 |
+
background-color: #e8e8e8;
|
| 59 |
+
overflow: hidden;
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
.avatar img {
|
| 63 |
+
width: 100%;
|
| 64 |
+
height: 100%;
|
| 65 |
+
object-fit: cover;
|
| 66 |
+
}
|
| 67 |
+
|
| 68 |
+
.info h2 {
|
| 69 |
+
font-size: 16px;
|
| 70 |
+
font-weight: normal;
|
| 71 |
+
margin-bottom: 5px;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.info p {
|
| 75 |
+
font-size: 14px;
|
| 76 |
+
color: #888;
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
.amount-section {
|
| 80 |
+
background-color: #fff;
|
| 81 |
+
padding: 30px 20px;
|
| 82 |
+
margin-top: 10px;
|
| 83 |
+
text-align: center;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
.amount-label {
|
| 87 |
+
font-size: 14px;
|
| 88 |
+
color: #333;
|
| 89 |
+
margin-bottom: 10px;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
.amount {
|
| 93 |
+
font-size: 48px;
|
| 94 |
+
font-weight: 500;
|
| 95 |
+
margin-bottom: 30px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.payment-items {
|
| 99 |
+
display: grid;
|
| 100 |
+
grid-template-columns: repeat(2, 1fr);
|
| 101 |
+
gap: 10px;
|
| 102 |
+
margin-bottom: 20px;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
.payment-item {
|
| 106 |
+
background-color: #f7f7f7;
|
| 107 |
+
padding: 15px;
|
| 108 |
+
border-radius: 8px;
|
| 109 |
+
text-align: center;
|
| 110 |
+
cursor: pointer;
|
| 111 |
+
transition: all 0.3s ease;
|
| 112 |
+
border: 2px solid transparent;
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
.payment-item.active {
|
| 116 |
+
background-color: #e7f7e7;
|
| 117 |
+
border-color: #4CAF50;
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
.payment-item .emoji {
|
| 121 |
+
font-size: 24px;
|
| 122 |
+
margin-bottom: 5px;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.payment-item .price {
|
| 126 |
+
font-size: 18px;
|
| 127 |
+
font-weight: 500;
|
| 128 |
+
color: #333;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.payment-item .quantity {
|
| 132 |
+
display: inline-block;
|
| 133 |
+
background-color: #4CAF50;
|
| 134 |
+
color: white;
|
| 135 |
+
padding: 2px 8px;
|
| 136 |
+
border-radius: 12px;
|
| 137 |
+
font-size: 12px;
|
| 138 |
+
margin-left: 5px;
|
| 139 |
+
}
|
| 140 |
+
|
| 141 |
+
.note {
|
| 142 |
+
text-align: left;
|
| 143 |
+
padding: 0 20px;
|
| 144 |
+
margin-bottom: 20px;
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
.note-label {
|
| 148 |
+
font-size: 14px;
|
| 149 |
+
color: #888;
|
| 150 |
+
margin-bottom: 10px;
|
| 151 |
+
}
|
| 152 |
+
|
| 153 |
+
.note-input {
|
| 154 |
+
width: 100%;
|
| 155 |
+
padding: 10px;
|
| 156 |
+
border: 1px solid #e0e0e0;
|
| 157 |
+
border-radius: 4px;
|
| 158 |
+
font-size: 14px;
|
| 159 |
+
background-color: #f7f7f7;
|
| 160 |
+
}
|
| 161 |
+
|
| 162 |
+
.pay-button {
|
| 163 |
+
background-color: #4CAF50;
|
| 164 |
+
color: white;
|
| 165 |
+
border: none;
|
| 166 |
+
padding: 15px 40px;
|
| 167 |
+
font-size: 18px;
|
| 168 |
+
border-radius: 25px;
|
| 169 |
+
cursor: pointer;
|
| 170 |
+
width: calc(100% - 40px);
|
| 171 |
+
margin: 20px;
|
| 172 |
+
transition: background-color 0.3s ease;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
.pay-button:hover {
|
| 176 |
+
background-color: #45a049;
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
.pay-button:active {
|
| 180 |
+
transform: scale(0.98);
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/* 支付处理覆盖层 */
|
| 184 |
+
.payment-overlay {
|
| 185 |
+
display: none;
|
| 186 |
+
position: fixed;
|
| 187 |
+
top: 0;
|
| 188 |
+
left: 0;
|
| 189 |
+
width: 100%;
|
| 190 |
+
height: 100%;
|
| 191 |
+
background-color: rgba(0,0,0,0.7);
|
| 192 |
+
z-index: 1000;
|
| 193 |
+
align-items: center;
|
| 194 |
+
justify-content: center;
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
.payment-processing {
|
| 198 |
+
background-color: white;
|
| 199 |
+
padding: 40px;
|
| 200 |
+
border-radius: 10px;
|
| 201 |
+
text-align: center;
|
| 202 |
+
max-width: 350px;
|
| 203 |
+
width: 90%;
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
.loading-spinner {
|
| 207 |
+
width: 50px;
|
| 208 |
+
height: 50px;
|
| 209 |
+
margin: 20px auto;
|
| 210 |
+
border: 3px solid #f3f3f3;
|
| 211 |
+
border-top: 3px solid #4CAF50;
|
| 212 |
+
border-radius: 50%;
|
| 213 |
+
animation: spin 1s linear infinite;
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
@keyframes spin {
|
| 217 |
+
0% { transform: rotate(0deg); }
|
| 218 |
+
100% { transform: rotate(360deg); }
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.payment-message {
|
| 222 |
+
font-size: 16px;
|
| 223 |
+
color: #333;
|
| 224 |
+
margin: 20px 0;
|
| 225 |
+
}
|
| 226 |
+
|
| 227 |
+
.payment-submessage {
|
| 228 |
+
font-size: 14px;
|
| 229 |
+
color: #666;
|
| 230 |
+
margin-top: 10px;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.payment-actions {
|
| 234 |
+
margin-top: 30px;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.action-button {
|
| 238 |
+
padding: 10px 20px;
|
| 239 |
+
margin: 5px;
|
| 240 |
+
border: none;
|
| 241 |
+
border-radius: 5px;
|
| 242 |
+
cursor: pointer;
|
| 243 |
+
font-size: 14px;
|
| 244 |
+
transition: all 0.3s ease;
|
| 245 |
+
}
|
| 246 |
+
|
| 247 |
+
.action-button.primary {
|
| 248 |
+
background-color: #4CAF50;
|
| 249 |
+
color: white;
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
.action-button.secondary {
|
| 253 |
+
background-color: #f0f0f0;
|
| 254 |
+
color: #333;
|
| 255 |
+
}
|
| 256 |
+
|
| 257 |
+
.action-button:hover {
|
| 258 |
+
opacity: 0.9;
|
| 259 |
+
transform: translateY(-1px);
|
| 260 |
+
}
|
| 261 |
+
|
| 262 |
+
/* 二维码显示区域 */
|
| 263 |
+
.qr-container {
|
| 264 |
+
display: none;
|
| 265 |
+
text-align: center;
|
| 266 |
+
padding: 20px;
|
| 267 |
+
}
|
| 268 |
+
|
| 269 |
+
.qr-code-image {
|
| 270 |
+
width: 200px;
|
| 271 |
+
height: 200px;
|
| 272 |
+
margin: 0 auto 20px;
|
| 273 |
+
padding: 10px;
|
| 274 |
+
background-color: white;
|
| 275 |
+
border-radius: 10px;
|
| 276 |
+
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.qr-code-image img {
|
| 280 |
+
width: 100%;
|
| 281 |
+
height: 100%;
|
| 282 |
+
display: block;
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
+
.payment-tips {
|
| 286 |
+
font-size: 14px;
|
| 287 |
+
color: #666;
|
| 288 |
+
line-height: 1.6;
|
| 289 |
+
}
|
| 290 |
+
|
| 291 |
+
/* 响应式优化 */
|
| 292 |
+
@media (max-width: 480px) {
|
| 293 |
+
.payment-items {
|
| 294 |
+
grid-template-columns: repeat(2, 1fr);
|
| 295 |
+
gap: 8px;
|
| 296 |
+
}
|
| 297 |
+
|
| 298 |
+
.payment-item {
|
| 299 |
+
padding: 12px;
|
| 300 |
+
}
|
| 301 |
+
|
| 302 |
+
.amount {
|
| 303 |
+
font-size: 36px;
|
| 304 |
+
}
|
| 305 |
+
}
|
| 306 |
+
</style>
|
| 307 |
+
</head>
|
| 308 |
+
<body>
|
| 309 |
+
<div class="header">
|
| 310 |
+
<div class="back" onclick="goBack()">←</div>
|
| 311 |
+
<h1>收款</h1>
|
| 312 |
+
<div class="more">⋯</div>
|
| 313 |
+
</div>
|
| 314 |
+
|
| 315 |
+
<div class="profile">
|
| 316 |
+
<div class="avatar">
|
| 317 |
+
<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="头像">
|
| 318 |
+
</div>
|
| 319 |
+
<div class="info">
|
| 320 |
+
<h2>收款给 个人</h2>
|
| 321 |
+
<p>SUNRISE(*晓)</p>
|
| 322 |
+
</div>
|
| 323 |
+
</div>
|
| 324 |
+
|
| 325 |
+
<div class="amount-section">
|
| 326 |
+
<div class="amount-label">付款金额</div>
|
| 327 |
+
<div class="amount">¥<span id="totalAmount">1.00</span></div>
|
| 328 |
+
|
| 329 |
+
<div class="payment-items">
|
| 330 |
+
<div class="payment-item active" data-amount="1.00" onclick="selectItem(this)">
|
| 331 |
+
<div class="emoji">=>v0=</div>
|
| 332 |
+
<div class="price">¥1.00</div>
|
| 333 |
+
<span class="quantity" id="qty-1">×1</span>
|
| 334 |
+
</div>
|
| 335 |
+
<div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
|
| 336 |
+
<div class="emoji">≦∴v <∸ ᴖ</div>
|
| 337 |
+
<div class="price">¥5.20</div>
|
| 338 |
+
</div>
|
| 339 |
+
<div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
|
| 340 |
+
<div class="emoji">᷈>ಞ<᷈</div>
|
| 341 |
+
<div class="price">¥5.20</div>
|
| 342 |
+
</div>
|
| 343 |
+
<div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
|
| 344 |
+
<div class="emoji">☆ฺᵒᵍ☆ฺ</div>
|
| 345 |
+
<div class="price">¥5.20</div>
|
| 346 |
+
</div>
|
| 347 |
+
<div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
|
| 348 |
+
<div class="emoji">=>ヽ<≈⊙</div>
|
| 349 |
+
<div class="price">¥5.20</div>
|
| 350 |
+
</div>
|
| 351 |
+
<div class="payment-item" data-amount="5.20" onclick="selectItem(this)">
|
| 352 |
+
<div class="emoji">ଳ∪ᴖ⊙</div>
|
| 353 |
+
<div class="price">¥5.20</div>
|
| 354 |
+
</div>
|
| 355 |
+
</div>
|
| 356 |
+
|
| 357 |
+
<div class="note">
|
| 358 |
+
<div class="note-label">添加备注</div>
|
| 359 |
+
<input type="text" class="note-input" placeholder="请输入备注信息">
|
| 360 |
+
</div>
|
| 361 |
+
</div>
|
| 362 |
+
|
| 363 |
+
<button class="pay-button" onclick="processPayment()">付款</button>
|
| 364 |
+
|
| 365 |
+
<!-- 支付处理覆盖层 -->
|
| 366 |
+
<div class="payment-overlay" id="paymentOverlay">
|
| 367 |
+
<div class="payment-processing">
|
| 368 |
+
<!-- 初始加载状态 -->
|
| 369 |
+
<div id="loadingState">
|
| 370 |
+
<div class="loading-spinner"></div>
|
| 371 |
+
<div class="payment-message">正在处理支付请求...</div>
|
| 372 |
+
<div class="payment-submessage">正在检测您的支付环境</div>
|
| 373 |
+
</div>
|
| 374 |
+
|
| 375 |
+
<!-- 二维码支付状态 -->
|
| 376 |
+
<div id="qrState" class="qr-container">
|
| 377 |
+
<div class="payment-message">请使用微信扫码支付</div>
|
| 378 |
+
<div class="qr-code-image">
|
| 379 |
+
<!-- 在这里放置您的收款二维码图片 -->
|
| 380 |
+
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Crect width='200' height='200' fill='%23f0f0f0'/%3E%3Ctext x='100' y='100' text-anchor='middle' dy='.3em' font-size='14' fill='%23999'%3E请替换为二维码%3C/text%3E%3C/svg%3E" alt="支付二维码" id="paymentQR">
|
| 381 |
+
</div>
|
| 382 |
+
<div class="payment-tips">
|
| 383 |
+
金额:¥<span id="qrAmount">0.00</span><br>
|
| 384 |
+
请在微信中扫描上方二维码完成支付
|
| 385 |
+
</div>
|
| 386 |
+
<div class="payment-actions">
|
| 387 |
+
<button class="action-button primary" onclick="confirmPayment()">我已完成支付</button>
|
| 388 |
+
<button class="action-button secondary" onclick="cancelPayment()">取消</button>
|
| 389 |
+
</div>
|
| 390 |
+
</div>
|
| 391 |
+
|
| 392 |
+
<!-- 微信内支付提示 -->
|
| 393 |
+
<div id="wechatState" style="display: none;">
|
| 394 |
+
<div class="payment-message">正在跳转到微信支付...</div>
|
| 395 |
+
<div class="payment-submessage">请稍候,系统正在为您处理</div>
|
| 396 |
+
<div class="payment-actions" style="margin-top: 20px;">
|
| 397 |
+
<button class="action-button secondary" onclick="cancelPayment()">取消</button>
|
| 398 |
+
</div>
|
| 399 |
+
</div>
|
| 400 |
+
</div>
|
| 401 |
+
</div>
|
| 402 |
+
|
| 403 |
+
<script>
|
| 404 |
+
// 配置项
|
| 405 |
+
const CONFIG = {
|
| 406 |
+
// 微信支付链接(从二维码解析得到的)
|
| 407 |
+
wechatPayUrl: 'wxp://f2f0uaoKZnUqDIp6w1BYLiXrLJjIntTdVoaTLkQhX8vsZfw',
|
| 408 |
+
// 备用二维码图片路径(请替换为您的实际二维码图片文件名)
|
| 409 |
+
qrCodeImagePath: 'wechat-qr.jpg' // 例如:如果您的二维码文件名是 wechat-qr.jpg
|
| 410 |
+
};
|
| 411 |
+
|
| 412 |
+
let selectedItems = new Set();
|
| 413 |
+
let itemQuantities = {};
|
| 414 |
+
|
| 415 |
+
// 初始化第一个项目
|
| 416 |
+
selectedItems.add('1.00');
|
| 417 |
+
itemQuantities['1.00'] = 1;
|
| 418 |
+
|
| 419 |
+
function selectItem(element) {
|
| 420 |
+
const amount = element.dataset.amount;
|
| 421 |
+
|
| 422 |
+
if (selectedItems.has(amount)) {
|
| 423 |
+
// 如果已选中,增加数量
|
| 424 |
+
itemQuantities[amount] = (itemQuantities[amount] || 1) + 1;
|
| 425 |
+
|
| 426 |
+
// 更新数量显示
|
| 427 |
+
const qtyElement = element.querySelector('.quantity');
|
| 428 |
+
if (!qtyElement) {
|
| 429 |
+
const span = document.createElement('span');
|
| 430 |
+
span.className = 'quantity';
|
| 431 |
+
span.textContent = `×${itemQuantities[amount]}`;
|
| 432 |
+
element.appendChild(span);
|
| 433 |
+
} else {
|
| 434 |
+
qtyElement.textContent = `×${itemQuantities[amount]}`;
|
| 435 |
+
}
|
| 436 |
+
} else {
|
| 437 |
+
// 新选中项目
|
| 438 |
+
element.classList.add('active');
|
| 439 |
+
selectedItems.add(amount);
|
| 440 |
+
itemQuantities[amount] = 1;
|
| 441 |
+
|
| 442 |
+
const span = document.createElement('span');
|
| 443 |
+
span.className = 'quantity';
|
| 444 |
+
span.textContent = '×1';
|
| 445 |
+
element.appendChild(span);
|
| 446 |
+
}
|
| 447 |
+
|
| 448 |
+
updateTotalAmount();
|
| 449 |
+
}
|
| 450 |
+
|
| 451 |
+
function updateTotalAmount() {
|
| 452 |
+
let total = 0;
|
| 453 |
+
selectedItems.forEach(amount => {
|
| 454 |
+
total += parseFloat(amount) * (itemQuantities[amount] || 1);
|
| 455 |
+
});
|
| 456 |
+
document.getElementById('totalAmount').textContent = total.toFixed(2);
|
| 457 |
+
|
| 458 |
+
// 更新二维码显示中的金额
|
| 459 |
+
const qrAmountElement = document.getElementById('qrAmount');
|
| 460 |
+
if (qrAmountElement) {
|
| 461 |
+
qrAmountElement.textContent = total.toFixed(2);
|
| 462 |
+
}
|
| 463 |
+
}
|
| 464 |
+
|
| 465 |
+
// 检测是否在微信内
|
| 466 |
+
function isWechat() {
|
| 467 |
+
const ua = navigator.userAgent.toLowerCase();
|
| 468 |
+
return ua.indexOf('micromessenger') !== -1;
|
| 469 |
+
}
|
| 470 |
+
|
| 471 |
+
// 检测是否为移动设备
|
| 472 |
+
function isMobile() {
|
| 473 |
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
| 474 |
+
}
|
| 475 |
+
|
| 476 |
+
// 处理支付
|
| 477 |
+
function processPayment() {
|
| 478 |
+
const overlay = document.getElementById('paymentOverlay');
|
| 479 |
+
const loadingState = document.getElementById('loadingState');
|
| 480 |
+
const qrState = document.getElementById('qrState');
|
| 481 |
+
const wechatState = document.getElementById('wechatState');
|
| 482 |
+
|
| 483 |
+
overlay.style.display = 'flex';
|
| 484 |
+
|
| 485 |
+
// 获取当前金额
|
| 486 |
+
const currentAmount = document.getElementById('totalAmount').textContent;
|
| 487 |
+
document.getElementById('qrAmount').textContent = currentAmount;
|
| 488 |
+
|
| 489 |
+
// 模拟加载过程
|
| 490 |
+
setTimeout(() => {
|
| 491 |
+
loadingState.style.display = 'none';
|
| 492 |
+
|
| 493 |
+
if (isWechat()) {
|
| 494 |
+
// 在微信内,尝试直接调用支付
|
| 495 |
+
wechatState.style.display = 'block';
|
| 496 |
+
|
| 497 |
+
// 尝试跳转到微信支付
|
| 498 |
+
// 注意:wxp:// 协议通常只能在微信内部使用
|
| 499 |
+
setTimeout(() => {
|
| 500 |
+
try {
|
| 501 |
+
window.location.href = CONFIG.wechatPayUrl;
|
| 502 |
+
} catch (e) {
|
| 503 |
+
console.error('无法调用微信支付:', e);
|
| 504 |
+
// 如果失败,显示二维码
|
| 505 |
+
wechatState.style.display = 'none';
|
| 506 |
+
qrState.style.display = 'block';
|
| 507 |
+
}
|
| 508 |
+
}, 1000);
|
| 509 |
+
} else {
|
| 510 |
+
// 不在微信内,显示二维码
|
| 511 |
+
qrState.style.display = 'block';
|
| 512 |
+
|
| 513 |
+
// 如果有实际的二维码图片路径,替换占位符
|
| 514 |
+
if (CONFIG.qrCodeImagePath && CONFIG.qrCodeImagePath !== 'your-qr-code.jpg') {
|
| 515 |
+
document.getElementById('paymentQR').src = CONFIG.qrCodeImagePath;
|
| 516 |
+
}
|
| 517 |
+
}
|
| 518 |
+
}, 1500);
|
| 519 |
+
}
|
| 520 |
+
|
| 521 |
+
// 确认支付完成
|
| 522 |
+
function confirmPayment() {
|
| 523 |
+
const overlay = document.getElementById('paymentOverlay');
|
| 524 |
+
overlay.style.display = 'none';
|
| 525 |
+
|
| 526 |
+
// 显示支付成功提示
|
| 527 |
+
alert('感谢您的支付!如果支付遇到问题,请联系客服。');
|
| 528 |
+
|
| 529 |
+
// 可以在这里添加支付成功后的处理逻辑
|
| 530 |
+
// 例如:跳转到成功页面、发送支付记录等
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
// 取消支付
|
| 534 |
+
function cancelPayment() {
|
| 535 |
+
const overlay = document.getElementById('paymentOverlay');
|
| 536 |
+
overlay.style.display = 'none';
|
| 537 |
+
|
| 538 |
+
// 重置显示状态
|
| 539 |
+
document.getElementById('loadingState').style.display = 'block';
|
| 540 |
+
document.getElementById('qrState').style.display = 'none';
|
| 541 |
+
document.getElementById('wechatState').style.display = 'none';
|
| 542 |
+
}
|
| 543 |
+
|
| 544 |
+
function goBack() {
|
| 545 |
+
window.history.back();
|
| 546 |
+
}
|
| 547 |
+
|
| 548 |
+
// 点击覆盖层外部区域关闭(仅在显示二维码时)
|
| 549 |
+
document.getElementById('paymentOverlay').addEventListener('click', function(event) {
|
| 550 |
+
if (event.target === this && document.getElementById('qrState').style.display === 'block') {
|
| 551 |
+
cancelPayment();
|
| 552 |
+
}
|
| 553 |
+
});
|
| 554 |
+
|
| 555 |
+
// 初始化页面
|
| 556 |
+
updateTotalAmount();
|
| 557 |
+
</script>
|
| 558 |
+
</body>
|
| 559 |
+
</html>
|
/345/276/256/344/277/241/345/233/276/347/211/207_20250609201923.jpg
ADDED
|