2025-06-19 17:33:18 +08:00

80 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// pages/index/index.ts
Page({
/**
* 页面的初始数据
*/
data: {},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
// 判断是否登录
const token = wx.getStorageSync('token');
if (!token) {
wx.reLaunch({
url: '/pages/login/login'
});
} else {
// 获取token用户信息 判断账号角色然后跳转到对应的首页
let userInfo = wx.getStorageSync('userInfo');
if (userInfo.type == '1') {
wx.reLaunch({
url: '/pages/driverIndex/index'
});
} else if (userInfo.type == '2') {
wx.reLaunch({
url: '/pages/manufacturerIndex/manufacturerIndex'
});
} else if (userInfo.type == '3') {
wx.reLaunch({
url: '/pages/projectIndex/projectIndex'
});
} else if (userInfo.type == '4') {
wx.reLaunch({
url: '/pages/maintenanceIndex/maintenanceIndex'
});
} else {
wx.reLaunch({
url: '/pages/login/login'
});
}
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {}
});