2025-11-07 14:54:09 +08:00
|
|
|
|
// pages/profile/index/index.js
|
2025-11-10 13:32:14 +08:00
|
|
|
|
const app = getApp();
|
|
|
|
|
|
|
2025-11-07 14:54:09 +08:00
|
|
|
|
Page({
|
2025-11-10 13:32:14 +08:00
|
|
|
|
data: {
|
|
|
|
|
|
isLoggedIn: false,
|
|
|
|
|
|
userInfo: null,
|
|
|
|
|
|
isSubscribed: false
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
|
|
this.loadUserInfo();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onShow() {
|
|
|
|
|
|
this.loadUserInfo();
|
|
|
|
|
|
this.checkSubscriptionStatus();
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 加载用户信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
loadUserInfo() {
|
|
|
|
|
|
const isLoggedIn = app.isLoggedIn();
|
|
|
|
|
|
const userInfo = app.getUserInfo();
|
|
|
|
|
|
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
isLoggedIn,
|
|
|
|
|
|
userInfo: userInfo || {
|
|
|
|
|
|
nickName: '未登录',
|
|
|
|
|
|
avatarUrl: ''
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 检查订阅状态
|
|
|
|
|
|
*/
|
|
|
|
|
|
checkSubscriptionStatus() {
|
|
|
|
|
|
const isSubscribed = app.isSubscribed();
|
|
|
|
|
|
this.setData({
|
|
|
|
|
|
isSubscribed
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 点击头部区域
|
|
|
|
|
|
*/
|
|
|
|
|
|
handleHeaderTap() {
|
|
|
|
|
|
if (!this.data.isLoggedIn) {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/login/login'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 消息通知设置
|
|
|
|
|
|
*/
|
|
|
|
|
|
goToNotificationSettings() {
|
|
|
|
|
|
if (!this.data.isLoggedIn) {
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '提示',
|
|
|
|
|
|
content: '请先登录',
|
|
|
|
|
|
confirmText: '去登录',
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/login/login'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '消息通知',
|
|
|
|
|
|
content: '是否开启消息推送通知?开启后可以及时接收设备检验预警提醒',
|
|
|
|
|
|
confirmText: '开启',
|
|
|
|
|
|
cancelText: '取消',
|
|
|
|
|
|
success: async res => {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await app.subscribeAllMessages();
|
|
|
|
|
|
this.setData({ isSubscribed: true });
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
title: '订阅成功',
|
|
|
|
|
|
icon: 'success'
|
|
|
|
|
|
});
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('订阅失败', error);
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
title: '订阅失败',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-11-07 14:54:09 +08:00
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-10 13:32:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 预警设置
|
|
|
|
|
|
*/
|
2025-11-07 14:54:09 +08:00
|
|
|
|
goToWarningSettings() {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/warning/settings/settings'
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-10 13:32:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 单位管理
|
|
|
|
|
|
*/
|
|
|
|
|
|
goToUnitManage() {
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
title: '功能开发中',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 数据导出
|
|
|
|
|
|
*/
|
2025-11-07 14:54:09 +08:00
|
|
|
|
exportData() {
|
2025-11-10 13:32:14 +08:00
|
|
|
|
if (!this.data.isLoggedIn) {
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '提示',
|
|
|
|
|
|
content: '请先登录',
|
|
|
|
|
|
confirmText: '去登录',
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
|
url: '/pages/login/login'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-07 14:54:09 +08:00
|
|
|
|
wx.showToast({
|
|
|
|
|
|
title: '功能开发中',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-10 13:32:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 关于我们
|
|
|
|
|
|
*/
|
2025-11-07 14:54:09 +08:00
|
|
|
|
goToAbout() {
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '关于我们',
|
|
|
|
|
|
content: '安全工器具预警小程序\n版本:v1.0.0\n\n专注于施工安全工器具的管理、维保和预警',
|
|
|
|
|
|
showCancel: false
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2025-11-10 13:32:14 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 帮助中心
|
|
|
|
|
|
*/
|
2025-11-07 14:54:09 +08:00
|
|
|
|
goToHelp() {
|
|
|
|
|
|
wx.showToast({
|
|
|
|
|
|
title: '功能开发中',
|
|
|
|
|
|
icon: 'none'
|
|
|
|
|
|
});
|
2025-11-10 13:32:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 退出登录
|
|
|
|
|
|
*/
|
|
|
|
|
|
handleLogout() {
|
|
|
|
|
|
wx.showModal({
|
|
|
|
|
|
title: '确认退出',
|
|
|
|
|
|
content: '确定要退出登录吗?',
|
|
|
|
|
|
success: res => {
|
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
|
app.logout();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-11-07 14:54:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|