注册修改为绑定

This commit is contained in:
2025-10-21 21:51:51 +08:00
parent 5ee4e077fb
commit be2323074b
28 changed files with 729 additions and 211 deletions

View File

@@ -1,5 +1,6 @@
// 管理员界面 - 全屏管理面板
import { UserInfo } from '../../types';
import userService from '../../services/userService';
Page({
data: {
@@ -183,5 +184,70 @@ Page({
this.setData({
currentTime: timeString
});
},
/**
* 解绑微信处理
*/
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'
});
}
}
});

View File

@@ -62,5 +62,6 @@
<view class="admin-footer">
<text class="footer-text">管理员系统 v1.0</text>
<text class="footer-time">{{currentTime}}</text>
<button class="unbind-btn" bindtap="onUnbindWechat">解绑微信</button>
</view>
</view>

View File

@@ -5,16 +5,21 @@
display: flex;
flex-direction: column;
padding: 0;
/* 安全区域适配 - 为整个容器添加顶部安全区域 */
padding-top: env(safe-area-inset-top);
box-sizing: border-box;
}
/* 顶部导航栏样式 */
.admin-header {
background: rgba(255, 255, 255, 0.95);
padding: 30rpx 40rpx;
padding: 40rpx 40rpx 30rpx 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
/* 移除margin-top使用容器的padding-top来处理安全区域 */
min-height: 140rpx;
}
.header-left {
@@ -259,4 +264,21 @@
.footer-time {
font-size: 22rpx;
color: #999;
}
/* 解绑微信按钮样式 */
.unbind-btn {
background: #e74c3c;
color: white;
border: none;
border-radius: 8rpx;
padding: 12rpx 20rpx;
font-size: 24rpx;
cursor: pointer;
transition: all 0.3s ease;
}
.unbind-btn:active {
background: #c0392b;
transform: translateY(1rpx);
}

View File

@@ -1,5 +1,6 @@
// 员工界面 - 全屏工作面板
import { UserInfo } from '../../types';
import userService from '../../services/userService';
Page({
data: {
@@ -156,5 +157,70 @@ Page({
wx.makePhoneCall({
phoneNumber: '400-123-4567'
});
},
/**
* 解绑微信处理
*/
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'
});
}
}
});

View File

@@ -81,5 +81,6 @@
<view class="employee-footer">
<text class="footer-text">员工工作系统 v1.0</text>
<text class="footer-time">{{currentTime}}</text>
<button class="unbind-btn" bindtap="onUnbindWechat">解绑微信</button>
</view>
</view>

View File

@@ -5,16 +5,21 @@
display: flex;
flex-direction: column;
padding: 0;
/* 安全区域适配 - 为整个容器添加顶部安全区域 */
padding-top: env(safe-area-inset-top);
box-sizing: border-box;
}
/* 顶部导航栏样式 */
.employee-header {
background: rgba(255, 255, 255, 0.95);
padding: 30rpx 40rpx;
padding: 40rpx 40rpx 30rpx 40rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1);
/* 移除margin-top使用容器的padding-top来处理安全区域 */
min-height: 140rpx;
}
.header-left {
@@ -320,4 +325,21 @@
.footer-time {
font-size: 22rpx;
color: #999;
}
/* 解绑微信按钮样式 */
.unbind-btn {
background: #e74c3c;
color: white;
border: none;
border-radius: 8rpx;
padding: 12rpx 20rpx;
font-size: 24rpx;
cursor: pointer;
transition: all 0.3s ease;
}
.unbind-btn:active {
background: #c0392b;
transform: translateY(1rpx);
}

View File

@@ -148,16 +148,16 @@ Page({
if (!phone.trim()) {
this.setData({
errorMessage: '请输入手机号'
errorMessage: '请输入员工工号'
});
return false;
}
// 简单的手机号格式验证
const phoneRegex = /^1[3-9]\d{9}$/;
// 简单的号格式验证
const phoneRegex = /^\d+$/;
if (!phoneRegex.test(phone)) {
this.setData({
errorMessage: '请输入正确的手机号格式'
errorMessage: '工号只能包含数字'
});
return false;
}

View File

@@ -57,7 +57,7 @@
<view class="search-input-wrapper">
<input
class="search-input"
placeholder="搜索员工姓名、手机号或角色"
placeholder="搜索员工姓名、号或角色"
bindinput="onSearchInput"
value="{{searchKeyword}}"
/>
@@ -80,7 +80,7 @@
{{getRoleText(item.role)}}
</text>
</view>
<text class="employee-phone">{{item.phone}}</text>
<text class="employee-phone">工号: {{item.phone}}</text>
<text class="employee-id">ID: {{item.id}}</text>
</view>
</view>
@@ -122,10 +122,10 @@
</view>
<view class="form-item">
<text class="form-label">手机号码</text>
<text class="form-label">员工工号</text>
<input
class="form-input"
placeholder="请输入手机号码"
placeholder="请输入员工工号"
type="number"
value="{{addForm.phone}}"
bindinput="onFormInput"
@@ -152,7 +152,7 @@
<view class="form-hint">
<text class="hint-text">
提示:添加员工后,用户可以使用该员工的姓名和手机号进行注册
提示:添加员工后,用户可以使用该员工的姓名和号进行绑定
</text>
</view>