chore: establish V1.1 recovery baseline
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
/**
|
||||
* 红娘工作台登录页
|
||||
*
|
||||
* 红娘工作人员使用账号密码登录,与用户端分离
|
||||
*/
|
||||
const { appStore } = require('../../stores');
|
||||
|
||||
Page({
|
||||
data: {
|
||||
username: '',
|
||||
password: '',
|
||||
loading: false,
|
||||
error: '',
|
||||
platformName: getApp().globalData.platformName,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
wx.setNavigationBarTitle({ title: '红娘工作台' });
|
||||
},
|
||||
|
||||
onUsernameInput(e) {
|
||||
this.setData({ username: e.detail.value, error: '' });
|
||||
},
|
||||
|
||||
onPasswordInput(e) {
|
||||
this.setData({ password: e.detail.value, error: '' });
|
||||
},
|
||||
|
||||
async onLogin() {
|
||||
if (!this.data.username || !this.data.password) {
|
||||
this.setData({ error: '请输入用户名和密码' });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setData({ loading: true, error: '' });
|
||||
|
||||
try {
|
||||
const res = await new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
url: 'http://localhost:8085/api/v1/operator/auth/login',
|
||||
method: 'POST',
|
||||
data: {
|
||||
username: this.data.username,
|
||||
password: this.data.password,
|
||||
},
|
||||
header: { 'Content-Type': 'application/json' },
|
||||
success: (res) => resolve(res.data),
|
||||
fail: reject,
|
||||
});
|
||||
});
|
||||
|
||||
if (res.success) {
|
||||
const { accessToken, name } = res.data;
|
||||
// 存储token
|
||||
wx.setStorageSync('operatorToken', accessToken);
|
||||
wx.setStorageSync('operatorName', name);
|
||||
|
||||
// 跳转到红娘工作台
|
||||
wx.reLaunch({ url: '/pages/matchmaker-workbench/matchmaker-workbench' });
|
||||
} else {
|
||||
this.setData({ error: res.message || '登录失败' });
|
||||
}
|
||||
} catch (err) {
|
||||
this.setData({ error: '网络连接失败,请重试' });
|
||||
} finally {
|
||||
this.setData({ loading: false });
|
||||
}
|
||||
},
|
||||
|
||||
onForgotPassword() {
|
||||
wx.showModal({
|
||||
title: '忘记密码',
|
||||
content: '请联系平台管理员重置密码',
|
||||
showCancel: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user