实现手机号登录自动进入注册审核流程 #52

Merged
xiaowang merged 1 commits from dev into sit 2026-09-10 13:49:58 +08:00
11 changed files with 265 additions and 34 deletions
@@ -0,0 +1,13 @@
package com.xiaowang.jacyucloudsalon.core.modules.auth.service;
import com.xiaowang.jacyucloudsalon.core.modules.auth.vo.PhoneRegistrationTicketVO;
/**
* 管理已完成手机号验证的注册引导凭证。
*/
public interface PhoneRegistrationTicketService {
PhoneRegistrationTicketVO issue(String phone, Long userId, Long applicationId);
PhoneRegistrationTicketVO consume(String ticket, String phone);
}
@@ -0,0 +1,63 @@
package com.xiaowang.jacyucloudsalon.core.modules.auth.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.PhoneRegistrationTicketService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.vo.PhoneRegistrationTicketVO;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.time.Duration;
import java.util.UUID;
/**
* 基于 Redis 的一次性手机号注册凭证服务。
*/
@Service
@RequiredArgsConstructor
public class PhoneRegistrationTicketServiceImpl implements PhoneRegistrationTicketService {
private static final String KEY_PREFIX = "workbench:registration:ticket:";
private static final Duration TTL = Duration.ofMinutes(10);
private final StringRedisTemplate redisTemplate;
private final ObjectMapper objectMapper;
@Override
public PhoneRegistrationTicketVO issue(String phone, Long userId, Long applicationId) {
String normalizedPhone = requireText(phone, "手机号不能为空");
String ticket = UUID.randomUUID().toString().replace("-", "");
PhoneRegistrationTicketVO value = new PhoneRegistrationTicketVO(ticket, normalizedPhone, userId, applicationId);
try {
redisTemplate.opsForValue().set(KEY_PREFIX + ticket, objectMapper.writeValueAsString(value), TTL);
} catch (JsonProcessingException exception) {
throw new IllegalStateException("生成手机号注册凭证失败", exception);
}
return value;
}
@Override
public PhoneRegistrationTicketVO consume(String ticket, String phone) {
String normalizedTicket = requireText(ticket, "手机号注册凭证不能为空");
String payload = redisTemplate.opsForValue().getAndDelete(KEY_PREFIX + normalizedTicket);
if (payload == null) {
throw new IllegalStateException("手机号注册凭证已过期或已使用,请重新验证手机号");
}
try {
PhoneRegistrationTicketVO value = objectMapper.readValue(payload, PhoneRegistrationTicketVO.class);
if (!value.getPhone().equals(requireText(phone, "手机号不能为空"))) {
throw new IllegalStateException("手机号与已验证凭证不一致");
}
return value;
} catch (JsonProcessingException exception) {
throw new IllegalStateException("手机号注册凭证无效", exception);
}
}
private String requireText(String value, String message) {
if (value == null || value.trim().isEmpty()) {
throw new IllegalArgumentException(message);
}
return value.trim();
}
}
@@ -36,6 +36,21 @@ public class LoginResponseVO {
*/
private boolean needSetPassword; // 是否需要设置密码
private boolean registrationRequired;
private String phone;
private String registrationTicket;
private String registrationReason;
private String registrationStatus;
private String registrationRejectReason;
@JsonSerialize(using = ToStringSerializer.class)
private Long registrationApplicationId;
@Data
/**
* Purpose: UserInfo supports LoginResponseVO.java by holding or executing the user info business role.
@@ -0,0 +1,18 @@
package com.xiaowang.jacyucloudsalon.core.modules.auth.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 已验证手机号注册引导凭证。
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class PhoneRegistrationTicketVO {
private String ticket;
private String phone;
private Long userId;
private Long applicationId;
}
@@ -7,6 +7,7 @@ import lombok.Setter;
@Setter
public class WorkbenchRegistrationRequestDTO {
private Long applicationId;
private String registrationTicket;
private String wxCode;
private String phone;
private String verificationCode;
@@ -2,6 +2,8 @@ package com.xiaowang.jacyucloudsalon.core.modules.registration.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.VerificationCodeService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.PhoneRegistrationTicketService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.vo.PhoneRegistrationTicketVO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRequestDTO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationRole;
@@ -15,6 +17,8 @@ import com.xiaowang.jacyucloudsalon.core.modules.integration.service.WechatMiniC
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.ShopMapper;
import com.xiaowang.jacyucloudsalon.core.modules.shop.support.UserShopBindingSupport;
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.UserShopBindingDO;
import com.xiaowang.jacyucloudsalon.core.modules.shop.mapper.UserShopBindingMapper;
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
import com.xiaowang.jacyucloudsalon.core.modules.user.service.UserService;
@@ -35,7 +39,9 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
private final ShopMapper shopMapper;
private final UserService userService;
private final VerificationCodeService verificationCodeService;
private final PhoneRegistrationTicketService phoneRegistrationTicketService;
private final UserShopBindingSupport userShopBindingSupport;
private final UserShopBindingMapper userShopBindingMapper;
private final WechatMiniBindingMapper wechatMiniBindingMapper;
private final WechatMiniClientService wechatMiniClientService;
private final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
@@ -46,7 +52,9 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
ShopMapper shopMapper,
UserService userService,
VerificationCodeService verificationCodeService,
PhoneRegistrationTicketService phoneRegistrationTicketService,
UserShopBindingSupport userShopBindingSupport,
UserShopBindingMapper userShopBindingMapper,
WechatMiniBindingMapper wechatMiniBindingMapper,
WechatMiniClientService wechatMiniClientService
) {
@@ -55,7 +63,9 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
this.shopMapper = shopMapper;
this.userService = userService;
this.verificationCodeService = verificationCodeService;
this.phoneRegistrationTicketService = phoneRegistrationTicketService;
this.userShopBindingSupport = userShopBindingSupport;
this.userShopBindingMapper = userShopBindingMapper;
this.wechatMiniBindingMapper = wechatMiniBindingMapper;
this.wechatMiniClientService = wechatMiniClientService;
}
@@ -65,12 +75,22 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
public WorkbenchRegistrationStatusVO register(WorkbenchRegistrationRequestDTO request) {
require(request != null, "注册信息不能为空");
String phone = requireText(request.getPhone(), "手机号不能为空");
PhoneRegistrationTicketVO ticket = null;
if (StringUtils.hasText(request.getRegistrationTicket())) {
ticket = phoneRegistrationTicketService.consume(request.getRegistrationTicket(), phone);
phone = ticket.getPhone();
} else {
require(verificationCodeService.verifyCode(phone, request.getVerificationCode()), "验证码错误或已过期");
}
String roleType = requireText(request.getRoleType(), "请选择注册身份").toUpperCase();
require(WorkbenchRegistrationRole.MANAGER.equals(roleType) || WorkbenchRegistrationRole.STAFF.equals(roleType), "注册身份不合法");
require(verificationCodeService.verifyCode(phone, request.getVerificationCode()), "验证码错误或已过期");
require(request.getAgreementAccepted() == null || request.getAgreementAccepted(), "请先同意用户协议和隐私政策");
UserDO existing = userMapper.selectOne(Wrappers.lambdaQuery(UserDO.class).eq(UserDO::getPhone, phone).eq(UserDO::getIsDelete, 0).last("limit 1"));
require(existing == null, "该手机号已注册,请直接登录或查看审核状态");
if (ticket != null) {
require(ticket.getUserId() == null || existing != null && ticket.getUserId().equals(existing.getId()), "手机号注册凭证与账号不匹配");
} else {
require(existing == null, "该手机号已注册,请直接登录或查看审核状态");
}
require(StringUtils.hasText(request.getPassword()), "密码不能为空");
require(request.getPassword().equals(request.getConfirmPassword()), "两次密码不一致");
@@ -91,7 +111,7 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
require(shop != null, "店铺不存在或暂未营业");
}
UserDO user = new UserDO();
UserDO user = existing == null ? new UserDO() : existing;
user.setShopId(shop.getId());
user.setNickname((WorkbenchRegistrationRole.MANAGER.equals(roleType) ? shop.getShopName() + "店长" : "Salon店员"));
user.setAccount(phone);
@@ -102,13 +122,29 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
user.setType(WorkbenchRegistrationRole.MANAGER.equals(roleType) ? 2 : 3);
user.setStatus(0);
user.setIsDelete(0);
userMapper.insert(user);
if (existing == null) {
userMapper.insert(user);
} else {
userMapper.updateById(user);
}
bindWechatUser(request.getWxCode(), user.getId());
userShopBindingSupport.syncUserShopBindings(user.getId(), List.of(shop.getId()));
userShopBindingSupport.updateBindingStatus(user.getId(), shop.getId(), 0);
if (WorkbenchRegistrationRole.MANAGER.equals(roleType)) {
createPendingBinding(user.getId(), shop.getId());
} else {
userShopBindingSupport.syncUserShopBindings(user.getId(), List.of(shop.getId()));
userShopBindingSupport.updateBindingStatus(user.getId(), shop.getId(), 0);
}
WorkbenchRegistrationApplicationDO application = new WorkbenchRegistrationApplicationDO();
application.setApplicationNo("SALON-" + UUID.randomUUID().toString().replace("-", "").substring(0, 20).toUpperCase());
WorkbenchRegistrationApplicationDO application = ticket == null || ticket.getApplicationId() == null
? new WorkbenchRegistrationApplicationDO()
: applicationMapper.selectById(ticket.getApplicationId());
if (application.getId() != null) {
require(existing != null && existing.getId().equals(application.getUserId()), "注册申请与账号不匹配");
require(WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus()), "该注册申请当前不可重新提交");
}
if (!StringUtils.hasText(application.getApplicationNo())) {
application.setApplicationNo("SALON-" + UUID.randomUUID().toString().replace("-", "").substring(0, 20).toUpperCase());
}
application.setUserId(user.getId());
application.setRoleType(roleType);
application.setShopId(shop.getId());
@@ -116,7 +152,11 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
application.setShopAddress(shop.getAddress());
application.setStatus(WorkbenchRegistrationRole.MANAGER.equals(roleType) ? WorkbenchRegistrationStatus.PENDING_ADMIN : WorkbenchRegistrationStatus.PENDING_MANAGER);
application.setIsDelete(0);
applicationMapper.insert(application);
if (application.getId() == null) {
applicationMapper.insert(application);
} else {
applicationMapper.updateById(application);
}
return toStatus(application);
}
@@ -133,7 +173,14 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
require(request != null && request.getApplicationId() != null, "申请信息不能为空");
WorkbenchRegistrationApplicationDO application = applicationMapper.selectById(request.getApplicationId());
require(application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus()), "该申请当前不可重新提交");
require(verificationCodeService.verifyCode(requireText(request.getPhone(), "手机号不能为空"), request.getVerificationCode()), "验证码错误或已过期");
String phone = requireText(request.getPhone(), "手机号不能为空");
if (StringUtils.hasText(request.getRegistrationTicket())) {
PhoneRegistrationTicketVO ticket = phoneRegistrationTicketService.consume(request.getRegistrationTicket(), phone);
require(ticket.getApplicationId() != null && ticket.getApplicationId().equals(application.getId()), "手机号注册凭证与申请不匹配");
require(ticket.getUserId() == null || ticket.getUserId().equals(application.getUserId()), "手机号注册凭证与账号不匹配");
} else {
require(verificationCodeService.verifyCode(phone, request.getVerificationCode()), "验证码错误或已过期");
}
application.setStatus(WorkbenchRegistrationRole.MANAGER.equals(application.getRoleType()) ? WorkbenchRegistrationStatus.PENDING_ADMIN : WorkbenchRegistrationStatus.PENDING_MANAGER);
application.setRejectReason(null);
application.setReviewerId(null);
@@ -214,6 +261,25 @@ public class WorkbenchRegistrationServiceImpl implements WorkbenchRegistrationSe
return value.trim();
}
private void createPendingBinding(Long userId, Long shopId) {
UserShopBindingDO binding = userShopBindingMapper.selectOne(Wrappers.lambdaQuery(UserShopBindingDO.class)
.eq(UserShopBindingDO::getUserId, userId)
.eq(UserShopBindingDO::getShopId, shopId)
.last("limit 1"));
if (binding == null) {
binding = new UserShopBindingDO();
binding.setUserId(userId);
binding.setShopId(shopId);
binding.setStatus(0);
binding.setIsDelete(0);
userShopBindingMapper.insert(binding);
return;
}
binding.setStatus(0);
binding.setIsDelete(0);
userShopBindingMapper.updateById(binding);
}
private void bindWechatUser(String wxCode, Long userId) {
if (!StringUtils.hasText(wxCode)) {
return;
@@ -450,9 +450,11 @@ public class UserController {
legalAgreementService.requireAccepted(phoneLoginRequestDTO);
try {
LoginResponseVO loginResponseVO = userService.phoneLogin(phoneLoginRequestDTO);
legalAgreementService.recordConsent(loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO, "USER_PHONE_LOGIN", request);
if (loginResponseVO.getUserInfo() != null) {
legalAgreementService.recordConsent(loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO, "USER_PHONE_LOGIN", request);
}
requestThrottleService.clearLoginFailure(request, phoneLoginRequestDTO.getPhone());
securityAuditLogService.record(loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO.getPhone(), "USER_PHONE_LOGIN", "SUCCESS", null, request);
securityAuditLogService.record(loginResponseVO.getUserInfo() == null ? null : loginResponseVO.getUserInfo().getId(), phoneLoginRequestDTO.getPhone(), "USER_PHONE_LOGIN", "SUCCESS", null, request);
return Result.success(loginResponseVO);
} catch (RuntimeException exception) {
requestThrottleService.recordLoginFailure(request, phoneLoginRequestDTO.getPhone());
@@ -28,6 +28,11 @@ import com.xiaowang.jacyucloudsalon.core.modules.shop.service.ShopService;
import com.xiaowang.jacyucloudsalon.core.modules.system.service.SystemParameterConfigService;
import com.xiaowang.jacyucloudsalon.core.modules.user.service.UserService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.VerificationCodeService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.service.PhoneRegistrationTicketService;
import com.xiaowang.jacyucloudsalon.core.modules.auth.vo.PhoneRegistrationTicketVO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationStatus;
import com.xiaowang.jacyucloudsalon.core.modules.registration.mapper.WorkbenchRegistrationApplicationMapper;
import com.xiaowang.jacyucloudsalon.core.modules.system.support.AdminDefaultPasswordSupport;
import com.xiaowang.jacyucloudsalon.core.modules.file.support.ObjectStorageUrlSupport;
import com.xiaowang.jacyucloudsalon.core.modules.security.support.PermissionCatalog;
@@ -167,6 +172,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
* Variable `verificationCodeService`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
*/
private final VerificationCodeService verificationCodeService;
private final PhoneRegistrationTicketService phoneRegistrationTicketService;
private final WorkbenchRegistrationApplicationMapper registrationApplicationMapper;
/**
* Variable `userShopBindingSupport`: Spring-injected collaborator used by this class to finish database access, validation, or downstream calls.
*/
@@ -1074,30 +1081,42 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
);
if (userDO == null) {
if (phoneLoginRequestDTO.getShopId() == null || phoneLoginRequestDTO.getShopId() == 0) {
/**
* Run business method `RuntimeException`.
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
* @return throw new result consumed by the caller or returned to the frontend
*/
throw new RuntimeException("首次登录需要选择店铺");
}
userDO = registerByPhone(phoneLoginRequestDTO.getPhone(), phoneLoginRequestDTO.getShopId());
} else {
/**
* Run business method `assertUserAvailable`.
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
* @param userDO parameter `userDO` supplied by the caller
* @return result consumed by the caller or returned to the frontend
*/
assertUserAvailable(userDO);
clearLoginFailureCount(userDO.getAccount());
return buildRegistrationRequiredResponse(phoneLoginRequestDTO.getPhone(), null, "PHONE_NOT_REGISTERED");
}
if (userShopBindingSupport.listActiveShopIdsByUserId(userDO.getId()).isEmpty()) {
return buildRegistrationRequiredResponse(phoneLoginRequestDTO.getPhone(), userDO, "NO_SHOP_BINDING");
}
assertUserAvailable(userDO);
clearLoginFailureCount(userDO.getAccount());
Long resolvedShopId = resolveUserLoginShopId(userDO, phoneLoginRequestDTO.getShopId());
return buildLoginResponse(userDO, resolvedShopId, ENCODED_UNSET_PASSWORD.equals(userDO.getPassword()), Boolean.TRUE.equals(phoneLoginRequestDTO.getRememberMe()));
}
private LoginResponseVO buildRegistrationRequiredResponse(String phone, UserDO userDO, String reason) {
WorkbenchRegistrationApplicationDO application = userDO == null ? null : registrationApplicationMapper.selectOne(
Wrappers.lambdaQuery(WorkbenchRegistrationApplicationDO.class)
.eq(WorkbenchRegistrationApplicationDO::getUserId, userDO.getId())
.eq(WorkbenchRegistrationApplicationDO::getIsDelete, 0)
.orderByDesc(WorkbenchRegistrationApplicationDO::getCreateTime)
.last("limit 1")
);
LoginResponseVO response = new LoginResponseVO();
response.setRegistrationRequired(true);
response.setPhone(phone);
response.setRegistrationReason(reason);
response.setRegistrationStatus(application == null ? null : application.getStatus());
response.setRegistrationRejectReason(application == null ? null : application.getRejectReason());
boolean rejected = application != null && WorkbenchRegistrationStatus.REJECTED.equals(application.getStatus());
boolean approvedWithoutBinding = application != null && WorkbenchRegistrationStatus.APPROVED.equals(application.getStatus());
response.setRegistrationApplicationId(rejected ? application.getId() : null);
if (application == null || rejected || approvedWithoutBinding) {
PhoneRegistrationTicketVO ticket = phoneRegistrationTicketService.issue(phone, userDO == null ? null : userDO.getId(), rejected ? application.getId() : null);
response.setRegistrationTicket(ticket.getTicket());
}
return response;
}
// 未设置密码的特殊标识
@Override
/**
+24
View File
@@ -276,6 +276,26 @@ Page({
return null
},
openRegistrationFlow(data) {
const ticket = String(data.registrationTicket || '').trim()
const status = data.registrationStatus
if (status === 'PENDING_ADMIN' || status === 'PENDING_MANAGER') {
wx.showToast({ title: status === 'PENDING_ADMIN' ? '管理员审核中' : '店长审核中', icon: 'none', duration: 2500 })
return
}
if (!ticket) {
wx.showToast({ title: data.registrationRejectReason || '该手机号需要先完成身份注册', icon: 'none', duration: 2200 })
return
}
wx.showToast({ title: '手机号已验证,请完成身份注册', icon: 'none', duration: 1600 })
const query = [
`registrationTicket=${encodeURIComponent(ticket)}`,
`phone=${encodeURIComponent(data.phone || this.data.form.phone || '')}`,
data.registrationApplicationId ? `applicationId=${encodeURIComponent(data.registrationApplicationId)}` : ''
].filter(Boolean).join('&')
setTimeout(() => wx.navigateTo({ url: `/pages/register/index?${query}` }), 700)
},
buildLoginRequestData(shopId) {
const form = this.data.form
if (this.data.loginMode === 'phone') {
@@ -433,6 +453,10 @@ Page({
try {
const app = getApp()
const data = await this.requestLogin('')
if (this.data.loginMode === 'phone' && data && data.registrationRequired) {
this.openRegistrationFlow(data)
return
}
const session = await this.resolveLoginSession(data)
if (!session) {
return
+13 -3
View File
@@ -9,6 +9,9 @@ Page({
passwordMode: false,
form: { phone: '', code: '', password: '', confirmPassword: '', shopName: '', shopAddress: '', shopId: '' },
wxCode: '',
registrationTicket: '',
applicationId: '',
phoneVerified: false,
shopOptions: [],
shopIndex: 0,
selectedShopName: '',
@@ -19,7 +22,15 @@ Page({
},
async onLoad(options) {
this.setData({ wxCode: options && options.wxCode ? options.wxCode : '' })
const registrationTicket = options && options.registrationTicket ? options.registrationTicket : ''
this.setData({
wxCode: options && options.wxCode ? options.wxCode : '',
registrationTicket,
applicationId: options && options.applicationId ? options.applicationId : '',
phoneVerified: Boolean(registrationTicket),
'form.phone': options && options.phone ? options.phone : '',
step: registrationTicket ? 2 : 1
})
try {
const shopOptions = await authApi.getAvailableRegistrationShops()
this.setData({ shopOptions: Array.isArray(shopOptions) ? shopOptions : [] })
@@ -64,10 +75,9 @@ Page({
const form = this.data.form
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({ phone: form.phone, verificationCode: form.code, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode: this.data.wxCode })
await authApi.register({ phone: form.phone, verificationCode: this.data.registrationTicket ? undefined : form.code, registrationTicket: this.data.registrationTicket || undefined, applicationId: this.data.applicationId || undefined, password: form.password, confirmPassword: form.confirmPassword, shopName: form.shopName, shopAddress: form.shopAddress, shopId: form.shopId, roleType: this.data.role === 'manager' ? 'MANAGER' : 'STAFF', agreementAccepted: true, wxCode: this.data.wxCode })
this.setData({ step: 4 })
} catch (error) { wx.showToast({ title: error.message || '提交失败', icon: 'none' }) } finally { this.setData({ loading: false }) }
},
+1 -1
View File
@@ -3,7 +3,7 @@
<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><input value="{{form.phone}}" data-field="phone" bindinput="onInput" type="number" disabled="{{phoneVerified}}" placeholder="请输入手机号" /><text wx:if="{{phoneVerified}}" class="verified-tip">手机号已验证</text></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>