beefast-mini-deliveryman/pages/login/index.js
2025-02-18 18:26:07 +08:00

93 lines
1.4 KiB
JavaScript

import userApi from '../../api/user';
const app = getApp();
Page({
/**
* 页面的初始数据
*/
data: {
phone:'13438370499',
password:'6x9vw9s2',
isAgree:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
login(){
if(this.data.isAgree){
userApi.login(this.data.phone,this.data.password).then((data)=>{
app.globalData.userInfo = data.user;
app.globalData.accessToken = data.access_token;
wx.setStorage({
key:'accessToken',
data:data.access_token,
success:()=>{
wx.reLaunch({
url: '/pages/index/index',
})
}
})
})
}else{
}
},
handleAgreeChange(event){
this.setData({
isAgree:!!event.detail
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})