chore: remove native miniprogram (use uni-app instead)
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
App({
|
||||
globalData: {
|
||||
userInfo: null,
|
||||
token: null,
|
||||
baseUrl: 'http://localhost:8000/api/v1',
|
||||
},
|
||||
|
||||
onLaunch() {
|
||||
const token = wx.getStorageSync('token');
|
||||
if (token) {
|
||||
this.globalData.token = token;
|
||||
}
|
||||
},
|
||||
|
||||
setToken(token) {
|
||||
this.globalData.token = token;
|
||||
wx.setStorageSync('token', token);
|
||||
},
|
||||
|
||||
clearToken() {
|
||||
this.globalData.token = null;
|
||||
wx.removeStorageSync('token');
|
||||
},
|
||||
|
||||
getAuthHeader() {
|
||||
const token = this.globalData.token;
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
},
|
||||
});
|
||||
@@ -1,55 +0,0 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/login/login",
|
||||
"pages/index/index",
|
||||
"pages/translate/translate",
|
||||
"pages/customers/customers",
|
||||
"pages/marketing/marketing",
|
||||
"pages/quotation/quotation"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "light",
|
||||
"navigationBarBackgroundColor": "#1890ff",
|
||||
"navigationBarTitleText": "外贸小助手",
|
||||
"navigationBarTextStyle": "white"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#666666",
|
||||
"selectedColor": "#1890ff",
|
||||
"backgroundColor": "#ffffff",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"text": "首页",
|
||||
"iconPath": "assets/home.png",
|
||||
"selectedIconPath": "assets/home-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/translate/translate",
|
||||
"text": "翻译",
|
||||
"iconPath": "assets/translate.png",
|
||||
"selectedIconPath": "assets/translate-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/customers/customers",
|
||||
"text": "客户",
|
||||
"iconPath": "assets/customers.png",
|
||||
"selectedIconPath": "assets/customers-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/marketing/marketing",
|
||||
"text": "营销",
|
||||
"iconPath": "assets/marketing.png",
|
||||
"selectedIconPath": "assets/marketing-active.png"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/quotation/quotation",
|
||||
"text": "报价",
|
||||
"iconPath": "assets/quotation.png",
|
||||
"selectedIconPath": "assets/quotation-active.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"sitemapLocation": "sitemap.json"
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
page {
|
||||
background-color: #f5f5f5;
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.container {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #1890ff;
|
||||
color: #fff;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 40rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn-primary:active {
|
||||
background-color: #40a9ff;
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
background-color: #fff;
|
||||
color: #1890ff;
|
||||
border: 1rpx solid #1890ff;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx 40rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.card {
|
||||
background-color: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
|
||||
}
|
||||
|
||||
.input-field {
|
||||
border: 1rpx solid #d9d9d9;
|
||||
border-radius: 8rpx;
|
||||
padding: 20rpx;
|
||||
font-size: 28rpx;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.input-field:focus {
|
||||
border-color: #40a9ff;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.text-gray {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.text-primary {
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.text-success {
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.text-warning {
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.text-danger {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-center {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.flex-between {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.mt-10 { margin-top: 10rpx; }
|
||||
.mt-20 { margin-top: 20rpx; }
|
||||
.mt-30 { margin-top: 30rpx; }
|
||||
.mb-10 { margin-bottom: 10rpx; }
|
||||
.mb-20 { margin-bottom: 20rpx; }
|
||||
.mb-30 { margin-bottom: 30rpx; }
|
||||
.p-20 { padding: 20rpx; }
|
||||
@@ -1,121 +0,0 @@
|
||||
const { customerApi } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
customers: [],
|
||||
page: 1,
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
showAddModal: false,
|
||||
newCustomer: {
|
||||
name: '',
|
||||
company: '',
|
||||
country: '',
|
||||
phone: '',
|
||||
whatsapp_id: '',
|
||||
email: '',
|
||||
},
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadCustomers();
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.data.hasMore && !this.data.loading) {
|
||||
this.setData({ page: this.data.page + 1 });
|
||||
this.loadCustomers(true);
|
||||
}
|
||||
},
|
||||
|
||||
async loadCustomers(isAppend = false) {
|
||||
if (this.data.loading) return;
|
||||
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const result = await customerApi.list(this.data.page);
|
||||
this.setData({
|
||||
customers: isAppend ? [...this.data.customers, ...result.items] : result.items,
|
||||
hasMore: result.items.length >= result.size,
|
||||
loading: false,
|
||||
});
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '加载失败', icon: 'none' });
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
showAdd() {
|
||||
this.setData({ showAddModal: true });
|
||||
},
|
||||
|
||||
hideAdd() {
|
||||
this.setData({ showAddModal: false });
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
this.setData({
|
||||
[`newCustomer.${field}`]: value,
|
||||
});
|
||||
},
|
||||
|
||||
async addCustomer() {
|
||||
const { newCustomer } = this.data;
|
||||
if (!newCustomer.name) {
|
||||
wx.showToast({ title: '请输入客户名称', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await customerApi.create(newCustomer);
|
||||
wx.showToast({ title: '添加成功', icon: 'success' });
|
||||
this.hideAdd();
|
||||
this.setData({ page: 1, customers: [] });
|
||||
this.loadCustomers();
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '添加失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
|
||||
async deleteCustomer(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.showModal({
|
||||
title: '确认删除',
|
||||
content: '确定要删除该客户吗?',
|
||||
success: async (res) => {
|
||||
if (res.confirm) {
|
||||
try {
|
||||
await customerApi.delete(id);
|
||||
wx.showToast({ title: '已删除', icon: 'success' });
|
||||
this.setData({ page: 1, customers: [] });
|
||||
this.loadCustomers();
|
||||
} catch (err) {
|
||||
wx.showToast({ title: '删除失败', icon: 'none' });
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
viewDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({ url: `/pages/customers/detail?id=${id}` });
|
||||
},
|
||||
|
||||
getStatusClass(status) {
|
||||
const map = {
|
||||
lead: 'text-primary',
|
||||
negotiating: 'text-warning',
|
||||
closed: 'text-success',
|
||||
};
|
||||
return map[status] || '';
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.setData({ page: 1, customers: [] });
|
||||
this.loadCustomers();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "客户管理",
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<text class="section-title">客户列表</text>
|
||||
<button class="add-btn" bindtap="showAdd">+ 添加客户</button>
|
||||
</view>
|
||||
|
||||
<view class="customer-list">
|
||||
<view class="customer-item" wx:for="{{customers}}" wx:key="id" bindtap="viewDetail" data-id="{{item.id}}">
|
||||
<view class="customer-info">
|
||||
<view class="customer-name">{{item.name}}</view>
|
||||
<view class="customer-meta">
|
||||
{{item.company}} {{item.country ? '· ' + item.country : ''}}
|
||||
</view>
|
||||
<view class="customer-meta" wx:if="{{item.last_contact_at}}">
|
||||
最后联系: {{item.last_contact_at}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="customer-status status-{{item.status}}">
|
||||
{{item.status === 'lead' ? '潜在' : item.status === 'negotiating' ? '谈判中' : '已成交'}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty" wx:if="{{customers.length === 0 && !loading}}">
|
||||
<text>暂无客户,点击上方添加</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="modal" wx:if="{{showAddModal}}" bindtap="hideAdd">
|
||||
<view class="modal-content" catchtap>
|
||||
<view class="modal-title">添加客户</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">姓名 *</text>
|
||||
<input class="form-input" placeholder="客户姓名" data-field="name" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">公司</text>
|
||||
<input class="form-input" placeholder="公司名称" data-field="company" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">国家</text>
|
||||
<input class="form-input" placeholder="如:美国、德国" data-field="country" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">电话</text>
|
||||
<input class="form-input" placeholder="手机号" data-field="phone" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">WhatsApp</text>
|
||||
<input class="form-input" placeholder="WhatsApp ID" data-field="whatsapp_id" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">邮箱</text>
|
||||
<input class="form-input" placeholder="邮箱地址" data-field="email" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="modal-btns">
|
||||
<view class="modal-btn btn-cancel" bindtap="hideAdd">取消</view>
|
||||
<view class="modal-btn btn-confirm" bindtap="addCustomer">确定</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,160 +0,0 @@
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 15rpx 30rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.customer-list {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.customer-item {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.customer-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.customer-meta {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.customer-status {
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.status-lead {
|
||||
background: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.status-negotiating {
|
||||
background: #fffbe6;
|
||||
color: #faad14;
|
||||
}
|
||||
|
||||
.status-closed {
|
||||
background: #f6ffed;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.customer-actions {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
}
|
||||
|
||||
.action-btn {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.delete-btn {
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
padding: 100rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 40rpx;
|
||||
width: 80%;
|
||||
max-height: 80vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.modal-btns {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.modal-btn {
|
||||
flex: 1;
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
const app = getApp();
|
||||
const { authApi, customerApi, translateApi } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
userInfo: null,
|
||||
stats: {
|
||||
customers: 0,
|
||||
silentCustomers: 0,
|
||||
todayTranslations: 0,
|
||||
quotations: 0,
|
||||
},
|
||||
silentCustomers: [],
|
||||
loading: true,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadData();
|
||||
},
|
||||
|
||||
onShow() {
|
||||
const token = app.globalData.token;
|
||||
if (!token) {
|
||||
wx.redirectTo({ url: '/pages/login/login' });
|
||||
} else {
|
||||
this.loadData();
|
||||
}
|
||||
},
|
||||
|
||||
async loadData() {
|
||||
try {
|
||||
const userInfo = await authApi.getUserInfo();
|
||||
const silentData = await customerApi.getSilent(3);
|
||||
|
||||
this.setData({
|
||||
userInfo,
|
||||
stats: {
|
||||
customers: silentData.count + Math.floor(Math.random() * 10),
|
||||
silentCustomers: silentData.count,
|
||||
todayTranslations: Math.floor(Math.random() * 20),
|
||||
quotations: Math.floor(Math.random() * 5),
|
||||
},
|
||||
silentCustomers: silentData.customers.slice(0, 5),
|
||||
loading: false,
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('Failed to load data:', err);
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
goToTranslate() {
|
||||
wx.switchTab({ url: '/pages/translate/translate' });
|
||||
},
|
||||
|
||||
goToCustomers() {
|
||||
wx.switchTab({ url: '/pages/customers/customers' });
|
||||
},
|
||||
|
||||
goToMarketing() {
|
||||
wx.switchTab({ url: '/pages/marketing/marketing' });
|
||||
},
|
||||
|
||||
goToQuotation() {
|
||||
wx.switchTab({ url: '/pages/quotation/quotation' });
|
||||
},
|
||||
|
||||
onLogout() {
|
||||
wx.showModal({
|
||||
title: '确认退出',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
app.clearToken();
|
||||
wx.redirectTo({ url: '/pages/login/login' });
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "外贸小助手",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<view class="user-info">
|
||||
<view class="avatar">👤</view>
|
||||
<view class="user-detail">
|
||||
<view class="username">{{userInfo.username || '用户'}}</view>
|
||||
<text class="tier-badge">{{userInfo.tier === 'pro' ? 'Pro' : userInfo.tier === 'enterprise' ? '企业版' : '免费版'}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats-grid">
|
||||
<view class="stat-item" bindtap="goToCustomers">
|
||||
<text class="stat-value">{{stats.customers}}</text>
|
||||
<text class="stat-label">客户数</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-value text-danger">{{stats.silentCustomers}}</text>
|
||||
<text class="stat-label">待跟进</text>
|
||||
</view>
|
||||
<view class="stat-item" bindtap="goToTranslate">
|
||||
<text class="stat-value">{{stats.todayTranslations}}</text>
|
||||
<text class="stat-label">今日翻译</text>
|
||||
</view>
|
||||
<view class="stat-item" bindtap="goToQuotation">
|
||||
<text class="stat-value">{{stats.quotations}}</text>
|
||||
<text class="stat-label">报价单</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="menu-grid">
|
||||
<view class="menu-item" bindtap="goToTranslate">
|
||||
<view class="menu-icon">📝</view>
|
||||
<text class="menu-text">翻译</text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="goToCustomers">
|
||||
<view class="menu-icon">👥</view>
|
||||
<text class="menu-text">客户</text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="goToMarketing">
|
||||
<view class="menu-icon">📢</view>
|
||||
<text class="menu-text">营销</text>
|
||||
</view>
|
||||
<view class="menu-item" bindtap="goToQuotation">
|
||||
<view class="menu-icon">📄</view>
|
||||
<text class="menu-text">报价</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section" wx:if="{{silentCustomers.length > 0}}">
|
||||
<view class="section-title">待跟进客户</view>
|
||||
<view class="silent-list">
|
||||
<view class="silent-item" wx:for="{{silentCustomers}}" wx:key="id">
|
||||
<text class="customer-name">{{item.name}}</text>
|
||||
<text class="silence-days">沉默 {{item.silence_days}} 天</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<button class="logout-btn" bindtap="onLogout">退出登录</button>
|
||||
</view>
|
||||
@@ -1,142 +0,0 @@
|
||||
.header {
|
||||
background: linear-gradient(135deg, #1890ff, #40a9ff);
|
||||
padding: 40rpx 30rpx;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 50%;
|
||||
background-color: rgba(255, 255, 255, 0.3);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 48rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.user-detail {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 8rpx;
|
||||
}
|
||||
|
||||
.tier-badge {
|
||||
font-size: 24rpx;
|
||||
background: rgba(255, 255, 255, 0.2);
|
||||
padding: 4rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
}
|
||||
|
||||
.stats-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 30rpx;
|
||||
background: #fff;
|
||||
margin: -30rpx 30rpx 30rpx;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
width: 25%;
|
||||
text-align: center;
|
||||
padding: 20rpx 0;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #1890ff;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-top: 8rpx;
|
||||
}
|
||||
|
||||
.menu-grid {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.menu-item {
|
||||
width: 25%;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.menu-icon {
|
||||
width: 80rpx;
|
||||
height: 80rpx;
|
||||
background: #e6f7ff;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin: 0 auto 10rpx;
|
||||
font-size: 40rpx;
|
||||
}
|
||||
|
||||
.menu-text {
|
||||
font-size: 24rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.section {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.section-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.silent-list {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.silent-item {
|
||||
padding: 30rpx;
|
||||
border-bottom: 1rpx solid #f0f0f0;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.silent-item:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.customer-name {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.silence-days {
|
||||
font-size: 24rpx;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
margin: 40rpx 30rpx;
|
||||
background: #fff;
|
||||
color: #ff4d4f;
|
||||
border: 1rpx solid #ff4d4f;
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
const app = getApp();
|
||||
const { authApi } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
phone: '',
|
||||
password: '',
|
||||
username: '',
|
||||
isRegister: false,
|
||||
loading: false,
|
||||
error: '',
|
||||
},
|
||||
|
||||
onPhoneInput(e) {
|
||||
this.setData({ phone: e.detail.value });
|
||||
},
|
||||
|
||||
onPasswordInput(e) {
|
||||
this.setData({ password: e.detail.value });
|
||||
},
|
||||
|
||||
onUsernameInput(e) {
|
||||
this.setData({ username: e.detail.value });
|
||||
},
|
||||
|
||||
toggleMode() {
|
||||
this.setData({
|
||||
isRegister: !this.data.isRegister,
|
||||
error: '',
|
||||
});
|
||||
},
|
||||
|
||||
async handleSubmit() {
|
||||
const { phone, password, username, isRegister } = this.data;
|
||||
|
||||
if (!phone || !password) {
|
||||
this.setData({ error: '请输入手机号和密码' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (isRegister && !username) {
|
||||
this.setData({ error: '请输入用户名' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true, error: '' });
|
||||
|
||||
try {
|
||||
if (isRegister) {
|
||||
await authApi.register(phone, password, username);
|
||||
wx.showToast({ title: '注册成功,请登录', icon: 'success' });
|
||||
this.setData({ isRegister: false });
|
||||
} else {
|
||||
const res = await authApi.login(phone, password);
|
||||
app.setToken(res.access_token);
|
||||
app.globalData.userInfo = res.user;
|
||||
wx.showToast({ title: '登录成功', icon: 'success' });
|
||||
setTimeout(() => {
|
||||
wx.switchTab({ url: '/pages/index/index' });
|
||||
}, 1000);
|
||||
}
|
||||
} catch (err) {
|
||||
this.setData({ error: err.message || '操作失败,请重试' });
|
||||
} finally {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
handleWechatLogin() {
|
||||
wx.getUserProfile({
|
||||
desc: '用于完善用户资料',
|
||||
success: (res) => {
|
||||
console.log('微信登录', res.userInfo);
|
||||
wx.showToast({ title: '微信登录开发中', icon: 'none' });
|
||||
},
|
||||
fail: (err) => {
|
||||
console.log('微信登录失败', err);
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
<view class="container">
|
||||
<view class="logo-section">
|
||||
<view class="logo">TradeMate</view>
|
||||
<view class="subtitle">外贸小助手</view>
|
||||
</view>
|
||||
|
||||
<view class="form-section">
|
||||
<view class="form-title">{{isRegister ? '注册' : '登录'}}</view>
|
||||
|
||||
<view class="input-group">
|
||||
<input class="input" type="number" placeholder="手机号" bindinput="onPhoneInput" value="{{phone}}" />
|
||||
</view>
|
||||
|
||||
<view class="input-group" wx:if="{{isRegister}}">
|
||||
<input class="input" type="text" placeholder="用户名" bindinput="onUsernameInput" value="{{username}}" />
|
||||
</view>
|
||||
|
||||
<view class="input-group">
|
||||
<input class="input" type="password" placeholder="密码" bindinput="onPasswordInput" value="{{password}}" />
|
||||
</view>
|
||||
|
||||
<view class="error" wx:if="{{error}}">{{error}}</view>
|
||||
|
||||
<button class="submit-btn" bindtap="handleSubmit" disabled="{{loading}}">
|
||||
{{loading ? '处理中...' : (isRegister ? '注册' : '登录')}}
|
||||
</button>
|
||||
|
||||
<view class="toggle-mode" bindtap="toggleMode">
|
||||
{{isRegister ? '已有账号?立即登录' : '没有账号?立即注册'}}
|
||||
</view>
|
||||
|
||||
<view class="divider">
|
||||
<view class="line"></view>
|
||||
<text class="text">或</text>
|
||||
<view class="line"></view>
|
||||
</view>
|
||||
|
||||
<button class="wechat-btn" bindtap="handleWechatLogin">
|
||||
<text class="wechat-icon">W</text>
|
||||
微信一键登录
|
||||
</button>
|
||||
</view>
|
||||
|
||||
<view class="footer">
|
||||
<text class="agreement">登录即表示同意</text>
|
||||
<text class="link">《用户协议》</text>
|
||||
<text class="agreement">和</text>
|
||||
<text class="link">《隐私政策》</text>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,142 +0,0 @@
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(180deg, #1890ff 0%, #e6f7ff 100%);
|
||||
padding: 120rpx 60rpx 60rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.logo-section {
|
||||
text-align: center;
|
||||
margin-bottom: 80rpx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
font-size: 60rpx;
|
||||
font-weight: bold;
|
||||
color: #fff;
|
||||
letter-spacing: 4rpx;
|
||||
}
|
||||
|
||||
.subtitle {
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
margin-top: 16rpx;
|
||||
}
|
||||
|
||||
.form-section {
|
||||
background: #fff;
|
||||
border-radius: 24rpx;
|
||||
padding: 48rpx 40rpx;
|
||||
box-shadow: 0 8rpx 32rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.form-title {
|
||||
font-size: 40rpx;
|
||||
font-weight: 600;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 48rpx;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
margin-bottom: 32rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 16rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 28rpx;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
background: #e6f7ff;
|
||||
border: 2rpx solid #1890ff;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #ff4d4f;
|
||||
font-size: 24rpx;
|
||||
margin-bottom: 24rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
border-radius: 16rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.submit-btn[disabled] {
|
||||
background: #a0cfff;
|
||||
}
|
||||
|
||||
.toggle-mode {
|
||||
text-align: center;
|
||||
margin-top: 32rpx;
|
||||
color: #666;
|
||||
font-size: 26rpx;
|
||||
}
|
||||
|
||||
.divider {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin: 48rpx 0;
|
||||
}
|
||||
|
||||
.divider .line {
|
||||
flex: 1;
|
||||
height: 1rpx;
|
||||
background: #e8e8e8;
|
||||
}
|
||||
|
||||
.divider .text {
|
||||
padding: 0 24rpx;
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.wechat-btn {
|
||||
width: 100%;
|
||||
height: 96rpx;
|
||||
background: #07c160;
|
||||
color: #fff;
|
||||
border-radius: 16rpx;
|
||||
font-size: 32rpx;
|
||||
font-weight: 500;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.wechat-icon {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin-right: 16rpx;
|
||||
}
|
||||
|
||||
.footer {
|
||||
text-align: center;
|
||||
margin-top: 60rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.agreement {
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.link {
|
||||
color: #1890ff;
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
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: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "营销素材",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
<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>
|
||||
@@ -1,123 +0,0 @@
|
||||
.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;
|
||||
}
|
||||
@@ -1,155 +0,0 @@
|
||||
const { quotationApi, customerApi } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
quotations: [],
|
||||
page: 1,
|
||||
hasMore: true,
|
||||
loading: false,
|
||||
showCreateModal: false,
|
||||
customers: [],
|
||||
newQuotation: {
|
||||
customer_id: '',
|
||||
title: '',
|
||||
items: [],
|
||||
currency: 'USD',
|
||||
payment_terms: 'T/T 30% deposit',
|
||||
delivery_terms: 'FOB',
|
||||
lead_time: '',
|
||||
notes: '',
|
||||
},
|
||||
tempItem: {
|
||||
product_name: '',
|
||||
quantity: 1,
|
||||
unit_price: 0,
|
||||
},
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadQuotations();
|
||||
},
|
||||
|
||||
onReachBottom() {
|
||||
if (this.data.hasMore && !this.data.loading) {
|
||||
this.setData({ page: this.data.page + 1 });
|
||||
this.loadQuotations(true);
|
||||
}
|
||||
},
|
||||
|
||||
async loadQuotations(isAppend = false) {
|
||||
if (this.data.loading) return;
|
||||
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const result = await quotationApi.list(this.data.page);
|
||||
this.setData({
|
||||
quotations: isAppend ? [...this.data.quotations, ...result.items] : result.items,
|
||||
hasMore: result.items.length >= result.size,
|
||||
loading: false,
|
||||
});
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '加载失败', icon: 'none' });
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
async showCreate() {
|
||||
try {
|
||||
const customers = await customerApi.list(1, 100);
|
||||
this.setData({
|
||||
showCreateModal: true,
|
||||
customers: customers.items,
|
||||
});
|
||||
} catch (err) {
|
||||
wx.showToast({ title: '加载客户失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
|
||||
hideCreate() {
|
||||
this.setData({
|
||||
showCreateModal: false,
|
||||
newQuotation: {
|
||||
customer_id: '',
|
||||
title: '',
|
||||
items: [],
|
||||
currency: 'USD',
|
||||
payment_terms: 'T/T 30% deposit',
|
||||
delivery_terms: 'FOB',
|
||||
lead_time: '',
|
||||
notes: '',
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
onInput(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
this.setData({ [`newQuotation.${field}`]: value });
|
||||
},
|
||||
|
||||
onItemInput(e) {
|
||||
const field = e.currentTarget.dataset.field;
|
||||
const value = e.detail.value;
|
||||
this.setData({ [`tempItem.${field}`]: value });
|
||||
},
|
||||
|
||||
addItem() {
|
||||
const { tempItem, newQuotation } = this.data;
|
||||
if (!tempItem.product_name) {
|
||||
wx.showToast({ title: '请输入产品名称', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({
|
||||
newQuotation: {
|
||||
...newQuotation,
|
||||
items: [...newQuotation.items, { ...tempItem }],
|
||||
},
|
||||
tempItem: {
|
||||
product_name: '',
|
||||
quantity: 1,
|
||||
unit_price: 0,
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
removeItem(e) {
|
||||
const index = e.currentTarget.dataset.index;
|
||||
const { newQuotation } = this.data;
|
||||
newQuotation.items.splice(index, 1);
|
||||
this.setData({ newQuotation });
|
||||
},
|
||||
|
||||
async createQuotation() {
|
||||
const { newQuotation } = this.data;
|
||||
if (!newQuotation.customer_id) {
|
||||
wx.showToast({ title: '请选择客户', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (newQuotation.items.length === 0) {
|
||||
wx.showToast({ title: '请添加产品', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await quotationApi.create(newQuotation);
|
||||
wx.showToast({ title: '创建成功', icon: 'success' });
|
||||
this.hideCreate();
|
||||
this.setData({ page: 1, quotations: [] });
|
||||
this.loadQuotations();
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '创建失败', icon: 'none' });
|
||||
}
|
||||
},
|
||||
|
||||
viewDetail(e) {
|
||||
const id = e.currentTarget.dataset.id;
|
||||
wx.navigateTo({ url: `/pages/quotation/detail?id=${id}` });
|
||||
},
|
||||
|
||||
onPullDownRefresh() {
|
||||
this.setData({ page: 1, quotations: [] });
|
||||
this.loadQuotations();
|
||||
wx.stopPullDownRefresh();
|
||||
},
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "报价单",
|
||||
"enablePullDownRefresh": true,
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<text class="section-title">报价单</text>
|
||||
<button class="add-btn" bindtap="showCreate">+ 新建报价</button>
|
||||
</view>
|
||||
|
||||
<view class="quotation-list">
|
||||
<view class="quotation-item" wx:for="{{quotations}}" wx:key="id" bindtap="viewDetail" data-id="{{item.id}}">
|
||||
<view class="quotation-header">
|
||||
<text class="quotation-title">{{item.title || '报价单'}}</text>
|
||||
<view class="quotation-status status-{{item.status}}">
|
||||
{{item.status === 'draft' ? '草稿' : item.status === 'sent' ? '已发送' : '已接受'}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="quotation-info">
|
||||
货币: {{item.currency}} ·条款: {{item.delivery_terms}}
|
||||
</view>
|
||||
<view class="quotation-total">
|
||||
合计: ${{item.total || 0}}
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="empty" wx:if="{{quotations.length === 0 && !loading}}">
|
||||
<text>暂无报价单,点击上方创建</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="modal" wx:if="{{showCreateModal}}" bindtap="hideCreate">
|
||||
<view class="modal-content" catchtap>
|
||||
<view class="modal-title">新建报价单</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">客户 *</text>
|
||||
<picker bindchange="onCustomerChange" value="{{customerIndex}}" range="{{customers}}" range-key="name">
|
||||
<view class="form-input">
|
||||
{{customers[customerIndex] ? customers[customerIndex].name : '请选择客户'}}
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">标题</text>
|
||||
<input class="form-input" placeholder="报价单标题" value="{{newQuotation.title}}" data-field="title" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="items-section">
|
||||
<text class="form-label">产品明细</text>
|
||||
<view class="item-row" wx:for="{{newQuotation.items}}" wx:key="index">
|
||||
<text>{{item.product_name}}</text>
|
||||
<text>x{{item.quantity}}</text>
|
||||
<text>${{item.unit_price}}</text>
|
||||
<text class="remove-item" data-index="{{index}}" bindtap="removeItem">×</text>
|
||||
</view>
|
||||
|
||||
<view class="item-row">
|
||||
<input class="form-input item-input" placeholder="产品名称" value="{{tempItem.product_name}}" data-field="product_name" bindinput="onItemInput" />
|
||||
<input class="form-input qty-input" type="number" placeholder="数量" value="{{tempItem.quantity}}" data-field="quantity" bindinput="onItemInput" />
|
||||
<input class="form-input price-input" type="digit" placeholder="单价" value="{{tempItem.unit_price}}" data-field="unit_price" bindinput="onItemInput" />
|
||||
</view>
|
||||
<view class="add-item-btn" bindtap="addItem">+ 添加产品</view>
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">货币</text>
|
||||
<input class="form-input" placeholder="USD" value="{{newQuotation.currency}}" data-field="currency" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">付款条款</text>
|
||||
<input class="form-input" placeholder="T/T 30% deposit" value="{{newQuotation.payment_terms}}" data-field="payment_terms" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">交货条款</text>
|
||||
<input class="form-input" placeholder="FOB" value="{{newQuotation.delivery_terms}}" data-field="delivery_terms" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="form-group">
|
||||
<text class="form-label">交货周期</text>
|
||||
<input class="form-input" placeholder="如:25 days" value="{{newQuotation.lead_time}}" data-field="lead_time" bindinput="onInput" />
|
||||
</view>
|
||||
|
||||
<view class="modal-btns">
|
||||
<view class="modal-btn btn-cancel" bindtap="hideCreate">取消</view>
|
||||
<view class="modal-btn btn-confirm" bindtap="createQuotation">创建</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,195 +0,0 @@
|
||||
.header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 30rpx;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
font-size: 28rpx;
|
||||
padding: 15rpx 30rpx;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.quotation-list {
|
||||
padding: 0 30rpx;
|
||||
}
|
||||
|
||||
.quotation-item {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.quotation-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.quotation-title {
|
||||
font-size: 30rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.quotation-status {
|
||||
padding: 6rpx 16rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 22rpx;
|
||||
}
|
||||
|
||||
.status-draft {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.status-sent {
|
||||
background: #e6f7ff;
|
||||
color: #1890ff;
|
||||
}
|
||||
|
||||
.status-accepted {
|
||||
background: #f6ffed;
|
||||
color: #52c41a;
|
||||
}
|
||||
|
||||
.quotation-info {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.quotation-total {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #ff4d4f;
|
||||
}
|
||||
|
||||
.empty {
|
||||
text-align: center;
|
||||
padding: 100rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: center;
|
||||
z-index: 100;
|
||||
overflow-y: auto;
|
||||
padding-top: 50rpx;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 40rpx;
|
||||
width: 85%;
|
||||
max-height: 90vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 30rpx;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.items-section {
|
||||
background: #f9f9f9;
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.item-row {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
align-items: center;
|
||||
margin-bottom: 15rpx;
|
||||
}
|
||||
|
||||
.item-input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.qty-input {
|
||||
width: 100rpx;
|
||||
}
|
||||
|
||||
.price-input {
|
||||
width: 150rpx;
|
||||
}
|
||||
|
||||
.remove-item {
|
||||
color: #ff4d4f;
|
||||
font-size: 32rpx;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
.add-item-btn {
|
||||
background: #fff;
|
||||
border: 1rpx dashed #1890ff;
|
||||
color: #1890ff;
|
||||
font-size: 26rpx;
|
||||
padding: 15rpx;
|
||||
text-align: center;
|
||||
border-radius: 8rpx;
|
||||
}
|
||||
|
||||
.modal-btns {
|
||||
display: flex;
|
||||
gap: 20rpx;
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.modal-btn {
|
||||
flex: 1;
|
||||
padding: 20rpx;
|
||||
border-radius: 8rpx;
|
||||
text-align: center;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.btn-cancel {
|
||||
background: #f5f5f5;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.btn-confirm {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
const { translateApi } = require('../../utils/api');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
tab: 'translate',
|
||||
sourceText: '',
|
||||
translatedText: '',
|
||||
targetLang: 'en',
|
||||
langOptions: [
|
||||
{ value: 'en', label: 'English' },
|
||||
{ value: 'zh', label: '中文' },
|
||||
{ value: 'es', label: 'Español' },
|
||||
{ value: 'fr', label: 'Français' },
|
||||
{ value: 'de', label: 'Deutsch' },
|
||||
{ value: 'ja', label: '日本語' },
|
||||
{ value: 'pt', label: 'Português' },
|
||||
],
|
||||
replyInquiry: '',
|
||||
replySuggestions: [],
|
||||
loading: false,
|
||||
},
|
||||
|
||||
onLoad() {},
|
||||
|
||||
switchTab(e) {
|
||||
const tab = e.currentTarget.dataset.tab;
|
||||
this.setData({ tab });
|
||||
},
|
||||
|
||||
onSourceInput(e) {
|
||||
this.setData({ sourceText: e.detail.value });
|
||||
},
|
||||
|
||||
onReplyInput(e) {
|
||||
this.setData({ replyInquiry: e.detail.value });
|
||||
},
|
||||
|
||||
onLangChange(e) {
|
||||
this.setData({ targetLang: e.detail.value });
|
||||
},
|
||||
|
||||
async doTranslate() {
|
||||
if (!this.data.sourceText.trim()) {
|
||||
wx.showToast({ title: '请输入要翻译的内容', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const result = await translateApi.translate(
|
||||
this.data.sourceText,
|
||||
this.data.targetLang
|
||||
);
|
||||
this.setData({
|
||||
translatedText: result.translated_text,
|
||||
loading: false,
|
||||
});
|
||||
} catch (err) {
|
||||
wx.showToast({ title: err.message || '翻译失败', icon: 'none' });
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
async doGetReply() {
|
||||
if (!this.data.replyInquiry.trim()) {
|
||||
wx.showToast({ title: '请输入客户询盘内容', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true });
|
||||
try {
|
||||
const result = await translateApi.getReply(this.data.replyInquiry);
|
||||
this.setData({
|
||||
replySuggestions: result.suggestions,
|
||||
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' });
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
clearInput() {
|
||||
this.setData({
|
||||
sourceText: '',
|
||||
translatedText: '',
|
||||
replyInquiry: '',
|
||||
replySuggestions: [],
|
||||
});
|
||||
},
|
||||
});
|
||||
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"navigationBarTitleText": "智能翻译",
|
||||
"usingComponents": {}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
<view class="container">
|
||||
<view class="tabs">
|
||||
<view class="tab {{tab === 'translate' ? 'active' : ''}}" data-tab="translate" bindtap="switchTab">翻译</view>
|
||||
<view class="tab {{tab === 'reply' ? 'active' : ''}}" data-tab="reply" bindtap="switchTab">回复建议</view>
|
||||
</view>
|
||||
|
||||
<view class="content">
|
||||
<view wx:if="{{tab === 'translate'}}">
|
||||
<view class="input-area">
|
||||
<text class="input-label">输入要翻译的内容</text>
|
||||
<textarea class="textarea" placeholder="请输入中文或英文..." value="{{sourceText}}" bindinput="onSourceInput" auto-height />
|
||||
</view>
|
||||
|
||||
<view class="lang-select">
|
||||
<text>目标语言</text>
|
||||
<picker value="{{targetLang}}" range="{{langOptions}}" range-key="label" bindchange="onLangChange">
|
||||
<text class="picker">{{langOptions[langOptions.findIndex(function(item) { return item.value === targetLang })].label}}</text>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<button class="btn-primary btn-translate" bindtap="doTranslate" loading="{{loading}}">翻译</button>
|
||||
|
||||
<view class="result-area" wx:if="{{translatedText}}">
|
||||
<view class="result-header">
|
||||
<text class="input-label">翻译结果</text>
|
||||
<text class="copy-btn" bindtap="copyText" data-text="{{translatedText}}">复制</text>
|
||||
</view>
|
||||
<text class="result-text">{{translatedText}}</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{tab === 'reply'}}">
|
||||
<view class="input-area">
|
||||
<text class="input-label">输入客户询盘内容</text>
|
||||
<textarea class="textarea" placeholder="粘贴客户的英文询盘..." value="{{replyInquiry}}" bindinput="onReplyInput" auto-height />
|
||||
</view>
|
||||
|
||||
<button class="btn-primary btn-translate" bindtap="doGetReply" loading="{{loading}}">生成回复建议</button>
|
||||
|
||||
<view class="suggestions" wx:if="{{replySuggestions.length > 0}}">
|
||||
<view class="section-title">回复建议</view>
|
||||
<view class="suggestion-item" wx:for="{{replySuggestions}}" wx:key="tone">
|
||||
<text class="suggestion-tone">{{item.tone}}</text>
|
||||
<text class="suggestion-content">{{item.reply}}</text>
|
||||
<view style="margin-top: 10rpx;">
|
||||
<text class="copy-btn" bindtap="copyText" data-text="{{item.reply}}">复制</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
@@ -1,114 +0,0 @@
|
||||
.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;
|
||||
}
|
||||
|
||||
.content {
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.input-area {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.input-label {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
margin-bottom: 10rpx;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
width: 100%;
|
||||
min-height: 200rpx;
|
||||
font-size: 28rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.lang-select {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
background: #fff;
|
||||
padding: 20rpx;
|
||||
border-radius: 12rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.picker {
|
||||
color: #1890ff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.btn-translate {
|
||||
background: #1890ff;
|
||||
color: #fff;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.result-area {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.result-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.copy-btn {
|
||||
color: #1890ff;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.result-text {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.6;
|
||||
color: #333;
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.suggestions {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.suggestion-item {
|
||||
background: #fff;
|
||||
border-radius: 12rpx;
|
||||
padding: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.suggestion-tone {
|
||||
font-size: 24rpx;
|
||||
color: #1890ff;
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.suggestion-content {
|
||||
font-size: 28rpx;
|
||||
line-height: 1.5;
|
||||
color: #333;
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"description": "外贸小助手 - 微信小程序",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
},
|
||||
"setting": {
|
||||
"bundle": false,
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"urlCheck": true,
|
||||
"scopeDataCheck": false,
|
||||
"coverView": true,
|
||||
"es6": true,
|
||||
"postcss": true,
|
||||
"compileHotReLoad": false,
|
||||
"lazyloadPlaceholderEnable": false,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
"autoAudits": false,
|
||||
"newFeature": false,
|
||||
"uglifyFileName": false,
|
||||
"uploadWithSourceMap": true,
|
||||
"useIsolateContext": true,
|
||||
"nodeModules": false,
|
||||
"enhance": true,
|
||||
"useMultiFrameRuntime": true,
|
||||
"useApiHook": true,
|
||||
"useApiHostProcess": true,
|
||||
"showShadowRootInWxmlPanel": true,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true,
|
||||
"disableUseStrict": false,
|
||||
"minifyWXML": true,
|
||||
"showES6CompileOption": false,
|
||||
"useCompilerPlugins": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "3.3.4",
|
||||
"appid": "wxxxxxxxxxxx",
|
||||
"projectname": "trade-assistant",
|
||||
"condition": {},
|
||||
"editorSetting": {
|
||||
"tabIndent": "insertTwoSpaces",
|
||||
"tabSize": 2
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
|
||||
"rules": [
|
||||
{
|
||||
"action": "allow",
|
||||
"page": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
const app = getApp();
|
||||
|
||||
const request = (url, method = 'GET', data = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const header = {
|
||||
'Content-Type': 'application/json',
|
||||
...app.getAuthHeader(),
|
||||
};
|
||||
|
||||
wx.request({
|
||||
url: `${app.globalData.baseUrl}${url}`,
|
||||
method,
|
||||
data,
|
||||
header,
|
||||
success: (res) => {
|
||||
if (res.statusCode === 200) {
|
||||
resolve(res.data);
|
||||
} else if (res.statusCode === 401) {
|
||||
app.clearToken();
|
||||
wx.redirectTo({ url: '/pages/login/login' });
|
||||
reject(new Error('Unauthorized'));
|
||||
} else {
|
||||
reject(new Error(res.data?.detail || 'Request failed'));
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(err);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const authApi = {
|
||||
login: (phone, password) => request('/auth/login', 'POST', { username: phone, password }),
|
||||
register: (phone, password, username) => request('/auth/register', 'POST', { phone, password, username }),
|
||||
getUserInfo: () => request('/auth/me'),
|
||||
};
|
||||
|
||||
export const translateApi = {
|
||||
translate: (text, targetLang, sourceLang = 'auto') =>
|
||||
request('/translate', 'POST', { text, target_lang: targetLang, source_lang: sourceLang }),
|
||||
getReply: (inquiry, tone = 'professional', count = 3) =>
|
||||
request('/translate/reply', 'POST', { inquiry, tone, count }),
|
||||
extract: (text, type = 'auto') =>
|
||||
request('/translate/extract', 'POST', { text, extract_type: type }),
|
||||
};
|
||||
|
||||
export const customerApi = {
|
||||
list: (page = 1, size = 20, status) => {
|
||||
const params = new URLSearchParams({ page, size });
|
||||
if (status) params.append('status', status);
|
||||
return request(`/customers?${params.toString()}`);
|
||||
},
|
||||
get: (id) => request(`/customers/${id}`),
|
||||
create: (data) => request('/customers', 'POST', data),
|
||||
update: (id, data) => request(`/customers/${id}`, 'PATCH', data),
|
||||
delete: (id) => request(`/customers/${id}`, 'DELETE'),
|
||||
getSilent: (days = 3) => request(`/customers/silent?days=${days}`),
|
||||
getConversation: (id, page = 1, size = 50) =>
|
||||
request(`/customers/${id}/conversation?page=${page}&size=${size}`),
|
||||
};
|
||||
|
||||
export const marketingApi = {
|
||||
generate: (productName, description, category, target = 'US importers', style = 'professional') =>
|
||||
request('/marketing/generate', 'POST', {
|
||||
product_name: productName,
|
||||
description,
|
||||
category,
|
||||
target,
|
||||
style,
|
||||
}),
|
||||
getKeywords: (productName, description, category) =>
|
||||
request('/marketing/keywords', 'POST', {
|
||||
product_name: productName,
|
||||
description,
|
||||
category,
|
||||
}),
|
||||
analyzeCompetitors: (productName, description, category, market = 'US') =>
|
||||
request('/marketing/competitor-analysis', 'POST', {
|
||||
product_name: productName,
|
||||
description,
|
||||
category,
|
||||
market,
|
||||
}),
|
||||
};
|
||||
|
||||
export const quotationApi = {
|
||||
list: (page = 1, size = 20) => request(`/quotations?page=${page}&size=${size}`),
|
||||
get: (id) => request(`/quotations/${id}`),
|
||||
create: (data) => request('/quotations', 'POST', data),
|
||||
updateStatus: (id, status) => request(`/quotations/${id}/status`, 'PATCH', { status }),
|
||||
};
|
||||
|
||||
export const whatsappApi = {
|
||||
send: (to, text) => request('/whatsapp/send', 'POST', { to, text }),
|
||||
};
|
||||
Reference in New Issue
Block a user