Initial commit: TradeMate 外贸小助手 MVP

项目结构:
- backend/     Python FastAPI 后端
- uni-app/     uni-app跨端前端
- docs/        设计文档
- docker-compose.yml  Docker编排
- nginx/scripts/systemd 运维配置

已完成功能:
- 用户认证 (JWT)
- 智能翻译 + 回复建议
- 营销素材生成
- 客户管理 + 沉默检测
- 报价单管理
- 产品库管理
- 汇率换算
- 推送通知 (uni-push)
- WhatsApp Webhook框架
- Celery定时任务
This commit is contained in:
TradeMate Dev
2026-05-08 18:17:12 +08:00
commit c6206787da
121 changed files with 11743 additions and 0 deletions
+95
View File
@@ -0,0 +1,95 @@
const { marketingApi } = require('../../utils/api');
Page({
data: {
productName: '',
description: '',
category: '',
target: 'US importers',
style: 'professional',
results: [],
keywords: [],
loading: false,
activeTab: 'generate',
},
onLoad() {},
switchTab(e) {
const tab = e.currentTarget.dataset.tab;
this.setData({ activeTab: tab });
},
onInput(e) {
const field = e.currentTarget.dataset.field;
this.setData({ [field]: e.detail.value });
},
onTargetChange(e) {
this.setData({ target: e.detail.value });
},
onStyleChange(e) {
this.setData({ style: e.detail.value });
},
async generateContent() {
const { productName, description, target, style } = this.data;
if (!productName || !description) {
wx.showToast({ title: '请填写产品信息', icon: 'none' });
return;
}
this.setData({ loading: true });
try {
const result = await marketingApi.generate(productName, description, this.data.category, target, style);
this.setData({
results: result.results.filter(r => r.content),
loading: false,
});
} catch (err) {
wx.showToast({ title: err.message || '生成失败', icon: 'none' });
this.setData({ loading: false });
}
},
async generateKeywords() {
const { productName, description } = this.data;
if (!productName || !description) {
wx.showToast({ title: '请填写产品信息', icon: 'none' });
return;
}
this.setData({ loading: true });
try {
const result = await marketingApi.getKeywords(productName, description, this.data.category);
this.setData({
keywords: result.keywords,
loading: false,
});
} catch (err) {
wx.showToast({ title: err.message || '生成失败', icon: 'none' });
this.setData({ loading: false });
}
},
copyText(e) {
const text = e.currentTarget.dataset.text;
wx.setClipboardData({
data: text,
success: () => {
wx.showToast({ title: '已复制', icon: 'success' });
},
});
},
clear() {
this.setData({
productName: '',
description: '',
category: '',
results: [],
keywords: [],
});
},
});
@@ -0,0 +1,4 @@
{
"navigationBarTitleText": "营销素材",
"usingComponents": {}
}
@@ -0,0 +1,59 @@
<view class="container">
<view class="tabs">
<view class="tab {{activeTab === 'generate' ? 'active' : ''}}" data-tab="generate" bindtap="switchTab">生成文案</view>
<view class="tab {{activeTab === 'keywords' ? 'active' : ''}}" data-tab="keywords" bindtap="switchTab">关键词</view>
</view>
<view class="form-section">
<view class="form-group">
<text class="form-label">产品名称 *</text>
<input class="form-input" placeholder="如:户外折叠椅" value="{{productName}}" data-field="productName" bindinput="onInput" />
</view>
<view class="form-group">
<text class="form-label">产品描述 *</text>
<textarea class="form-input form-textarea" placeholder="描述产品的特点、材质、优势..." value="{{description}}" data-field="description" bindinput="onInput" auto-height />
</view>
<view class="form-group">
<text class="form-label">产品类别</text>
<input class="form-input" placeholder="如:家具、户外用品" value="{{category}}" data-field="category" bindinput="onInput" />
</view>
<view class="select-row" wx:if="{{activeTab === 'generate'}}">
<view class="select-group">
<text class="form-label">目标市场</text>
<input class="form-input" placeholder="如:US importers" value="{{target}}" bindinput="onInput" data-field="target" />
</view>
<view class="select-group">
<text class="form-label">风格</text>
<input class="form-input" placeholder="如:professional" value="{{style}}" bindinput="onInput" data-field="style" />
</view>
</view>
<button class="btn-generate" bindtap="{{activeTab === 'generate' ? 'generateContent' : 'generateKeywords'}}" loading="{{loading}}">
{{activeTab === 'generate' ? '生成营销文案' : '生成关键词'}}
</button>
</view>
<view class="results" wx:if="{{activeTab === 'generate' && results.length > 0}}">
<view class="section-title">生成结果</view>
<view class="result-item" wx:for="{{results}}" wx:key="style">
<view class="result-header">
<text class="result-style">{{item.style}}</text>
<text class="result-provider">{{item.provider}}</text>
</view>
<text class="result-content">{{item.content}}</text>
<view>
<text class="copy-btn" bindtap="copyText" data-text="{{item.content}}">复制文案</text>
</view>
</view>
</view>
<view class="keywords-section" wx:if="{{activeTab === 'keywords' && keywords.length > 0}}">
<view class="section-title">关键词建议</view>
<view class="keyword-list">
<view class="keyword-tag" wx:for="{{keywords}}" wx:key="index">{{item}}</view>
</view>
</view>
</view>
+123
View File
@@ -0,0 +1,123 @@
.tabs {
display: flex;
background: #fff;
padding: 20rpx;
}
.tab {
flex: 1;
text-align: center;
padding: 20rpx;
font-size: 28rpx;
color: #666;
border-bottom: 4rpx solid transparent;
}
.tab.active {
color: #1890ff;
border-bottom-color: #1890ff;
font-weight: bold;
}
.form-section {
padding: 30rpx;
}
.form-group {
margin-bottom: 20rpx;
}
.form-label {
font-size: 26rpx;
color: #666;
margin-bottom: 10rpx;
display: block;
}
.form-input {
border: 1rpx solid #d9d9d9;
border-radius: 8rpx;
padding: 20rpx;
font-size: 28rpx;
width: 100%;
box-sizing: border-box;
}
.form-textarea {
min-height: 150rpx;
}
.select-row {
display: flex;
gap: 20rpx;
}
.select-group {
flex: 1;
}
.btn-generate {
background: #1890ff;
color: #fff;
margin: 0 30rpx 30rpx;
}
.results {
padding: 0 30rpx 30rpx;
}
.result-item {
background: #fff;
border-radius: 12rpx;
padding: 30rpx;
margin-bottom: 20rpx;
}
.result-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 15rpx;
}
.result-style {
font-size: 24rpx;
color: #1890ff;
font-weight: bold;
}
.result-provider {
font-size: 22rpx;
color: #999;
}
.result-content {
font-size: 28rpx;
line-height: 1.6;
color: #333;
white-space: pre-wrap;
}
.copy-btn {
color: #1890ff;
font-size: 24rpx;
padding: 10rpx 0;
}
.keywords-section {
padding: 30rpx;
}
.keyword-list {
display: flex;
flex-wrap: wrap;
gap: 15rpx;
}
.keyword-tag {
background: #e6f7ff;
color: #1890ff;
padding: 10rpx 20rpx;
border-radius: 20rpx;
font-size: 26rpx;
}