-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
189 lines (167 loc) · 7.95 KB
/
index.html
File metadata and controls
189 lines (167 loc) · 7.95 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>AI Ecommerce Agent | Listing & Copywriter</title>
<style>
*{box-sizing:border-box;margin:0;padding:0;font-family:Arial,sans-serif}
body{max-width:900px;margin:40px auto;padding:0 20px;background:#f5f7fa}
.tool-box{background:white;padding:30px;border-radius:15px;box-shadow:0 3px 12px rgba(0,0,0,0.08);margin-bottom:25px}
h2{color:#2563eb;margin-bottom:10px;font-size:26px}
.sub-title{color:#64748b;margin-bottom:20px;font-size:15px}
.use-limit{color:#475569;font-size:14px;margin-bottom:15px}
.func-select{width:100%;padding:12px;border:1px solid #e2e8f0;border-radius:8px;margin-bottom:15px;font-size:15px}
textarea{width:100%;height:200px;padding:15px;margin:10px 0;border:1px solid #e2e8f0;border-radius:8px;font-size:15px;resize:vertical}
.generate-btn{background:#2563eb;color:white;border:none;padding:14px 28px;border-radius:8px;cursor:pointer;font-size:17px;font-weight:500}
.result-box{margin-top:25px;padding:20px;background:#f1f5f9;border-radius:10px;min-height:150px;line-height:1.6}
.pay-box{margin-top:25px;text-align:center;padding:25px;background:#dbeafe;border-radius:12px}
.pay-box h3{margin-bottom:12px;color:#1d4ed8;font-size:20px}
.pay-box p{margin:8px 0;color:#334155;font-size:16px}
.pay-link{display:inline-block;margin-top:15px;padding:12px 25px;background:#1d4ed8;color:white;border-radius:8px;text-decoration:none;font-weight:bold;font-size:16px}
.premium-info{color:#16a34a;font-weight:bold;margin-top:10px;font-size:14px}
</style>
</head>
<body>
<div class="tool-box">
<h2>AI Ecommerce Smart Agent</h2>
<p class="sub-title">One-click Generate Listing, Product Copy, Email & Research</p >
<p class="use-limit" id="usageInfo">Free Daily Uses: 3 Times</p >
<!-- 电商功能选择 -->
<select class="func-select" id="funcType">
<option value="listing">Shopify Product Listing</option>
<option value="copy">Product Marketing Copy</option>
<option value="email">Business Development Email</option>
<option value="research">Product Research Analysis</option>
</select>
<!-- 输入框 -->
<textarea id="userInput" placeholder="Enter your product name, keywords or requirements..."></textarea>
<button class="generate-btn" onclick="generateEcommerceContent()">Generate Content</button>
<!-- 结果展示 -->
<div class="result-box" id="resultBox"></div>
<!-- 付费弹窗 -->
<div class="pay-box" id="payBox" style="display:none;">
<h3>Daily Free Limit Reached</h3>
<p>Upgrade to Premium & Unlock All Features</p >
<p><strong>Only $19.9 / Year</strong></p >
<p>Total 18,250 Uses Per Year | No Daily Limits</p >
<p>365 Days Validity | Instant Unlock</p >
<a href="https://www.paypal.com/ncp/payment/P7YJQL34PW9BN" target="_blank" class="pay-link">Pay Now via PayPal</a >
</div>
<!-- 付费用户信息 -->
<div class="premium-info" id="premiumInfo" style="display:none;">
✅ Premium Active - Total Uses: <span id="totalUses">0</span> / 18250
</div>
</div>
<script>
// 核心配置
const FREE_DAILY_LIMIT = 3;
const PREMIUM_YEARLY_LIMIT = 18250; // 365 × 50
const DEEPSEEK_API = "https://api.deepseek.com/v1/chat/completions";
const DEEPSEEK_KEY = "Bearer sk-ab85dc5a027847b7871f7be5bfd8ba39";
// 从本地存储加载数据
let userData = JSON.parse(localStorage.getItem('ecommerceAgentData')) || {
isPremium: false,
totalUses: 0,
lastResetDate: new Date().toDateString(),
dailyUses: 0
};
// 更新UI显示
updateUI();
// 电商AI生成主函数
async function generateEcommerceContent() {
const today = new Date().toDateString();
// 检查是否需要重置每日免费次数
if (userData.lastResetDate !== today) {
userData.dailyUses = 0;
userData.lastResetDate = today;
saveUserData();
updateUI();
}
// 检查使用限制
if (userData.isPremium) {
if (userData.totalUses >= PREMIUM_YEARLY_LIMIT) {
document.getElementById("resultBox").innerText = "Yearly premium limit reached. Please renew your subscription.";
return;
}
} else {
if (userData.dailyUses >= FREE_DAILY_LIMIT) {
document.getElementById("resultBox").innerText = "Daily free limit reached. Upgrade to premium for unlimited access.";
document.getElementById("payBox").style.display = "block";
return;
}
}
let inputText = document.getElementById("userInput").value.trim();
let funcType = document.getElementById("funcType").value;
if (!inputText) {
alert("Please enter your product info or requirements first!");
return;
}
document.getElementById("resultBox").innerText = "AI is generating content, please wait...";
// 根据功能匹配AI提示词
let promptContent = "";
if (funcType === "listing") {
promptContent = `You are a professional Shopify listing writer, write a high-conversion product listing based on keywords: ${inputText}, include product title, description, features, selling points, format clearly, no redundant content.`;
} else if (funcType === "copy") {
promptContent = `Write attractive e-commerce product marketing copy for ${inputText}, highlight selling points, suitable for social media & product page, concise and persuasive.`;
} else if (funcType === "email") {
promptContent = `Write a professional cross-border e-commerce business development/cooperation email for ${inputText}, formal tone, clear purpose, suitable for foreign suppliers/buyers.`;
} else if (funcType === "research") {
promptContent = `Do a simple cross-border e-commerce product research analysis for ${inputText}, include market demand, target audience, competitive advantages, short and concise.`;
}
// 调用DeepSeek API
try {
const res = await fetch(DEEPSEEK_API, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": DEEPSEEK_KEY
},
body: JSON.stringify({
model: "deepseek-chat",
messages: [{role: "user", content: promptContent}],
temperature: 0.7
})
});
const data = await res.json();
let result = data.choices?.[0]?.message?.content || "Generation failed, please try again later.";
document.getElementById("resultBox").innerText = result;
// 更新使用次数
if (userData.isPremium) {
userData.totalUses++;
} else {
userData.dailyUses++;
}
saveUserData();
updateUI();
} catch (error) {
document.getElementById("resultBox").innerText = "Network error, please check and try again.";
}
}
// 保存用户数据到本地存储
function saveUserData() {
localStorage.setItem('ecommerceAgentData', JSON.stringify(userData));
}
// 更新UI显示信息
function updateUI() {
if (userData.isPremium) {
document.getElementById("usageInfo").style.display = "none";
document.getElementById("premiumInfo").style.display = "block";
document.getElementById("totalUses").textContent = userData.totalUses;
document.getElementById("payBox").style.display = "none";
} else {
document.getElementById("usageInfo").textContent = `Free Daily Uses: ${userData.dailyUses} / ${FREE_DAILY_LIMIT}`;
document.getElementById("premiumInfo").style.display = "none";
}
}
// 模拟付费成功(实际使用时需要配合PayPal回调)
// 这里只是示例,实际需要后端验证付款
function activatePremium() {
userData.isPremium = true;
userData.totalUses = 0;
saveUserData();
updateUI();
alert("Premium activated successfully!");
}
</script>
</body>
</html>