重设计Salon登录注册工作台流程
This commit is contained in:
@@ -2,10 +2,12 @@
|
||||
<view class="brand">
|
||||
<image class="logo" src="/assets/images/app-icon.png" mode="aspectFill"></image>
|
||||
<text class="brand-name">{{appName}}</text>
|
||||
<text class="brand-sub">美甲店预约排班管理</text>
|
||||
<text class="brand-sub">门店工作台 · 让每一次服务都有清晰安排</text>
|
||||
</view>
|
||||
|
||||
<view class="card auth-card">
|
||||
<view class="welcome-copy">欢迎回来</view>
|
||||
<view class="welcome-hint">登录后继续管理门店与今日排班</view>
|
||||
<view class="mode-tabs">
|
||||
<view class="mode-tab {{loginMode === 'password' ? 'active' : ''}}" data-mode="password" bindtap="switchLoginMode">密码登录</view>
|
||||
<view class="mode-tab {{loginMode === 'phone' ? 'active' : ''}}" data-mode="phone" bindtap="switchLoginMode">验证码登录</view>
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
padding-top: 12rpx;
|
||||
padding: 34rpx 28rpx 48rpx;
|
||||
background: #f4f8f5;
|
||||
}
|
||||
|
||||
.brand {
|
||||
@@ -22,21 +23,28 @@
|
||||
|
||||
.brand-name {
|
||||
margin-top: 24rpx;
|
||||
color: #24211d;
|
||||
color: #2e4a3d;
|
||||
font-size: 42rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.brand-sub {
|
||||
margin-top: 8rpx;
|
||||
color: #938c83;
|
||||
font-size: 24rpx;
|
||||
color: #7b8f82;
|
||||
font-size: 23rpx;
|
||||
}
|
||||
|
||||
.auth-card {
|
||||
padding: 12rpx 24rpx 26rpx;
|
||||
padding: 30rpx 24rpx 26rpx;
|
||||
border: 1rpx solid #e1ebe3;
|
||||
border-radius: 24rpx;
|
||||
background: #fbfdfb;
|
||||
box-shadow: 0 18rpx 46rpx rgba(55, 94, 72, .08);
|
||||
}
|
||||
|
||||
.welcome-copy { color: #2e4a3d; font-size: 34rpx; font-weight: 800; }
|
||||
.welcome-hint { margin-top: 8rpx; color: #87978c; font-size: 23rpx; }
|
||||
|
||||
.mode-tabs {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
@@ -44,7 +52,7 @@
|
||||
margin: 12rpx 0 10rpx;
|
||||
padding: 8rpx;
|
||||
border-radius: 12px;
|
||||
background: #f3eee7;
|
||||
background: #edf5ef;
|
||||
}
|
||||
|
||||
.mode-tab {
|
||||
@@ -59,8 +67,8 @@
|
||||
}
|
||||
|
||||
.mode-tab.active {
|
||||
background: #fffdf8;
|
||||
color: #55786d;
|
||||
background: #ffffff;
|
||||
color: #3d6652;
|
||||
box-shadow: 0 8rpx 18rpx rgba(58, 48, 34, 0.08);
|
||||
}
|
||||
|
||||
@@ -159,6 +167,9 @@
|
||||
|
||||
.wechat-btn {
|
||||
margin-top: 34rpx;
|
||||
border: 1rpx solid #c9dbce;
|
||||
background: #edf5ef;
|
||||
color: #3d6652;
|
||||
}
|
||||
|
||||
.shop-select-mask {
|
||||
|
||||
@@ -1,95 +1,74 @@
|
||||
const authApi = require('../../api/auth')
|
||||
const { BRAND_CONFIG } = require('../../utils/config')
|
||||
|
||||
const PHONE_REGEX = /^1[3-9]\d{9}$/
|
||||
|
||||
Page({
|
||||
data: {
|
||||
form: {
|
||||
phone: '',
|
||||
code: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
shopName: ''
|
||||
},
|
||||
registerShopPlaceholder: BRAND_CONFIG.registerShopPlaceholder,
|
||||
step: 1,
|
||||
role: 'manager',
|
||||
passwordMode: false,
|
||||
form: { phone: '', code: '', password: '', confirmPassword: '', shopName: '', shopAddress: '', shopId: '' },
|
||||
shopOptions: [],
|
||||
shopIndex: 0,
|
||||
selectedShopName: '',
|
||||
loading: false,
|
||||
codeLoading: false,
|
||||
countdown: 0,
|
||||
countdownTimer: null
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
this.setData({
|
||||
[`form.${event.currentTarget.dataset.field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
onInput(event) { this.setData({ [`form.${event.currentTarget.dataset.field}`]: event.detail.value }) },
|
||||
|
||||
back() {
|
||||
wx.navigateBack()
|
||||
},
|
||||
togglePasswordMode() { this.setData({ passwordMode: !this.data.passwordMode }) },
|
||||
|
||||
async sendCode() {
|
||||
const phone = this.data.form.phone
|
||||
if (!phone) {
|
||||
wx.showToast({ title: '请输入手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.codeLoading || this.data.countdown > 0) {
|
||||
return
|
||||
}
|
||||
const phone = String(this.data.form.phone || '').trim()
|
||||
if (!PHONE_REGEX.test(phone)) { wx.showToast({ title: '请输入正确手机号', icon: 'none' }); return }
|
||||
if (this.data.codeLoading || this.data.countdown > 0) return
|
||||
this.setData({ codeLoading: true })
|
||||
try {
|
||||
await authApi.sendCode(phone)
|
||||
wx.showToast({ title: '验证码已发送' })
|
||||
this.startCountdown()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '发送失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ codeLoading: false })
|
||||
}
|
||||
try { await authApi.sendCode(phone); wx.showToast({ title: '验证码已发送' }); this.startCountdown() } catch (error) { wx.showToast({ title: error.message || '发送失败', icon: 'none' }) } finally { this.setData({ codeLoading: false }) }
|
||||
},
|
||||
|
||||
startCountdown() {
|
||||
if (this.data.countdownTimer) {
|
||||
clearInterval(this.data.countdownTimer)
|
||||
}
|
||||
this.setData({ countdown: 60 })
|
||||
const timer = setInterval(() => {
|
||||
const next = this.data.countdown - 1
|
||||
if (next <= 0) {
|
||||
clearInterval(timer)
|
||||
this.setData({ countdown: 0, countdownTimer: null })
|
||||
return
|
||||
}
|
||||
this.setData({ countdown: next })
|
||||
}, 1000)
|
||||
this.setData({ countdownTimer: timer })
|
||||
continueFromPhone() {
|
||||
const form = this.data.form
|
||||
if (!PHONE_REGEX.test(String(form.phone || '').trim()) || !/^\d{6}$/.test(String(form.code || '').trim())) { wx.showToast({ title: '请输入正确手机号和6位验证码', icon: 'none' }); return }
|
||||
if (this.data.passwordMode && (!form.password || form.password !== form.confirmPassword)) { wx.showToast({ title: '请确认两次密码一致', icon: 'none' }); return }
|
||||
this.setData({ step: 2 })
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
if (this.data.countdownTimer) {
|
||||
clearInterval(this.data.countdownTimer)
|
||||
}
|
||||
selectRole(event) { this.setData({ role: event.currentTarget.dataset.role }) },
|
||||
|
||||
continueFromRole() { this.setData({ step: 3 }) },
|
||||
|
||||
selectShop(event) {
|
||||
const index = Number(event.detail.value)
|
||||
const shop = this.data.shopOptions[index]
|
||||
if (!shop) return
|
||||
this.setData({ shopIndex: index, selectedShopName: shop.name, 'form.shopId': shop.id })
|
||||
},
|
||||
|
||||
goBackStep() { this.setData({ step: Math.max(1, this.data.step - 1) }) },
|
||||
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
if (!form.phone || !form.code || !form.password || !form.shopName) {
|
||||
wx.showToast({ title: '请补全注册信息', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (form.password !== form.confirmPassword) {
|
||||
wx.showToast({ title: '两次密码不一致', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.role === 'manager' && !String(form.shopName || '').trim()) { wx.showToast({ title: '请输入店铺名称', icon: 'none' }); return }
|
||||
if (this.data.role === 'staff' && !form.shopId) { wx.showToast({ title: '请选择要加入的店铺', icon: 'none' }); return }
|
||||
if (this.data.role === 'staff') { wx.showToast({ title: '店员申请功能即将开放', icon: 'none' }); return }
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
await authApi.register(form)
|
||||
wx.showToast({ title: '注册成功' })
|
||||
setTimeout(() => wx.navigateBack(), 500)
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '注册失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ loading: false })
|
||||
}
|
||||
}
|
||||
await authApi.register({ phone: form.phone, code: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, role: this.data.role })
|
||||
this.setData({ step: 4 })
|
||||
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
|
||||
},
|
||||
|
||||
startCountdown() {
|
||||
if (this.data.countdownTimer) clearInterval(this.data.countdownTimer)
|
||||
this.setData({ countdown: 60 })
|
||||
const timer = setInterval(() => { const next = this.data.countdown - 1; if (next <= 0) { clearInterval(timer); this.setData({ countdown: 0, countdownTimer: null }); return } this.setData({ countdown: next }) }, 1000)
|
||||
this.setData({ countdownTimer: timer })
|
||||
},
|
||||
|
||||
onUnload() { if (this.data.countdownTimer) clearInterval(this.data.countdownTimer) },
|
||||
|
||||
back() { wx.navigateBack() }
|
||||
})
|
||||
|
||||
@@ -1,32 +1,16 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="field">
|
||||
<text class="field-label">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">验证码</text>
|
||||
<input value="{{form.code}}" data-field="code" bindinput="onInput" placeholder="请输入验证码" />
|
||||
<button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendCode">
|
||||
<text wx:if="{{countdown > 0}}">重新获取 {{countdown}}s</text>
|
||||
<text wx:else>获取验证码</text>
|
||||
</button>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">密码</text>
|
||||
<input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="设置登录密码" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">确认密码</text>
|
||||
<input value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" password placeholder="再次输入密码" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">店铺名称</text>
|
||||
<input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="{{registerShopPlaceholder}}" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">注册</button>
|
||||
<view class="page no-tab auth-page">
|
||||
<view class="auth-header"><image class="logo" src="/assets/images/app-icon.png" mode="aspectFill"></image><view class="header-copy"><text class="brand-name">Salon</text><text class="brand-sub">门店工作台 · 创建你的工作身份</text></view></view>
|
||||
<view class="progress-row"><view class="progress-step {{step >= 1 ? 'active' : ''}}"><text>1</text><label>验证手机</label></view><view class="progress-line {{step >= 2 ? 'active' : ''}}"></view><view class="progress-step {{step >= 2 ? 'active' : ''}}"><text>2</text><label>选择身份</label></view><view class="progress-line {{step >= 3 ? 'active' : ''}}"></view><view class="progress-step {{step >= 3 ? 'active' : ''}}"><text>3</text><label>提交审核</label></view></view>
|
||||
<view wx:if="{{step === 1}}" class="card form-card">
|
||||
<view class="section-title">先验证手机号</view><view class="section-desc">手机号将作为你的工作台登录账号</view>
|
||||
<view class="field"><text class="field-label">手机号</text><input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" placeholder="请输入手机号" /></view>
|
||||
<view class="field"><text class="field-label">验证码</text><view class="code-row"><input class="code-input" value="{{form.code}}" data-field="code" bindinput="onInput" type="number" placeholder="请输入6位验证码" /><button class="code-btn {{countdown > 0 ? 'counting' : ''}}" loading="{{codeLoading}}" disabled="{{codeLoading || countdown > 0}}" bindtap="sendCode"><text wx:if="{{countdown > 0}}">{{countdown}}s 后重发</text><text wx:else>获取验证码</text></button></view></view>
|
||||
<view class="secondary-entry" bindtap="togglePasswordMode">使用密码注册 <text>›</text></view>
|
||||
<view wx:if="{{passwordMode}}" class="password-panel"><view class="field"><text class="field-label">设置密码</text><input value="{{form.password}}" data-field="password" bindinput="onInput" password placeholder="至少8位密码" /></view><view class="field"><text class="field-label">确认密码</text><input value="{{form.confirmPassword}}" data-field="confirmPassword" bindinput="onInput" password placeholder="再次输入密码" /></view></view>
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="continueFromPhone">继续</button>
|
||||
</view>
|
||||
<view wx:if="{{step === 2}}" class="card form-card"><view class="section-title">你要加入哪种工作身份?</view><view class="section-desc">不同身份需要由不同的负责人审核</view><view class="role-list"><view class="role-option {{role === 'manager' ? 'selected' : ''}}" data-role="manager" bindtap="selectRole"><view class="role-icon">店</view><view class="role-copy"><text class="role-title">店长</text><text class="role-desc">创建并负责一家 Salon 门店</text></view><text class="role-mark">{{role === 'manager' ? '✓' : '○'}}</text></view><view class="role-option {{role === 'staff' ? 'selected' : ''}}" data-role="staff" bindtap="selectRole"><view class="role-icon">员</view><view class="role-copy"><text class="role-title">店员</text><text class="role-desc">加入已有门店协同工作</text></view><text class="role-mark">{{role === 'staff' ? '✓' : '○'}}</text></view></view><button class="primary-btn" bindtap="continueFromRole">继续</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
|
||||
<view wx:if="{{step === 3}}" class="card form-card"><view class="section-title">{{role === 'manager' ? '完善店铺资料' : '选择要加入的店铺'}}</view><view class="section-desc">{{role === 'manager' ? '提交后由管理员审核,审核通过后即可登录' : '提交后由对应店长审核,审核通过后即可登录'}}</view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺名称</text><input value="{{form.shopName}}" data-field="shopName" bindinput="onInput" placeholder="请输入店铺名称" /></view><view wx:if="{{role === 'manager'}}" class="field"><text class="field-label">店铺地址</text><input value="{{form.shopAddress}}" data-field="shopAddress" bindinput="onInput" placeholder="请输入门店所在地址" /></view><view wx:if="{{role === 'staff'}}" class="field"><text class="field-label">选择店铺</text><picker range="{{shopOptions}}" range-key="name" value="{{shopIndex}}" bindchange="selectShop"><view class="picker-value {{selectedShopName ? 'filled' : ''}}">{{selectedShopName || '请选择要加入的店铺'}}</view></picker></view><view wx:if="{{role === 'staff'}}" class="notice">店员申请会发送给所选店铺的店长审核</view><button class="primary-btn" loading="{{loading}}" bindtap="submit">提交审核</button><view class="back-entry" bindtap="goBackStep">返回上一步</view></view>
|
||||
<view wx:if="{{step === 4}}" class="card result-card"><view class="result-icon">✓</view><view class="section-title">申请已提交</view><view class="section-desc">{{role === 'manager' ? '管理员审核通过后,你就可以登录 Salon 工作台。' : '店长审核通过后,你就可以登录 Salon 工作台。'}}</view><view class="result-status">当前状态:<text>等待审核</text></view><button class="primary-btn" bindtap="back">返回登录</button></view>
|
||||
<view class="safe-note">注册并不代表立即获得工作台权限,审核通过后才可登录。</view>
|
||||
</view>
|
||||
|
||||
@@ -1,17 +1 @@
|
||||
.code-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
height: 56rpx;
|
||||
padding: 0;
|
||||
color: #6f8f83;
|
||||
font-size: 24rpx;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.code-btn.counting {
|
||||
color: #aaa39a;
|
||||
font-weight: 500;
|
||||
}
|
||||
.auth-page{padding:36rpx 28rpx 48rpx;background:#f4f8f5}.auth-header{display:flex;align-items:center;margin-bottom:34rpx}.logo{width:88rpx;height:88rpx;border-radius:26rpx;background:#dce9df;box-shadow:0 12rpx 28rpx rgba(55,94,72,.14)}.header-copy{display:flex;flex-direction:column;margin-left:20rpx}.brand-name{color:#2e4a3d;font-size:42rpx;font-weight:800}.brand-sub{margin-top:8rpx;color:#7b8f82;font-size:23rpx}.progress-row{display:flex;align-items:center;margin-bottom:26rpx}.progress-step{display:flex;flex-direction:column;align-items:center;color:#a3b0a7;font-size:20rpx;white-space:nowrap}.progress-step text{display:flex;align-items:center;justify-content:center;width:42rpx;height:42rpx;border-radius:50%;background:#e0e9e2;color:#8da095;font-size:22rpx;font-weight:700}.progress-step label{margin-top:8rpx}.progress-step.active{color:#3d6652}.progress-step.active text{background:#3d6652;color:#fff}.progress-line{height:2rpx;flex:1;margin:0 12rpx 30rpx;background:#dce6de}.progress-line.active{background:#7ca48a}.form-card,.result-card{padding:34rpx 28rpx;border:1rpx solid #e1ebe3;border-radius:24rpx;background:#fbfdfb;box-shadow:0 18rpx 46rpx rgba(55,94,72,.08)}.section-title{color:#2e4a3d;font-size:34rpx;font-weight:800}.section-desc{margin-top:10rpx;color:#87978c;font-size:23rpx;line-height:1.55}.field{margin-top:26rpx}.field-label{display:block;margin-bottom:12rpx;color:#577061;font-size:23rpx;font-weight:700}.field input,.picker-value{box-sizing:border-box;width:100%;height:84rpx;padding:0 24rpx;border:1rpx solid #dfe9e1;border-radius:14rpx;background:#f7faf7;color:#2e4a3d;font-size:27rpx}.picker-value{display:flex;align-items:center;color:#a0ada4}.picker-value.filled{color:#2e4a3d}.code-row{display:flex;align-items:center;gap:14rpx}.code-input{min-width:0;flex:1}.code-btn{width:176rpx;min-width:176rpx;height:68rpx;padding:0;border:1rpx solid #b9d0c0;border-radius:12rpx;background:#edf5ef;color:#3d6652;font-size:23rpx;font-weight:700;line-height:68rpx;white-space:nowrap}.code-btn.counting{border-color:#e0e8e2;background:#f4f7f4;color:#9ca9a0;font-weight:500}.secondary-entry,.back-entry{margin-top:24rpx;color:#5b806b;font-size:24rpx;text-align:center}.secondary-entry text{margin-left:8rpx;font-size:30rpx}.password-panel{padding-bottom:4rpx}.primary-btn{margin-top:30rpx;height:84rpx;border-radius:14rpx;background:#3d6652;color:#fff;font-size:28rpx;font-weight:700;line-height:84rpx}.role-list{margin-top:28rpx}.role-option{display:flex;align-items:center;min-height:112rpx;margin-top:16rpx;padding:0 20rpx;border:1rpx solid #e1ebe3;border-radius:16rpx;background:#f8fbf8}.role-option.selected{border-color:#78a288;background:#edf6ef;box-shadow:0 10rpx 22rpx rgba(61,102,82,.08)}.role-icon{display:flex;align-items:center;justify-content:center;width:64rpx;height:64rpx;border-radius:18rpx;background:#dce9df;color:#3d6652;font-size:25rpx;font-weight:800}.role-copy{display:flex;flex:1;flex-direction:column;margin-left:18rpx}.role-title{color:#2e4a3d;font-size:28rpx;font-weight:700}.role-desc{margin-top:8rpx;color:#8b9b90;font-size:22rpx}.role-mark{color:#6f9780;font-size:34rpx}.notice{margin-top:18rpx;padding:18rpx;border-radius:12rpx;background:#f1f6f2;color:#718579;font-size:22rpx;line-height:1.5}.result-card{display:flex;flex-direction:column;align-items:center;padding-top:64rpx;text-align:center}.result-icon{display:flex;align-items:center;justify-content:center;width:92rpx;height:92rpx;border-radius:50%;background:#dcece0;color:#3d6652;font-size:48rpx;font-weight:800}.result-card .section-title{margin-top:24rpx}.result-status{margin-top:28rpx;padding:18rpx 28rpx;border-radius:12rpx;background:#f1f6f2;color:#75887b;font-size:24rpx}.result-status text{color:#c28b47;font-weight:700}.safe-note{margin-top:28rpx;color:#9aa9a0;font-size:21rpx;line-height:1.5;text-align:center}
|
||||
|
||||
Reference in New Issue
Block a user