Files
WXProgram/miniprogram/pages/staff/employee-dashboard.ts

226 lines
4.8 KiB
TypeScript
Raw Normal View History

2025-10-19 23:38:54 +08:00
// 员工界面 - 全屏工作面板
import { UserInfo } from '../../types';
2025-10-21 21:51:51 +08:00
import userService from '../../services/userService';
2025-10-19 23:38:54 +08:00
Page({
data: {
userInfo: null as UserInfo | null,
// Grid布局的功能菜单
menuItems: [
{
id: 'orders',
name: '我的订单',
icon: '📦',
color: '#3498db',
description: '查看分配订单'
},
{
id: 'location',
name: '位置上报',
icon: '📍',
color: '#e74c3c',
description: '上报当前位置'
},
{
id: 'schedule',
name: '工作安排',
icon: '📅',
color: '#f39c12',
description: '查看工作计划'
},
{
id: 'profile',
name: '个人信息',
icon: '👤',
color: '#9b59b6',
description: '个人资料管理'
},
{
id: 'messages',
name: '消息通知',
icon: '📨',
color: '#34495e',
description: '查看系统消息'
},
{
id: 'help',
name: '帮助中心',
icon: '❓',
color: '#27ae60',
description: '使用帮助文档'
}
],
// 工作统计
workStats: {
todayOrders: 0,
completedOrders: 0,
pendingOrders: 0
}
},
onLoad() {
this.getUserInfo();
this.loadWorkStats();
},
onShow() {
this.loadWorkStats();
},
/**
*
*/
getUserInfo() {
const app = getApp<any>();
if (app.globalData.userInfo) {
const userInfo = app.globalData.userInfo;
this.setData({ userInfo });
}
},
/**
*
*/
loadWorkStats() {
// 模拟加载工作统计数据
this.setData({
workStats: {
todayOrders: 8,
completedOrders: 5,
pendingOrders: 3
}
});
},
/**
*
*/
onMenuItemTap(e: any) {
const itemId = e.currentTarget.dataset.id;
switch (itemId) {
case 'orders':
wx.navigateTo({
url: '/pages/staff/my-orders'
});
break;
case 'location':
wx.navigateTo({
url: '/pages/staff/location-report'
});
break;
case 'schedule':
wx.navigateTo({
url: '/pages/staff/work-schedule'
});
break;
case 'profile':
wx.navigateTo({
url: '/pages/staff/profile'
});
break;
case 'messages':
wx.navigateTo({
url: '/pages/staff/messages'
});
break;
case 'help':
wx.navigateTo({
url: '/pages/staff/help'
});
break;
}
},
/**
*
*/
goBack() {
wx.navigateBack();
},
/**
*
*/
onRefresh() {
this.loadWorkStats();
wx.showToast({
title: '数据已刷新',
icon: 'success'
});
},
/**
*
*/
onEmergencyContact() {
wx.makePhoneCall({
phoneNumber: '400-123-4567'
});
2025-10-21 21:51:51 +08:00
},
/**
*
*/
async onUnbindWechat() {
try {
// 确认对话框
wx.showModal({
title: '确认解绑',
content: '解绑微信后,您将需要重新登录并绑定账号。确定要继续吗?',
confirmText: '确定解绑',
confirmColor: '#e74c3c',
cancelText: '取消',
success: async (res) => {
if (res.confirm) {
// 显示加载中
wx.showLoading({
title: '解绑中...',
mask: true
});
try {
// 调用解绑服务
const result = await userService.unbindWechat();
wx.hideLoading();
if (result.success) {
wx.showToast({
title: '解绑成功',
icon: 'success',
duration: 2000
});
// 延迟跳转到登录页面
setTimeout(() => {
wx.reLaunch({
url: '/pages/login/login'
});
}, 2000);
} else {
wx.showToast({
title: result.message || '解绑失败',
icon: 'none'
});
}
} catch (error) {
wx.hideLoading();
wx.showToast({
title: '解绑失败,请重试',
icon: 'none'
});
console.error('解绑微信错误:', error);
}
}
}
});
} catch (error) {
console.error('解绑微信处理错误:', error);
wx.showToast({
title: '操作失败,请重试',
icon: 'none'
});
}
2025-10-19 23:38:54 +08:00
}
});