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