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:
@@ -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: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user