[AI Generated]: feat(Comp): 重写用户同步逻辑支持主子用户、移除callWithTimeout、新增用户上限10人及主用户删除保护
This commit is contained in:
@@ -8,6 +8,8 @@ Component({
|
||||
data: {
|
||||
animationData: null,
|
||||
modalStatus: false,
|
||||
// 是否是第一个用户(主用户),true 时只能选员工
|
||||
isFirstUser: false,
|
||||
// 用户类型:employee=员工,family=家庭用户
|
||||
userType: 'employee',
|
||||
// 员工模式
|
||||
@@ -38,7 +40,8 @@ Component({
|
||||
},
|
||||
methods: {
|
||||
// 显示对话框
|
||||
showModal() {
|
||||
showModal(isFirstUser = false) {
|
||||
this.setData({ isFirstUser: !!isFirstUser });
|
||||
// 先瞬间将弹窗移到屏幕下方(duration:0,不产生过渡)
|
||||
let initAnim = wx.createAnimation({ duration: 0 });
|
||||
initAnim.translateY(1200).step();
|
||||
@@ -66,6 +69,7 @@ Component({
|
||||
// 关闭弹窗并重置所有数据
|
||||
closeModal() {
|
||||
this.setData({
|
||||
isFirstUser: false,
|
||||
userType: 'employee',
|
||||
workNo: "",
|
||||
userInfo: null,
|
||||
@@ -83,6 +87,8 @@ Component({
|
||||
|
||||
// 切换用户类型,同时清空所有已填数据
|
||||
switchUserType(e) {
|
||||
// 主用户模式下禁止切换
|
||||
if (this.data.isFirstUser) return;
|
||||
const type = e.currentTarget.dataset.type;
|
||||
if (type === this.data.userType) return;
|
||||
this.setData({
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<view>添加用户</view>
|
||||
</view>
|
||||
<view class="seaction">
|
||||
<!-- 用户类型切换 -->
|
||||
<view class="select">
|
||||
<!-- 用户类型切换(主用户模式下隐藏) -->
|
||||
<view class="select" wx:if="{{!isFirstUser}}">
|
||||
<view
|
||||
class="{{userType === 'employee' ? 'selectActive' : ''}}"
|
||||
bindtap="switchUserType"
|
||||
|
||||
Reference in New Issue
Block a user