beta
This commit is contained in:
parent
a45ddf13d5
commit
bcd986e3f7
46 changed files with 6166 additions and 454 deletions
48
miniprogram-example/pages/login/login.js
Normal file
48
miniprogram-example/pages/login/login.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
// login.js
|
||||
import { wxLogin } from '../../services/auth';
|
||||
|
||||
Page({
|
||||
data: {
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
// 页面加载时检查是否已经登录
|
||||
const token = wx.getStorageSync('token');
|
||||
if (token) {
|
||||
this.redirectToHome();
|
||||
}
|
||||
},
|
||||
|
||||
// 处理登录按钮点击
|
||||
handleLogin() {
|
||||
if (this.data.loading) return;
|
||||
|
||||
this.setData({ loading: true });
|
||||
|
||||
wxLogin()
|
||||
.then(() => {
|
||||
wx.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
});
|
||||
this.redirectToHome();
|
||||
})
|
||||
.catch(err => {
|
||||
wx.showToast({
|
||||
title: err.message || '登录失败',
|
||||
icon: 'none'
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
this.setData({ loading: false });
|
||||
});
|
||||
},
|
||||
|
||||
// 跳转到首页
|
||||
redirectToHome() {
|
||||
wx.reLaunch({
|
||||
url: '/pages/otp-list/index'
|
||||
});
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue