修复管理师端预约与登录体验
This commit is contained in:
+1
-1
@@ -20,5 +20,5 @@ public class BrandProperties {
|
||||
/**
|
||||
* 管理师注册店铺的默认描述。
|
||||
*/
|
||||
private String managerRegisterShopDescription = "指尖管理师注册店铺";
|
||||
private String managerRegisterShopDescription = "甲屿店务注册店铺";
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ public class JwtProperties {
|
||||
*/
|
||||
private long accessTokenExpirationSeconds = 2 * 60 * 60;
|
||||
|
||||
/**
|
||||
* 记住登录 AccessToken 有效期,单位秒。
|
||||
*/
|
||||
private long rememberMeAccessTokenExpirationSeconds = 60 * 60;
|
||||
|
||||
/**
|
||||
* RefreshToken 有效期,单位秒。
|
||||
*/
|
||||
|
||||
+5
@@ -34,6 +34,11 @@ public class PhoneLoginRequestDTO implements AgreementAwareRequest {
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 记住登录标志
|
||||
*/
|
||||
private Boolean rememberMe;
|
||||
|
||||
/**
|
||||
* Purpose: agreementAccepted supports PhoneLoginRequestDTO.java by holding or executing the agreement accepted business role.
|
||||
* Usage: reference this field from the owning layer and pass validated inputs before reading or updating related state.
|
||||
|
||||
+24
@@ -9,6 +9,7 @@ import com.xiaowang.fingertipdesigner.core.modules.artist.dto.NailArtistInfoDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.service.ArtistScheduleService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.service.NailArtistInfoService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.vo.ArtistScheduleVO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.manager.dto.ManagerCustomerCreateDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.dto.PlanningAppointmentMoveDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.dto.PlanningAppointmentStatusDTO;
|
||||
@@ -125,6 +126,28 @@ public class AdminManagerController {
|
||||
return Result.success(userService.getUserById(id));
|
||||
}
|
||||
|
||||
@PostMapping("/customers")
|
||||
@RequirePermission("user:create")
|
||||
@OperationGuard(action = "manager-customer-create", ttlSeconds = 10, message = "客户创建处理中,请勿重复提交")
|
||||
public Result<Long> createCustomer(HttpServletRequest request,
|
||||
@Valid @RequestBody ManagerCustomerCreateDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
adminScopeHelper.requireShopContext(currentUser, "请先选择店铺后再新增客户");
|
||||
Long shopId = adminScopeHelper.resolveShopScope(currentUser, null);
|
||||
String phone = dto.getPhone().trim();
|
||||
UserDTO userDTO = new UserDTO();
|
||||
userDTO.setNickname(dto.getNickname().trim());
|
||||
userDTO.setPhone(phone);
|
||||
userDTO.setContactPhone(phone);
|
||||
userDTO.setAccount(phone);
|
||||
userDTO.setType(0);
|
||||
userDTO.setShopId(shopId);
|
||||
userDTO.setShopIds(List.of(shopId));
|
||||
userDTO.setLevel("普通");
|
||||
userDTO.setVipId(0L);
|
||||
return Result.success(userService.createUser(userDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/employees")
|
||||
@RequirePermission("nail_artist:view")
|
||||
public Result<List<NailArtistInfoDTO>> employees(HttpServletRequest request) {
|
||||
@@ -164,6 +187,7 @@ public class AdminManagerController {
|
||||
public Result<Long> createEmployeeUser(HttpServletRequest request,
|
||||
@Valid @RequestBody UserDTO dto) {
|
||||
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
|
||||
dto.setType(3);
|
||||
adminScopeHelper.ensureAssignableUserType(currentUser, dto.getType());
|
||||
if (!adminScopeHelper.isPlatformAdmin(currentUser)) {
|
||||
Long managedShopId = adminScopeHelper.getManagedShopId(currentUser);
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.xiaowang.fingertipdesigner.core.modules.manager.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
@Data
|
||||
public class ManagerCustomerCreateDTO {
|
||||
|
||||
@NotBlank(message = "客户姓名不能为空")
|
||||
private String nickname;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
|
||||
private String phone;
|
||||
}
|
||||
+5
-5
@@ -481,7 +481,7 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
vo.setProductId(product == null ? item == null ? null : item.getProductId() : product.getId());
|
||||
vo.setProductTitle(reservation != null && hasText(reservation.getProductTitle())
|
||||
? reservation.getProductTitle()
|
||||
: product == null ? "预约项目" : product.getTitle());
|
||||
: product == null ? "预约作品" : product.getTitle());
|
||||
vo.setArtistId(artistId);
|
||||
vo.setArtistName(artist == null ? "未分配" : artist.getName());
|
||||
vo.setArtistColor(artist == null ? ARTIST_COLORS.get(0) : artist.getColor());
|
||||
@@ -578,11 +578,11 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
|
||||
private ProductDO requireActiveProduct(Long productId, Long shopId) {
|
||||
if (productId == null) {
|
||||
throw new RuntimeException("请选择预约项目");
|
||||
throw new RuntimeException("请选择预约作品");
|
||||
}
|
||||
ProductDO product = productMapper.selectById(productId);
|
||||
if (product == null || Integer.valueOf(1).equals(product.getIsDelete()) || !shopId.equals(product.getShopId())) {
|
||||
throw new RuntimeException("预约项目不存在或不属于当前店铺");
|
||||
throw new RuntimeException("预约作品不存在或不属于当前店铺");
|
||||
}
|
||||
return product;
|
||||
}
|
||||
@@ -597,11 +597,11 @@ public class PlanningServiceImpl implements PlanningService {
|
||||
private ProductDO createManualAppointmentProduct(PlanningAppointmentCreateDTO dto, Long shopId) {
|
||||
String title = trimToNull(dto.getManualProductTitle());
|
||||
if (!hasText(title)) {
|
||||
throw new RuntimeException("请选择预约项目或填写手动项目名称");
|
||||
throw new RuntimeException("请选择预约作品或填写手动作品名称");
|
||||
}
|
||||
BigDecimal price = dto.getManualProductPrice();
|
||||
if (price == null || price.compareTo(BigDecimal.ZERO) < 0) {
|
||||
throw new RuntimeException("手动项目价格不能小于0");
|
||||
throw new RuntimeException("手动作品价格不能小于0");
|
||||
}
|
||||
int durationMinutes = dto.getDurationMinutes() == null || dto.getDurationMinutes() <= 0
|
||||
? DEFAULT_DURATION_MINUTES
|
||||
|
||||
+13
-4
@@ -1062,7 +1062,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
* @param false parameter `false` supplied by the caller
|
||||
* @return return result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
return buildLoginResponse(userDO, resolvedShopId, false);
|
||||
return buildLoginResponse(userDO, resolvedShopId, false, Boolean.TRUE.equals(loginRequestDTO.getRememberMe()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1110,7 +1110,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
}
|
||||
|
||||
Long resolvedShopId = resolveUserLoginShopId(userDO, phoneLoginRequestDTO.getShopId());
|
||||
return buildLoginResponse(userDO, resolvedShopId, ENCODED_UNSET_PASSWORD.equals(userDO.getPassword()));
|
||||
return buildLoginResponse(userDO, resolvedShopId, ENCODED_UNSET_PASSWORD.equals(userDO.getPassword()), Boolean.TRUE.equals(phoneLoginRequestDTO.getRememberMe()));
|
||||
}
|
||||
|
||||
// 未设置密码的特殊标识
|
||||
@@ -1279,7 +1279,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
* @param false parameter `false` supplied by the caller
|
||||
* @return return result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
return buildLoginResponse(userDO, resolvedShopId, false);
|
||||
return buildLoginResponse(userDO, resolvedShopId, false, Boolean.TRUE.equals(loginRequestDTO.getRememberMe()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -2751,6 +2751,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
return buildLoginResponse(userDO, currentShopId, needSetPassword, null);
|
||||
}
|
||||
|
||||
private LoginResponseVO buildLoginResponse(UserDO userDO, Long currentShopId, boolean needSetPassword, boolean rememberMe) {
|
||||
return buildLoginResponse(userDO, currentShopId, needSetPassword, null, rememberMe);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run business method `buildLoginResponse`.
|
||||
* Call guide: pass the named parameters below from the controller or caller; the method validates them and returns the business result.
|
||||
@@ -2761,6 +2765,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
* @return private LoginResponseVO result consumed by the caller or returned to the frontend
|
||||
*/
|
||||
private LoginResponseVO buildLoginResponse(UserDO userDO, Long currentShopId, boolean needSetPassword, String previousSessionId) {
|
||||
return buildLoginResponse(userDO, currentShopId, needSetPassword, previousSessionId, false);
|
||||
}
|
||||
|
||||
private LoginResponseVO buildLoginResponse(UserDO userDO, Long currentShopId, boolean needSetPassword, String previousSessionId, boolean rememberMe) {
|
||||
UserSessionService.SessionIssueResult sessionIssueResult = StringUtils.hasText(previousSessionId)
|
||||
? userSessionService.rotateSession(previousSessionId, userDO.getId(), userDO.getAccount(), currentShopId, userDO.getType())
|
||||
: userSessionService.issueSession(userDO.getId(), userDO.getAccount(), currentShopId, userDO.getType());
|
||||
@@ -2769,7 +2777,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, UserDO> implements
|
||||
userDO.getAccount(),
|
||||
currentShopId,
|
||||
sessionIssueResult.sessionId(),
|
||||
sessionIssueResult.accessJti()
|
||||
sessionIssueResult.accessJti(),
|
||||
jwtUtil.resolveAccessTokenExpirationSeconds(rememberMe)
|
||||
);
|
||||
String refreshToken = jwtUtil.generateRefreshToken(
|
||||
userDO.getId(),
|
||||
|
||||
@@ -41,6 +41,10 @@ public class JwtUtil {
|
||||
* Usage: reference this method from the owning layer and pass validated inputs before reading or updating related state.
|
||||
*/
|
||||
public String generateAccessToken(Long userId, String account, Long currentShopId, String sessionId, String jti) {
|
||||
return generateAccessToken(userId, account, currentShopId, sessionId, jti, jwtProperties.getAccessTokenExpirationSeconds());
|
||||
}
|
||||
|
||||
public String generateAccessToken(Long userId, String account, Long currentShopId, String sessionId, String jti, long expirationSeconds) {
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
claims.put("userId", userId);
|
||||
claims.put("account", account);
|
||||
@@ -50,7 +54,13 @@ public class JwtUtil {
|
||||
if (currentShopId != null && currentShopId > 0) {
|
||||
claims.put("shopId", currentShopId);
|
||||
}
|
||||
return createToken(claims, userId.toString(), jwtProperties.getAccessTokenExpirationSeconds() * 1000);
|
||||
return createToken(claims, userId.toString(), expirationSeconds * 1000);
|
||||
}
|
||||
|
||||
public long resolveAccessTokenExpirationSeconds(boolean rememberMe) {
|
||||
return rememberMe
|
||||
? jwtProperties.getRememberMeAccessTokenExpirationSeconds()
|
||||
: jwtProperties.getAccessTokenExpirationSeconds();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,12 @@ mybatis:
|
||||
fingertip-designer:
|
||||
brand:
|
||||
message-template-name: ${PLATFORM_MESSAGE_TEMPLATE_NAME:FingertipDesigner}
|
||||
manager-register-shop-description: ${PLATFORM_MANAGER_REGISTER_SHOP_DESCRIPTION:指尖管理师注册店铺}
|
||||
manager-register-shop-description: ${PLATFORM_MANAGER_REGISTER_SHOP_DESCRIPTION:甲屿店务注册店铺}
|
||||
security:
|
||||
jwt:
|
||||
issuer: fingertip-designer
|
||||
access-token-expiration-seconds: 7200
|
||||
remember-me-access-token-expiration-seconds: 3600
|
||||
refresh-token-expiration-seconds: 604800
|
||||
clock-skew-seconds: 30
|
||||
signature:
|
||||
|
||||
+49
@@ -7,6 +7,7 @@ import com.xiaowang.fingertipdesigner.core.modules.artist.dto.NailArtistInfoDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.service.ArtistScheduleService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.service.NailArtistInfoService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.vo.ArtistScheduleVO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.manager.dto.ManagerCustomerCreateDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.service.PlanningService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.product.service.ProductService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.product.vo.ProductVO;
|
||||
@@ -28,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -109,6 +111,53 @@ class AdminManagerControllerTest {
|
||||
verify(adminScopeHelper).ensureAssignableUserType(manager, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createEmployeeUserShouldForceNailArtistType() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
UserDO manager = new UserDO();
|
||||
manager.setType(2);
|
||||
UserDTO dto = new UserDTO();
|
||||
dto.setType(0);
|
||||
when(adminScopeHelper.getCurrentUser(request)).thenReturn(manager);
|
||||
when(adminScopeHelper.isPlatformAdmin(manager)).thenReturn(true);
|
||||
when(userService.createUser(dto)).thenReturn(102L);
|
||||
|
||||
Result<Long> result = controller.createEmployeeUser(request, dto);
|
||||
|
||||
assertThat(result.getData()).isEqualTo(102L);
|
||||
assertThat(dto.getType()).isEqualTo(3);
|
||||
verify(adminScopeHelper).ensureAssignableUserType(manager, 3);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createCustomerShouldForceNormalUserInCurrentShop() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
UserDO manager = new UserDO();
|
||||
manager.setType(2);
|
||||
ManagerCustomerCreateDTO dto = new ManagerCustomerCreateDTO();
|
||||
dto.setNickname(" 小王客户 ");
|
||||
dto.setPhone(" 13800138000 ");
|
||||
when(adminScopeHelper.getCurrentUser(request)).thenReturn(manager);
|
||||
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
|
||||
when(userService.createUser(any(UserDTO.class))).thenReturn(103L);
|
||||
|
||||
Result<Long> result = controller.createCustomer(request, dto);
|
||||
|
||||
assertThat(result.getData()).isEqualTo(103L);
|
||||
verify(adminScopeHelper).requireShopContext(manager, "请先选择店铺后再新增客户");
|
||||
verify(userService).createUser(org.mockito.ArgumentMatchers.argThat(userDTO ->
|
||||
"小王客户".equals(userDTO.getNickname())
|
||||
&& "13800138000".equals(userDTO.getPhone())
|
||||
&& "13800138000".equals(userDTO.getContactPhone())
|
||||
&& "13800138000".equals(userDTO.getAccount())
|
||||
&& Integer.valueOf(0).equals(userDTO.getType())
|
||||
&& Long.valueOf(8L).equals(userDTO.getShopId())
|
||||
&& userDTO.getShopIds().equals(List.of(8L))
|
||||
&& "普通".equals(userDTO.getLevel())
|
||||
&& Long.valueOf(0L).equals(userDTO.getVipId())
|
||||
));
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveScheduleShouldResolveShopScopeBeforeSaving() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
|
||||
+197
@@ -0,0 +1,197 @@
|
||||
package com.xiaowang.fingertipdesigner.core.modules.planning.service.impl;
|
||||
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.ArtistScheduleMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.artist.mapper.NailArtistInfoMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.entity.OrderItemDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderItemMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.mapper.OrderMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.order.service.OrderService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.dto.PlanningAppointmentCreateDTO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.entity.AppointmentReservationDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.mapper.AppointmentReservationMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.planning.service.AppointmentCapacityService;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.product.entity.ProductDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.product.mapper.ProductMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.security.support.AdminScopeHelper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.shop.entity.ShopDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.shop.mapper.ShopMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.user.entity.UserDO;
|
||||
import com.xiaowang.fingertipdesigner.core.modules.user.mapper.UserMapper;
|
||||
import com.xiaowang.fingertipdesigner.core.support.id.TimeOrderedSnowflakeIdGenerator;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
class PlanningServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private AdminScopeHelper adminScopeHelper;
|
||||
|
||||
@Mock
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Mock
|
||||
private NailArtistInfoMapper nailArtistInfoMapper;
|
||||
|
||||
@Mock
|
||||
private ArtistScheduleMapper artistScheduleMapper;
|
||||
|
||||
@Mock
|
||||
private AppointmentReservationMapper appointmentReservationMapper;
|
||||
|
||||
@Mock
|
||||
private OrderMapper orderMapper;
|
||||
|
||||
@Mock
|
||||
private OrderItemMapper orderItemMapper;
|
||||
|
||||
@Mock
|
||||
private ProductMapper productMapper;
|
||||
|
||||
@Mock
|
||||
private ShopMapper shopMapper;
|
||||
|
||||
@Mock
|
||||
private AppointmentCapacityService appointmentCapacityService;
|
||||
|
||||
@Mock
|
||||
private OrderService orderService;
|
||||
|
||||
@Mock
|
||||
private TimeOrderedSnowflakeIdGenerator snowflakeIdGenerator;
|
||||
|
||||
private PlanningServiceImpl planningService;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
planningService = new PlanningServiceImpl(
|
||||
adminScopeHelper,
|
||||
userMapper,
|
||||
nailArtistInfoMapper,
|
||||
artistScheduleMapper,
|
||||
appointmentReservationMapper,
|
||||
orderMapper,
|
||||
orderItemMapper,
|
||||
productMapper,
|
||||
shopMapper,
|
||||
appointmentCapacityService,
|
||||
orderService,
|
||||
snowflakeIdGenerator
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
void createAppointmentShouldHideManualProductFromFront() {
|
||||
UserDO manager = user(2, 8L);
|
||||
UserDO artist = user(3, 8L);
|
||||
artist.setId(20L);
|
||||
UserDO customer = user(0, 8L);
|
||||
customer.setId(30L);
|
||||
ShopDO shop = new ShopDO();
|
||||
shop.setBusinessHours("10:00-22:00");
|
||||
PlanningAppointmentCreateDTO dto = new PlanningAppointmentCreateDTO();
|
||||
dto.setCustomerUserId(30L);
|
||||
dto.setArtistId(20L);
|
||||
dto.setAppointmentDate("2026-06-26");
|
||||
dto.setAppointmentTime("13:00");
|
||||
dto.setDurationMinutes(90);
|
||||
dto.setManualProductTitle(" 日落贝壳 ");
|
||||
dto.setManualProductPrice(new BigDecimal("168.00"));
|
||||
dto.setClientRequestId("manual-product-test");
|
||||
|
||||
when(adminScopeHelper.resolveShopScope(manager, null)).thenReturn(8L);
|
||||
when(productMapper.insert(any(ProductDO.class))).thenAnswer(invocation -> {
|
||||
ProductDO product = invocation.getArgument(0);
|
||||
product.setId(100L);
|
||||
return 1;
|
||||
});
|
||||
when(userMapper.selectById(20L)).thenReturn(artist);
|
||||
when(userMapper.selectById(30L)).thenReturn(customer);
|
||||
when(shopMapper.selectById(8L)).thenReturn(shop);
|
||||
when(snowflakeIdGenerator.nextIdString()).thenReturn("202606260001");
|
||||
when(orderMapper.insert(any(OrderDO.class))).thenAnswer(invocation -> {
|
||||
OrderDO order = invocation.getArgument(0);
|
||||
order.setId(200L);
|
||||
return 1;
|
||||
});
|
||||
when(orderItemMapper.insert(any(OrderItemDO.class))).thenAnswer(invocation -> {
|
||||
OrderItemDO item = invocation.getArgument(0);
|
||||
item.setId(300L);
|
||||
return 1;
|
||||
});
|
||||
when(orderItemMapper.selectById(300L)).thenAnswer(invocation -> {
|
||||
OrderItemDO item = new OrderItemDO();
|
||||
item.setId(300L);
|
||||
item.setOrderId(200L);
|
||||
item.setProductId(100L);
|
||||
item.setArtistId(20L);
|
||||
item.setQuantity(1);
|
||||
item.setAppointmentTime(LocalDateTime.of(2026, 6, 26, 13, 0));
|
||||
item.setIsDelete(0);
|
||||
return item;
|
||||
});
|
||||
when(orderMapper.selectById(200L)).thenAnswer(invocation -> {
|
||||
OrderDO order = new OrderDO();
|
||||
order.setId(200L);
|
||||
order.setUserId(30L);
|
||||
order.setShopId(8L);
|
||||
order.setStatus(1);
|
||||
order.setIsDelete(0);
|
||||
return order;
|
||||
});
|
||||
when(productMapper.selectById(100L)).thenAnswer(invocation -> {
|
||||
ProductDO product = new ProductDO();
|
||||
product.setId(100L);
|
||||
product.setShopId(8L);
|
||||
product.setTitle("日落贝壳");
|
||||
product.setPrice(new BigDecimal("168.00"));
|
||||
product.setApproximateDuration("90分钟");
|
||||
product.setFrontVisible(0);
|
||||
product.setSourceType("MANAGER_APPOINTMENT");
|
||||
product.setIsDelete(0);
|
||||
return product;
|
||||
});
|
||||
AppointmentReservationDO reservation = new AppointmentReservationDO();
|
||||
reservation.setOrderItemId(300L);
|
||||
reservation.setArtistId(20L);
|
||||
reservation.setProductTitle("日落贝壳");
|
||||
reservation.setAppointmentStartTime(LocalDateTime.of(2026, 6, 26, 13, 0));
|
||||
reservation.setAppointmentEndTime(LocalDateTime.of(2026, 6, 26, 14, 30));
|
||||
when(appointmentReservationMapper.selectOne(any())).thenReturn(reservation);
|
||||
when(userMapper.selectBatchIds(any())).thenReturn(List.of(customer));
|
||||
|
||||
planningService.createAppointment(manager, dto);
|
||||
|
||||
ArgumentCaptor<ProductDO> captor = ArgumentCaptor.forClass(ProductDO.class);
|
||||
org.mockito.Mockito.verify(productMapper).insert(captor.capture());
|
||||
ProductDO product = captor.getValue();
|
||||
assertThat(product.getTitle()).isEqualTo("日落贝壳");
|
||||
assertThat(product.getFrontVisible()).isZero();
|
||||
assertThat(product.getSourceType()).isEqualTo("MANAGER_APPOINTMENT");
|
||||
assertThat(product.getImageFileIds()).isNull();
|
||||
}
|
||||
|
||||
private UserDO user(Integer type, Long shopId) {
|
||||
UserDO user = new UserDO();
|
||||
user.setId(10L + type);
|
||||
user.setType(type);
|
||||
user.setShopId(shopId);
|
||||
user.setIsDelete(0);
|
||||
user.setNickname("测试用户");
|
||||
user.setPhone("13800138000");
|
||||
return user;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.xiaowang.fingertipdesigner.core.utils;
|
||||
|
||||
import com.xiaowang.fingertipdesigner.core.config.JwtProperties;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class JwtUtilTest {
|
||||
|
||||
@Test
|
||||
void resolveAccessTokenExpirationSecondsShouldUseRememberMeSeconds() {
|
||||
JwtProperties properties = new JwtProperties();
|
||||
properties.setAccessTokenExpirationSeconds(120L);
|
||||
properties.setRememberMeAccessTokenExpirationSeconds(3600L);
|
||||
JwtUtil jwtUtil = new JwtUtil(properties);
|
||||
|
||||
assertThat(jwtUtil.resolveAccessTokenExpirationSeconds(false)).isEqualTo(120L);
|
||||
assertThat(jwtUtil.resolveAccessTokenExpirationSeconds(true)).isEqualTo(3600L);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,9 @@ function normalizeBrandValue(value: string | undefined, fallbackValue: string):
|
||||
}
|
||||
|
||||
export const BRAND_CONFIG = {
|
||||
appName: normalizeBrandValue(import.meta.env.VITE_APP_NAME, '指尖设计师'),
|
||||
appNameEn: normalizeBrandValue(import.meta.env.VITE_APP_NAME_EN, 'Fingertip Designer'),
|
||||
appTitle: normalizeBrandValue(import.meta.env.VITE_APP_TITLE, 'Fingertip Designer 指尖设计师'),
|
||||
adminAppName: normalizeBrandValue(import.meta.env.VITE_ADMIN_APP_NAME, '指尖设计师管理台'),
|
||||
appName: normalizeBrandValue(import.meta.env.VITE_APP_NAME, '甲屿设计师'),
|
||||
appNameEn: normalizeBrandValue(import.meta.env.VITE_APP_NAME_EN, 'Jiayu Designer'),
|
||||
appTitle: normalizeBrandValue(import.meta.env.VITE_APP_TITLE, '甲屿设计师'),
|
||||
adminAppName: normalizeBrandValue(import.meta.env.VITE_ADMIN_APP_NAME, '甲屿设计师管理台'),
|
||||
appShortName: normalizeBrandValue(import.meta.env.VITE_APP_SHORT_NAME, 'YN')
|
||||
}
|
||||
|
||||
@@ -157,9 +157,9 @@ const API_DOMAIN = ensureHttps(
|
||||
ENV_VERSION
|
||||
)
|
||||
const BRAND_CONFIG = {
|
||||
appName: String(localOverride.appName || '指尖设计师'),
|
||||
appNameEn: String(localOverride.appNameEn || 'Fingertip Designer'),
|
||||
appTitle: String(localOverride.appTitle || 'Fingertip Designer 指尖设计师')
|
||||
appName: String(localOverride.appName || '甲屿设计师'),
|
||||
appNameEn: String(localOverride.appNameEn || 'Jiayu Designer'),
|
||||
appTitle: String(localOverride.appTitle || '甲屿设计师')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module.exports = {
|
||||
developTarget: 'local',
|
||||
appName: '指尖设计师',
|
||||
appNameEn: 'Fingertip Designer',
|
||||
appTitle: 'Fingertip Designer 指尖设计师',
|
||||
appName: '甲屿设计师',
|
||||
appNameEn: 'Jiayu Designer',
|
||||
appTitle: '甲屿设计师',
|
||||
requestTimeout: 10000,
|
||||
enableRequestSigning: true,
|
||||
domains: {
|
||||
|
||||
@@ -4,10 +4,7 @@ module.exports = {
|
||||
list(params) {
|
||||
return request({
|
||||
url: '/manager/customers',
|
||||
params: {
|
||||
hasOrder: true,
|
||||
...params
|
||||
}
|
||||
params
|
||||
})
|
||||
},
|
||||
|
||||
@@ -15,5 +12,13 @@ module.exports = {
|
||||
return request({
|
||||
url: `/manager/customers/${id}`
|
||||
})
|
||||
},
|
||||
|
||||
create(data) {
|
||||
return request({
|
||||
url: '/manager/customers',
|
||||
method: 'POST',
|
||||
data
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
"pages/about/index"
|
||||
],
|
||||
"window": {
|
||||
"navigationBarTitleText": "指尖管理师",
|
||||
"navigationBarTitleText": "甲屿店务",
|
||||
"navigationBarBackgroundColor": "#F8F5EF",
|
||||
"navigationBarTextStyle": "black",
|
||||
"backgroundColor": "#F8F5EF",
|
||||
|
||||
@@ -193,6 +193,13 @@ button::after {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.field-label.required::after,
|
||||
.required-label::after {
|
||||
content: " *";
|
||||
color: #c56f36;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.field input,
|
||||
.field textarea,
|
||||
.field-value {
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id: '',
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: ''
|
||||
timeText: '',
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -19,8 +19,12 @@ Page({
|
||||
const appointment = await planningApi.appointment(this.data.id)
|
||||
this.applyAppointment(appointment)
|
||||
} catch (error) {
|
||||
const demo = mock.buildCalendar(new Date()).appointments[0]
|
||||
this.applyAppointment(demo)
|
||||
this.setData({
|
||||
appointment: {},
|
||||
avatarText: '',
|
||||
timeText: '',
|
||||
loadError: error.message || '预约详情加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -28,7 +32,8 @@ Page({
|
||||
this.setData({
|
||||
appointment,
|
||||
avatarText: String(appointment.customerName || '客').slice(0, 1),
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`
|
||||
timeText: `${(appointment.startTime || '').slice(0, 16)} - ${(appointment.endTime || '').slice(11, 16)}`,
|
||||
loadError: ''
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card detail-card">
|
||||
<view wx:if="{{loadError}}" class="empty card detail-error">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadDetail">重试</button>
|
||||
</view>
|
||||
|
||||
<view wx:else class="card detail-card">
|
||||
<view class="detail-head">
|
||||
<view class="detail-person">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
@@ -33,12 +38,12 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view wx:if="{{!loadError}}" class="section">
|
||||
<view class="section-title">备注</view>
|
||||
<view class="card note-card">{{appointment.remark || '暂无备注'}}</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom action-row">
|
||||
<view wx:if="{{!loadError}}" class="fixed-bottom action-row">
|
||||
<button class="secondary-btn" bindtap="confirm">确认</button>
|
||||
<button class="primary-btn" bindtap="complete">完成</button>
|
||||
<button class="danger-btn" bindtap="cancel">取消</button>
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.detail-error {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.detail-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -86,6 +86,7 @@ Page({
|
||||
selectedArtist: {},
|
||||
productModalVisible: false,
|
||||
productKeyword: '',
|
||||
productError: '',
|
||||
conflictTip: '',
|
||||
conflictLevel: 'free',
|
||||
canCreateAppointment: true,
|
||||
@@ -96,6 +97,8 @@ Page({
|
||||
const creatable = canCreateAppointment()
|
||||
this.setData({
|
||||
canCreateAppointment: creatable,
|
||||
'form.customerName': options.customerName ? decodeURIComponent(options.customerName) : '',
|
||||
'form.phone': options.phone ? decodeURIComponent(options.phone) : '',
|
||||
'form.appointmentDate': options.date || dateUtil.formatDate(new Date()),
|
||||
'form.artistId': options.artistId || ''
|
||||
})
|
||||
@@ -107,17 +110,16 @@ Page({
|
||||
},
|
||||
|
||||
async loadOptions() {
|
||||
const fallbackProducts = [
|
||||
{ id: 1, title: '纯色美甲', approximateDuration: '90分钟' },
|
||||
{ id: 2, title: '猫眼延长', approximateDuration: '120分钟' },
|
||||
{ id: 3, title: '手部护理', approximateDuration: '60分钟' }
|
||||
]
|
||||
try {
|
||||
const productsData = await productsApi.list({ page: 1, size: 100 })
|
||||
const products = productsData.list || productsData || fallbackProducts
|
||||
this.setData({ products })
|
||||
const products = productsData.list || productsData || []
|
||||
this.setData({ products, productError: '' })
|
||||
} catch (error) {
|
||||
this.setData({ products: fallbackProducts })
|
||||
this.setData({
|
||||
products: [],
|
||||
filteredProducts: [],
|
||||
productError: error.message || '作品列表加载失败'
|
||||
})
|
||||
}
|
||||
await this.loadArtists()
|
||||
this.refreshProductCards()
|
||||
@@ -125,14 +127,24 @@ Page({
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.form.appointmentDate,
|
||||
endDate: this.data.form.appointmentDate
|
||||
})
|
||||
const artists = getCalendarArtists(calendar)
|
||||
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
|
||||
this.setData({ artists, selectedArtist })
|
||||
this.refreshProductCards()
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.form.appointmentDate,
|
||||
endDate: this.data.form.appointmentDate
|
||||
})
|
||||
const artists = getCalendarArtists(calendar)
|
||||
const selectedArtist = this.data.form.artistId ? findArtist(artists, this.data.form.artistId) : {}
|
||||
this.setData({ artists, selectedArtist })
|
||||
this.refreshProductCards()
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
artists: [],
|
||||
selectedArtist: {},
|
||||
'form.artistId': '',
|
||||
conflictTip: error.message || '美甲师列表加载失败',
|
||||
conflictLevel: 'danger'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
onInput(event) {
|
||||
@@ -198,7 +210,7 @@ Page({
|
||||
const title = String(this.data.form.manualProductTitle || '').trim()
|
||||
const price = Number(this.data.form.manualProductPrice)
|
||||
if (!title || Number.isNaN(price) || price < 0) {
|
||||
wx.showToast({ title: '请填写手动项目名称和价格', icon: 'none' })
|
||||
wx.showToast({ title: '请填写手动预约作品名称和价格', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({
|
||||
@@ -265,9 +277,9 @@ Page({
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'free' })
|
||||
return { ok: true, tip }
|
||||
} catch (error) {
|
||||
const tip = '暂未获取到排班,请保存时以系统校验为准'
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'warn' })
|
||||
return { ok: true, tip }
|
||||
const tip = error.message || '排班校验失败,请稍后重试'
|
||||
this.setData({ conflictTip: tip, conflictLevel: 'danger' })
|
||||
return { ok: false, tip }
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -1,39 +1,39 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card form-card">
|
||||
<view class="field">
|
||||
<text class="field-label">客户姓名</text>
|
||||
<text class="field-label required">客户姓名</text>
|
||||
<input value="{{form.customerName}}" data-field="customerName" bindinput="onInput" placeholder="请输入客户姓名" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">手机号</text>
|
||||
<text class="field-label required">手机号</text>
|
||||
<input value="{{form.phone}}" data-field="phone" bindinput="onInput" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">预约日期</text>
|
||||
<text class="field-label required">预约日期</text>
|
||||
<picker mode="date" value="{{form.appointmentDate}}" bindchange="onDateChange">
|
||||
<view class="field-value">{{form.appointmentDate}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">预约时间</text>
|
||||
<text class="field-label required">预约时间</text>
|
||||
<picker mode="time" value="{{form.appointmentTime}}" start="10:00" end="22:00" bindchange="onTimeChange">
|
||||
<view class="field-value">{{form.appointmentTime}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">项目内容</text>
|
||||
<text class="field-label required">预约作品</text>
|
||||
<view class="field-value product-value" bindtap="openProductModal">
|
||||
<text>{{selectedProduct.title || form.manualProductTitle || '请选择项目'}}</text>
|
||||
<text>{{selectedProduct.title || form.manualProductTitle || '请选择预约作品'}}</text>
|
||||
<text wx:if="{{form.manualProductTitle && !form.productId}}" class="manual-badge">手动</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">预计时长</text>
|
||||
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="默认读取项目时长" />
|
||||
<input value="{{form.durationMinutes}}" data-field="durationMinutes" bindinput="onInput" type="number" placeholder="默认读取作品时长" />
|
||||
<text class="unit">分钟</text>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">指定员工</text>
|
||||
<text class="field-label required">指定员工</text>
|
||||
<picker range="{{artists}}" range-key="name" bindchange="onArtistChange">
|
||||
<view class="field-value">{{selectedArtist.name || '请选择美甲师'}}</view>
|
||||
</picker>
|
||||
@@ -58,12 +58,13 @@
|
||||
<view class="product-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<view>
|
||||
<text class="modal-title">选择项目内容</text>
|
||||
<text class="modal-title">选择预约作品</text>
|
||||
</view>
|
||||
<view class="modal-close" bindtap="closeProductModal">×</view>
|
||||
</view>
|
||||
<input class="product-search" value="{{productKeyword}}" bindinput="onProductSearch" placeholder="搜索作品、标签、美甲师" />
|
||||
<scroll-view class="product-list" scroll-y>
|
||||
<view wx:if="{{productError}}" class="product-empty">{{productError}}</view>
|
||||
<view wx:for="{{filteredProducts}}" wx:key="id" class="product-option {{form.productId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectProduct">
|
||||
<image wx:if="{{item.coverImage}}" class="product-cover" src="{{item.coverImage}}" mode="aspectFill"></image>
|
||||
<view wx:else class="product-cover placeholder">图</view>
|
||||
@@ -78,15 +79,15 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
|
||||
<view wx:if="{{!productError && filteredProducts.length === 0}}" class="product-empty">暂无匹配作品</view>
|
||||
</scroll-view>
|
||||
<view class="manual-panel">
|
||||
<text class="manual-title">手动新增项目</text>
|
||||
<text class="manual-title required-label">手动新增预约作品</text>
|
||||
<view class="manual-grid">
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="项目名称" />
|
||||
<input value="{{form.manualProductTitle}}" data-field="manualProductTitle" bindinput="onInput" placeholder="作品名称" />
|
||||
<input value="{{form.manualProductPrice}}" data-field="manualProductPrice" bindinput="onInput" type="digit" placeholder="价格" />
|
||||
</view>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动项目</button>
|
||||
<button class="secondary-btn manual-btn" bindtap="useManualProduct">使用手动预约作品</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -114,18 +114,37 @@
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 56rpx;
|
||||
min-width: 56rpx;
|
||||
height: 56rpx;
|
||||
width: 48rpx;
|
||||
min-width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
background: #f2e7da;
|
||||
color: #61554c;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
border: 1rpx solid #e4d8ca;
|
||||
background: #fffaf4;
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.modal-close::before,
|
||||
.modal-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #61554c;
|
||||
}
|
||||
|
||||
.modal-close::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.modal-close::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.product-search {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
const planningApi = require('../../api/planning')
|
||||
const mock = require('../../utils/mock')
|
||||
const dateUtil = require('../../utils/date')
|
||||
|
||||
Page({
|
||||
@@ -9,26 +8,49 @@ Page({
|
||||
selectedArtistId: '',
|
||||
date: dateUtil.formatDate(new Date()),
|
||||
time: '13:00',
|
||||
loadError: '',
|
||||
loading: false
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.setData({
|
||||
id: options.id || '',
|
||||
artists: mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
availableStatus: index === 1 ? 'busy' : index === 2 ? 'full' : 'free',
|
||||
availableText: index === 1 ? '有冲突' : index === 2 ? '已满' : '可接'
|
||||
}))
|
||||
id: options.id || ''
|
||||
})
|
||||
this.loadArtists()
|
||||
},
|
||||
|
||||
async loadArtists() {
|
||||
try {
|
||||
const calendar = await planningApi.calendar({
|
||||
startDate: this.data.date,
|
||||
endDate: this.data.date
|
||||
})
|
||||
const artists = Array.isArray(calendar.artists) ? calendar.artists : []
|
||||
this.setData({
|
||||
artists: artists.map(item => ({
|
||||
...item,
|
||||
availableStatus: 'free',
|
||||
availableText: '可选择'
|
||||
})),
|
||||
selectedArtistId: '',
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
artists: [],
|
||||
selectedArtistId: '',
|
||||
loadError: error.message || '美甲师列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
selectArtist(event) {
|
||||
this.setData({ selectedArtistId: event.currentTarget.dataset.id })
|
||||
},
|
||||
|
||||
onDateChange(event) {
|
||||
async onDateChange(event) {
|
||||
this.setData({ date: event.detail.value })
|
||||
await this.loadArtists()
|
||||
},
|
||||
|
||||
onTimeChange(event) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<view class="page no-tab">
|
||||
<view class="list">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadArtists">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{artists.length === 0}}" class="empty card">暂无可选美甲师</view>
|
||||
<view wx:for="{{artists}}" wx:key="id" class="card transfer-card {{selectedArtistId == item.id ? 'active' : ''}}" data-id="{{item.id}}" bindtap="selectArtist">
|
||||
<view class="row between">
|
||||
<view class="row">
|
||||
@@ -14,22 +19,22 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="card form-card section">
|
||||
<view wx:if="{{!loadError}}" class="card form-card section">
|
||||
<view class="field">
|
||||
<text class="field-label">新日期</text>
|
||||
<text class="field-label required">新日期</text>
|
||||
<picker mode="date" value="{{date}}" bindchange="onDateChange">
|
||||
<view class="field-value">{{date}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
<view class="field">
|
||||
<text class="field-label">新时间</text>
|
||||
<text class="field-label required">新时间</text>
|
||||
<picker mode="time" value="{{time}}" start="10:00" end="22:00" bindchange="onTimeChange">
|
||||
<view class="field-value">{{time}}</view>
|
||||
</picker>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="fixed-bottom">
|
||||
<view wx:if="{{!loadError}}" class="fixed-bottom">
|
||||
<button class="primary-btn" loading="{{loading}}" bindtap="submit">确认改派</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
padding: 24rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.transfer-card.active {
|
||||
outline: 3rpx solid #8fb89a;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
const customersApi = require('../../api/customers')
|
||||
|
||||
function canCreateAppointment() {
|
||||
const app = getApp()
|
||||
const userInfo = app.globalData.userInfo || {}
|
||||
@@ -9,13 +11,10 @@ Page({
|
||||
id: '',
|
||||
canCreateAppointment: true,
|
||||
avatarText: '客',
|
||||
customer: { name: '王女士', phone: '138****1201' },
|
||||
stats: { orderCount: 12, amount: 2860, lastTime: '06-01' },
|
||||
orders: [
|
||||
{ id: 1, date: '2026-06-01', project: '纯色美甲', amount: 168, artist: '小王' },
|
||||
{ id: 2, date: '2026-05-18', project: '猫眼延长', amount: 268, artist: '小李' },
|
||||
{ id: 3, date: '2026-05-02', project: '手部护理', amount: 98, artist: '小张' }
|
||||
]
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
@@ -23,6 +22,48 @@ Page({
|
||||
id: options.id || '',
|
||||
canCreateAppointment: canCreateAppointment()
|
||||
})
|
||||
this.loadCustomer()
|
||||
},
|
||||
|
||||
async loadCustomer() {
|
||||
if (!this.data.id) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: '缺少客户 ID'
|
||||
})
|
||||
return
|
||||
}
|
||||
try {
|
||||
const detail = await customersApi.detail(this.data.id)
|
||||
if (!detail) {
|
||||
throw new Error('客户详情不存在')
|
||||
}
|
||||
const customer = {
|
||||
id: detail.id,
|
||||
name: detail.nickname || detail.name || detail.account || '客户',
|
||||
phone: detail.contactPhone || detail.phone || '未填写'
|
||||
}
|
||||
this.setData({
|
||||
customer,
|
||||
avatarText: String(customer.name || '客').slice(-1),
|
||||
stats: {
|
||||
orderCount: detail.orderCount || detail.totalOrderCount || 0,
|
||||
amount: detail.totalAmount || detail.consumeAmount || 0,
|
||||
lastTime: detail.lastOrderTime || detail.lastConsumeTime || '-'
|
||||
},
|
||||
orders: Array.isArray(detail.orders) ? detail.orders : [],
|
||||
loadError: ''
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
customer: {},
|
||||
stats: { orderCount: 0, amount: 0, lastTime: '-' },
|
||||
orders: [],
|
||||
loadError: error.message || '客户详情加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
createAppointment() {
|
||||
@@ -30,7 +71,10 @@ Page({
|
||||
wx.showToast({ title: '美甲师账号只能查看预约', icon: 'none' })
|
||||
return
|
||||
}
|
||||
wx.navigateTo({ url: '/pages/appointment-form/index' })
|
||||
const customer = this.data.customer || {}
|
||||
wx.navigateTo({
|
||||
url: `/pages/appointment-form/index?customerName=${encodeURIComponent(customer.name || '')}&phone=${encodeURIComponent(customer.phone || '')}`
|
||||
})
|
||||
},
|
||||
|
||||
back() {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<view class="page no-tab">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadCustomer">重试</button>
|
||||
</view>
|
||||
|
||||
<block wx:else>
|
||||
<view class="card customer-head">
|
||||
<view class="customer-identity">
|
||||
<view class="avatar">{{avatarText}}</view>
|
||||
@@ -28,13 +34,15 @@
|
||||
<view class="section">
|
||||
<view class="section-title">历史订单</view>
|
||||
<view class="list">
|
||||
<view wx:if="{{orders.length === 0}}" class="empty card">暂无历史订单</view>
|
||||
<view wx:for="{{orders}}" wx:key="id" class="card list-card order-card">
|
||||
<view>
|
||||
<text class="order-title">{{item.project}}</text>
|
||||
<text class="meta">{{item.date}} · {{item.artist}}</text>
|
||||
<text class="order-title">{{item.project || item.productTitle || '预约作品'}}</text>
|
||||
<text class="meta">{{item.date || item.appointmentDate || '-'}} · {{item.artist || item.artistName || '-'}}</text>
|
||||
</view>
|
||||
<text class="amount">¥{{item.amount}}</text>
|
||||
<text class="amount">¥{{item.amount || item.payAmount || 0}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
</view>
|
||||
|
||||
@@ -87,3 +87,10 @@
|
||||
color: #6f8f83;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,14 @@ const customersApi = require('../../api/customers')
|
||||
Page({
|
||||
data: {
|
||||
keyword: '',
|
||||
customers: []
|
||||
customers: [],
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
@@ -17,15 +24,11 @@ Page({
|
||||
},
|
||||
|
||||
async loadCustomers() {
|
||||
const fallback = [
|
||||
{ id: 1, name: '王女士', phone: '138****1201', lastTime: '2026-06-01' },
|
||||
{ id: 2, name: '陈女士', phone: '136****8842', lastTime: '2026-05-29' },
|
||||
{ id: 3, name: '林女士', phone: '159****6671', lastTime: '2026-05-27' }
|
||||
]
|
||||
try {
|
||||
const data = await customersApi.list({ keyword: this.data.keyword, page: 1, size: 30 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
loadError: '',
|
||||
customers: list.map(item => ({
|
||||
id: item.id,
|
||||
name: item.nickname || item.name || item.account || '客户',
|
||||
@@ -34,11 +37,65 @@ Page({
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ customers: fallback })
|
||||
this.setData({
|
||||
customers: [],
|
||||
loadError: error.message || '客户列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
openDetail(event) {
|
||||
wx.navigateTo({ url: `/pages/customer-detail/index?id=${event.currentTarget.dataset.id}` })
|
||||
},
|
||||
|
||||
addCustomer() {
|
||||
this.setData({ createModalVisible: true })
|
||||
},
|
||||
|
||||
closeCreateModal() {
|
||||
if (this.data.creating) {
|
||||
return
|
||||
}
|
||||
this.setData({ createModalVisible: false })
|
||||
},
|
||||
|
||||
stopTap() {
|
||||
},
|
||||
|
||||
onCreateInput(event) {
|
||||
this.setData({
|
||||
[`createForm.${event.currentTarget.dataset.field}`]: event.detail.value
|
||||
})
|
||||
},
|
||||
|
||||
resetCreateForm() {
|
||||
this.setData({
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: ''
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
async submitCustomer() {
|
||||
const form = this.data.createForm
|
||||
const nickname = String(form.nickname || '').trim()
|
||||
const phone = String(form.phone || '').trim()
|
||||
if (!nickname || !phone) {
|
||||
wx.showToast({ title: '请填写客户姓名和手机号', icon: 'none' })
|
||||
return
|
||||
}
|
||||
this.setData({ creating: true })
|
||||
try {
|
||||
await customersApi.create({ nickname, phone })
|
||||
wx.showToast({ title: '客户已新增', icon: 'success' })
|
||||
this.resetCreateForm()
|
||||
this.setData({ createModalVisible: false })
|
||||
await this.loadCustomers()
|
||||
} catch (error) {
|
||||
wx.showToast({ title: error.message || '新增失败', icon: 'none' })
|
||||
} finally {
|
||||
this.setData({ creating: false })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -1,9 +1,17 @@
|
||||
<view class="page">
|
||||
<view class="search-card card">
|
||||
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
|
||||
<view class="customer-toolbar">
|
||||
<view class="search-card card">
|
||||
<input value="{{keyword}}" bindinput="onSearchInput" placeholder="搜索客户姓名或手机号" />
|
||||
</view>
|
||||
<button class="compact-btn" bindtap="addCustomer">新增</button>
|
||||
</view>
|
||||
|
||||
<view class="list section">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadCustomers">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{customers.length === 0}}" class="empty card">暂无客户</view>
|
||||
<view wx:for="{{customers}}" wx:key="id" class="card list-card customer-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view>
|
||||
<text class="name">{{item.name}}</text>
|
||||
@@ -13,4 +21,24 @@
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{createModalVisible}}" class="modal-mask" bindtap="closeCreateModal">
|
||||
<view class="customer-modal" catchtap="stopTap">
|
||||
<view class="modal-head">
|
||||
<text class="modal-title">新增客户</text>
|
||||
<view class="modal-close" bindtap="closeCreateModal">×</view>
|
||||
</view>
|
||||
<view class="form-grid">
|
||||
<view class="modal-field">
|
||||
<text class="required-label">客户姓名</text>
|
||||
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入客户姓名" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
|
||||
</view>
|
||||
</view>
|
||||
<button class="primary-btn modal-submit" loading="{{creating}}" bindtap="submitCustomer">保存客户</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
.customer-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
}
|
||||
|
||||
.search-card {
|
||||
flex: 1;
|
||||
padding: 0 24rpx;
|
||||
height: 84rpx;
|
||||
display: flex;
|
||||
@@ -37,3 +44,106 @@
|
||||
color: #b0a79e;
|
||||
font-size: 48rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 80;
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
justify-content: center;
|
||||
background: rgba(18, 15, 12, 0.48);
|
||||
}
|
||||
|
||||
.customer-modal {
|
||||
width: 100%;
|
||||
padding: 28rpx 28rpx calc(28rpx + env(safe-area-inset-bottom));
|
||||
border-radius: 28rpx 28rpx 0 0;
|
||||
background: #fffaf4;
|
||||
box-shadow: 0 -18rpx 40rpx rgba(41, 31, 23, 0.16);
|
||||
}
|
||||
|
||||
.modal-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 20rpx;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #27211d;
|
||||
font-size: 34rpx;
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 48rpx;
|
||||
min-width: 48rpx;
|
||||
height: 48rpx;
|
||||
border: 1rpx solid #e4d8ca;
|
||||
border-radius: 50%;
|
||||
background: #fffaf4;
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.modal-close::before,
|
||||
.modal-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #61554c;
|
||||
}
|
||||
|
||||
.modal-close::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.modal-close::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 16rpx;
|
||||
}
|
||||
|
||||
.modal-field {
|
||||
padding: 16rpx 18rpx;
|
||||
border-radius: 18rpx;
|
||||
background: #f7efe7;
|
||||
}
|
||||
|
||||
.modal-field text {
|
||||
display: block;
|
||||
margin-bottom: 8rpx;
|
||||
color: #6c5f54;
|
||||
font-size: 24rpx;
|
||||
font-weight: 800;
|
||||
}
|
||||
|
||||
.modal-field input {
|
||||
height: 58rpx;
|
||||
color: #2c2722;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.modal-submit {
|
||||
margin-top: 22rpx;
|
||||
}
|
||||
|
||||
@@ -1,23 +1,43 @@
|
||||
const mock = require('../../utils/mock')
|
||||
const employeesApi = require('../../api/employees')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
|
||||
|
||||
Page({
|
||||
data: {
|
||||
id: '',
|
||||
employee: {}
|
||||
employee: {},
|
||||
loadError: ''
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
const id = options.id || mock.artists[0].id
|
||||
const artist = mock.artists.find(item => String(item.id) === String(id)) || mock.artists[0]
|
||||
this.setData({
|
||||
id,
|
||||
employee: {
|
||||
...artist,
|
||||
monthOrders: 32,
|
||||
monthAmount: 5800,
|
||||
avgAmount: 181
|
||||
}
|
||||
})
|
||||
this.setData({ id: options.id || '' })
|
||||
this.loadDetail()
|
||||
},
|
||||
|
||||
async loadDetail() {
|
||||
try {
|
||||
const data = await employeesApi.detail(this.data.id)
|
||||
const name = data.nickname || data.name || data.artistName || '美甲师'
|
||||
const monthOrders = data.monthOrders || data.orderCount || 0
|
||||
const monthAmount = data.monthAmount || data.turnover || 0
|
||||
this.setData({
|
||||
loadError: '',
|
||||
employee: {
|
||||
...data,
|
||||
name,
|
||||
shortName: name.slice(-1),
|
||||
color: data.color || EMPLOYEE_COLORS[0],
|
||||
monthOrders,
|
||||
monthAmount,
|
||||
avgAmount: monthOrders > 0 ? Math.round(monthAmount / monthOrders) : 0
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({
|
||||
employee: {},
|
||||
loadError: error.message || '美甲师详情加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
go(event) {
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
<view class="page no-tab">
|
||||
<view class="card employee-head">
|
||||
<view wx:if="{{loadError}}" class="empty card detail-error">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadDetail">重试</button>
|
||||
</view>
|
||||
|
||||
<view wx:else class="card employee-head">
|
||||
<view class="avatar" style="background: {{employee.color}};">{{employee.shortName}}</view>
|
||||
<view>
|
||||
<text class="employee-name">{{employee.name}}</text>
|
||||
@@ -7,7 +12,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="stats">
|
||||
<view wx:if="{{!loadError}}" class="stats">
|
||||
<view class="card stat">
|
||||
<text class="stat-value">{{employee.monthOrders}}</text>
|
||||
<text class="stat-label">本月订单</text>
|
||||
@@ -22,7 +27,7 @@
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="section">
|
||||
<view wx:if="{{!loadError}}" class="section">
|
||||
<view class="menu-grid">
|
||||
<view class="card menu-card" data-url="/pages/schedule-setting/index" bindtap="go">排班设置</view>
|
||||
<view class="card menu-card" data-url="/pages/leave-management/index" bindtap="go">请假管理</view>
|
||||
|
||||
@@ -5,6 +5,17 @@
|
||||
padding: 28rpx;
|
||||
}
|
||||
|
||||
.detail-error {
|
||||
margin-top: 24rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -1,16 +1,19 @@
|
||||
const employeesApi = require('../../api/employees')
|
||||
const mock = require('../../utils/mock')
|
||||
|
||||
const EMPLOYEE_COLORS = ['#7AA9C2', '#8EB99B', '#BDA7D8', '#D7B17D', '#D98D8D']
|
||||
const DEFAULT_EMPLOYEE_PASSWORD = 'Fingertip@123'
|
||||
|
||||
Page({
|
||||
data: {
|
||||
employees: [],
|
||||
loadError: '',
|
||||
createModalVisible: false,
|
||||
creating: false,
|
||||
createForm: {
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: '888888',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: ''
|
||||
}
|
||||
},
|
||||
@@ -20,26 +23,25 @@ Page({
|
||||
},
|
||||
|
||||
async loadEmployees() {
|
||||
const fallback = mock.artists.map((item, index) => ({
|
||||
...item,
|
||||
monthOrders: 32 - index * 5,
|
||||
monthAmount: 5800 - index * 760
|
||||
}))
|
||||
try {
|
||||
const data = await employeesApi.list({ page: 1, size: 50 })
|
||||
const list = data.list || data || []
|
||||
this.setData({
|
||||
loadError: '',
|
||||
employees: list.map((item, index) => ({
|
||||
id: item.userId || item.id,
|
||||
name: item.nickname || item.name || item.artistName || `美甲师${index + 1}`,
|
||||
shortName: (item.nickname || item.name || '师').slice(-1),
|
||||
color: mock.artists[index % mock.artists.length].color,
|
||||
color: EMPLOYEE_COLORS[index % EMPLOYEE_COLORS.length],
|
||||
monthOrders: item.monthOrders || item.orderCount || 0,
|
||||
monthAmount: item.monthAmount || item.turnover || 0
|
||||
}))
|
||||
})
|
||||
} catch (error) {
|
||||
this.setData({ employees: fallback })
|
||||
this.setData({
|
||||
employees: [],
|
||||
loadError: error.message || '美甲师列表加载失败'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
@@ -79,7 +81,7 @@ Page({
|
||||
nickname: '',
|
||||
phone: '',
|
||||
account: '',
|
||||
password: '888888',
|
||||
password: DEFAULT_EMPLOYEE_PASSWORD,
|
||||
wechatId: ''
|
||||
}
|
||||
})
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
</view>
|
||||
|
||||
<view class="list">
|
||||
<view wx:if="{{loadError}}" class="empty card">
|
||||
<text>{{loadError}}</text>
|
||||
<button class="secondary-btn retry-btn" bindtap="loadEmployees">重试</button>
|
||||
</view>
|
||||
<view wx:elif="{{employees.length === 0}}" class="empty card">暂无美甲师</view>
|
||||
<view wx:for="{{employees}}" wx:key="id" class="card employee-card" data-id="{{item.id}}" bindtap="openDetail">
|
||||
<view class="employee-left">
|
||||
<view class="avatar" style="background: {{item.color}};">{{item.shortName}}</view>
|
||||
@@ -27,23 +32,23 @@
|
||||
</view>
|
||||
<view class="form-grid">
|
||||
<view class="modal-field">
|
||||
<text>姓名</text>
|
||||
<text class="required-label">姓名</text>
|
||||
<input value="{{createForm.nickname}}" data-field="nickname" bindinput="onCreateInput" placeholder="请输入姓名" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>手机号</text>
|
||||
<text class="required-label">手机号</text>
|
||||
<input value="{{createForm.phone}}" data-field="phone" bindinput="onCreateInput" type="number" placeholder="请输入手机号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>登录账号</text>
|
||||
<text class="required-label">登录账号</text>
|
||||
<input value="{{createForm.account}}" data-field="account" bindinput="onCreateInput" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>初始密码</text>
|
||||
<text class="required-label">初始密码</text>
|
||||
<input value="{{createForm.password}}" data-field="password" bindinput="onCreateInput" password placeholder="请输入密码" />
|
||||
</view>
|
||||
<view class="modal-field">
|
||||
<text>微信号</text>
|
||||
<text class="required-label">微信号</text>
|
||||
<input value="{{createForm.wechatId}}" data-field="wechatId" bindinput="onCreateInput" placeholder="请输入微信号" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -65,6 +65,13 @@
|
||||
border-radius: 999rpx;
|
||||
}
|
||||
|
||||
.retry-btn {
|
||||
width: 180rpx;
|
||||
min-width: 180rpx;
|
||||
max-width: 180rpx;
|
||||
margin: 24rpx auto 0;
|
||||
}
|
||||
|
||||
.modal-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
@@ -102,18 +109,37 @@
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
position: relative;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 56rpx;
|
||||
min-width: 56rpx;
|
||||
height: 56rpx;
|
||||
width: 48rpx;
|
||||
min-width: 48rpx;
|
||||
height: 48rpx;
|
||||
border-radius: 50%;
|
||||
background: #f2e7da;
|
||||
color: #61554c;
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
line-height: 1;
|
||||
border: 1rpx solid #e4d8ca;
|
||||
background: #fffaf4;
|
||||
color: transparent;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.modal-close::before,
|
||||
.modal-close::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: 22rpx;
|
||||
height: 3rpx;
|
||||
border-radius: 999rpx;
|
||||
background: #61554c;
|
||||
}
|
||||
|
||||
.modal-close::before {
|
||||
transform: rotate(45deg);
|
||||
}
|
||||
|
||||
.modal-close::after {
|
||||
transform: rotate(-45deg);
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
|
||||
@@ -4,11 +4,12 @@ const { BRAND_CONFIG } = require('../../utils/config')
|
||||
const PHONE_REGEX = /^1[3-9]\d{9}$/
|
||||
|
||||
function buildSession(data) {
|
||||
const userInfo = data.userInfo || data.user || {}
|
||||
return {
|
||||
...data,
|
||||
accessToken: data.accessToken || data.token,
|
||||
userInfo: data.userInfo || data.user || {},
|
||||
shopName: data.shopName || (data.shop && data.shop.shopName)
|
||||
userInfo,
|
||||
shopName: data.shopName || userInfo.shopName || (data.shop && data.shop.shopName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +42,22 @@ function buildShopOptionsFromSelection(selection) {
|
||||
const shops = selection && Array.isArray(selection.shops) ? selection.shops : []
|
||||
return shops.map(shop => ({
|
||||
id: shop.id,
|
||||
name: shop.shopName || shop.name || `店铺 ${shop.id}`
|
||||
name: shop.shopName || shop.name || `店铺 ${shop.id}`,
|
||||
description: selection && selection.message ? selection.message : ''
|
||||
}))
|
||||
}
|
||||
|
||||
function isShopSelectionRequiredError(error) {
|
||||
return !!(error && error.message && error.message.indexOf('请选择登录店铺') !== -1)
|
||||
const message = error && error.message ? error.message : ''
|
||||
return message.indexOf('选择店铺') !== -1 || message.indexOf('请选择店铺') !== -1 || message.indexOf('请选择登录店铺') !== -1
|
||||
}
|
||||
|
||||
function assertShopSession(session) {
|
||||
const userInfo = session.userInfo || {}
|
||||
if (!userInfo.shopId) {
|
||||
throw new Error('请选择店铺后再进入管理师端')
|
||||
}
|
||||
return session
|
||||
}
|
||||
|
||||
Page({
|
||||
@@ -63,6 +74,7 @@ Page({
|
||||
countdown: 0,
|
||||
countdownTimer: null,
|
||||
agreementAccepted: false,
|
||||
rememberMe: false,
|
||||
agreements: [],
|
||||
appName: BRAND_CONFIG.appName,
|
||||
shopSelectVisible: false,
|
||||
@@ -125,6 +137,12 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
toggleRememberMe() {
|
||||
this.setData({
|
||||
rememberMe: !this.data.rememberMe
|
||||
})
|
||||
},
|
||||
|
||||
buildAgreementPayload() {
|
||||
const agreementVersions = {}
|
||||
;(this.data.agreements || []).forEach(item => {
|
||||
@@ -162,15 +180,13 @@ Page({
|
||||
if (!shopOptions.length) {
|
||||
throw new Error('当前账号没有可用店铺,无法进入管理师端')
|
||||
}
|
||||
const app = getApp()
|
||||
app.setSession(session)
|
||||
if (shopOptions.length === 1) {
|
||||
return buildSession(await authApi.switchShop(shopOptions[0].id))
|
||||
return this.loginForShop(shopOptions[0].id)
|
||||
}
|
||||
this.setData({
|
||||
shopOptions,
|
||||
shopSelectVisible: true,
|
||||
shopSelectMode: 'switch'
|
||||
shopSelectMode: 'login'
|
||||
})
|
||||
return null
|
||||
},
|
||||
@@ -181,6 +197,7 @@ Page({
|
||||
return {
|
||||
phone: String(form.phone || '').trim(),
|
||||
verificationCode: String(form.code || '').trim(),
|
||||
rememberMe: !!this.data.rememberMe,
|
||||
...this.buildAgreementPayload(),
|
||||
...(shopId ? { shopId } : {})
|
||||
}
|
||||
@@ -188,6 +205,7 @@ Page({
|
||||
return {
|
||||
account: form.account,
|
||||
password: form.password,
|
||||
rememberMe: !!this.data.rememberMe,
|
||||
...(shopId ? { shopId } : {})
|
||||
}
|
||||
},
|
||||
@@ -199,6 +217,10 @@ Page({
|
||||
: authApi.login(data)
|
||||
},
|
||||
|
||||
async loginForShop(shopId) {
|
||||
return assertShopSession(buildSession(await this.requestLogin(shopId)))
|
||||
},
|
||||
|
||||
async loadLoginShopOptions() {
|
||||
const form = this.data.form
|
||||
const selection = this.data.loginMode === 'phone'
|
||||
@@ -228,6 +250,15 @@ Page({
|
||||
})
|
||||
},
|
||||
|
||||
async tryOpenLoginShopSelector() {
|
||||
try {
|
||||
await this.openLoginShopSelector()
|
||||
return true
|
||||
} catch (error) {
|
||||
return false
|
||||
}
|
||||
},
|
||||
|
||||
async selectLoginShop(event) {
|
||||
if (this.data.switchingShop) {
|
||||
return
|
||||
@@ -252,10 +283,7 @@ Page({
|
||||
},
|
||||
|
||||
async loginWithSelectedShop(shopId) {
|
||||
const session = await this.resolveLoginSession(await this.requestLogin(shopId))
|
||||
if (!session) {
|
||||
return
|
||||
}
|
||||
const session = await this.loginForShop(shopId)
|
||||
const app = getApp()
|
||||
app.setSession(session)
|
||||
this.closeShopSelector()
|
||||
@@ -296,7 +324,7 @@ Page({
|
||||
async submit() {
|
||||
const form = this.data.form
|
||||
if (this.data.loginMode === 'password' && (!form.account || !form.password)) {
|
||||
wx.showToast({ title: '请填写手机号和密码', icon: 'none' })
|
||||
wx.showToast({ title: '请填写账号和密码', icon: 'none' })
|
||||
return
|
||||
}
|
||||
if (this.data.loginMode === 'phone' && (!PHONE_REGEX.test(String(form.phone || '').trim()) || !String(form.code || '').trim())) {
|
||||
@@ -311,18 +339,20 @@ Page({
|
||||
}
|
||||
this.setData({ loading: true })
|
||||
try {
|
||||
const data = await this.requestLogin('')
|
||||
const app = getApp()
|
||||
const data = await this.requestLogin('')
|
||||
const session = await this.resolveLoginSession(data)
|
||||
if (!session) {
|
||||
return
|
||||
}
|
||||
app.setSession(session)
|
||||
app.setSession(assertShopSession(session))
|
||||
wx.reLaunch({ url: '/pages/planning/index' })
|
||||
} catch (error) {
|
||||
if (isShopSelectionRequiredError(error)) {
|
||||
if (isShopSelectionRequiredError(error) || await this.tryOpenLoginShopSelector()) {
|
||||
try {
|
||||
await this.openLoginShopSelector()
|
||||
if (!this.data.shopSelectVisible) {
|
||||
await this.openLoginShopSelector()
|
||||
}
|
||||
} catch (shopError) {
|
||||
wx.showToast({ title: shopError.message || '店铺列表加载失败', icon: 'none' })
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
</view>
|
||||
|
||||
<view wx:if="{{loginMode === 'password'}}" class="field">
|
||||
<text class="field-label">手机号</text>
|
||||
<input value="{{form.account}}" data-field="account" bindinput="onInput" placeholder="请输入手机号或账号" />
|
||||
<text class="field-label">账号</text>
|
||||
<input value="{{form.account}}" data-field="account" bindinput="onInput" placeholder="请输入账号" />
|
||||
</view>
|
||||
<view wx:if="{{loginMode === 'password'}}" class="field">
|
||||
<text class="field-label">密码</text>
|
||||
@@ -36,6 +36,10 @@
|
||||
<view class="agreement-check {{agreementAccepted ? 'checked' : ''}}">{{agreementAccepted ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">我已阅读并同意用户协议和隐私政策</view>
|
||||
</view>
|
||||
<view class="remember-row" bindtap="toggleRememberMe">
|
||||
<view class="agreement-check {{rememberMe ? 'checked' : ''}}">{{rememberMe ? '✓' : ''}}</view>
|
||||
<view class="agreement-copy">记住登录 1 小时</view>
|
||||
</view>
|
||||
<button class="primary-btn login-btn" loading="{{loading}}" bindtap="submit">登录</button>
|
||||
<view class="auth-links">
|
||||
<button class="text-btn">忘记密码</button>
|
||||
@@ -62,7 +66,7 @@
|
||||
<view class="shop-option-icon">店</view>
|
||||
<view class="shop-option-copy">
|
||||
<text class="shop-option-name">{{item.name}}</text>
|
||||
<text class="shop-option-id">ID {{item.id}}</text>
|
||||
<text class="shop-option-id">{{item.description || ('ID ' + item.id)}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</scroll-view>
|
||||
|
||||
@@ -93,7 +93,8 @@
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.agreement-row {
|
||||
.agreement-row,
|
||||
.remember-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 14rpx;
|
||||
@@ -102,6 +103,10 @@
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.remember-row {
|
||||
margin-top: 18rpx;
|
||||
}
|
||||
|
||||
.agreement-check {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -7,14 +7,6 @@ function canCreateAppointment() {
|
||||
return Number(userInfo.type) !== 3
|
||||
}
|
||||
|
||||
function buildEmptyCalendar() {
|
||||
return {
|
||||
artists: [],
|
||||
appointments: [],
|
||||
daySummaries: []
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCalendarErrorMessage(error) {
|
||||
return error && error.message ? error.message : '规划数据加载失败'
|
||||
}
|
||||
@@ -153,7 +145,7 @@ Page({
|
||||
this.applyCalendar(data)
|
||||
this.setData({ calendarError: '' })
|
||||
} catch (error) {
|
||||
this.applyCalendar(buildEmptyCalendar())
|
||||
this.clearCalendarView()
|
||||
this.setData({
|
||||
calendarError: resolveCalendarErrorMessage(error),
|
||||
selectedArtistId: '',
|
||||
@@ -168,6 +160,23 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
clearCalendarView() {
|
||||
this.setData({
|
||||
businessStartTime: '10:00',
|
||||
businessEndTime: '22:00',
|
||||
artists: [],
|
||||
appointments: [],
|
||||
daySummaries: [],
|
||||
monthDays: [],
|
||||
weekDays: [],
|
||||
dayLanes: [],
|
||||
hours: [],
|
||||
dayTotal: 0,
|
||||
freeArtistCount: 0,
|
||||
pendingCount: 0
|
||||
})
|
||||
},
|
||||
|
||||
resolveRange() {
|
||||
const current = this.data.currentDateText
|
||||
if (this.data.viewMode === 'week') {
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<button class="calendar-error-action" bindtap="loadCalendar">重试</button>
|
||||
</view>
|
||||
|
||||
<block wx:if="{{!calendarError}}">
|
||||
<view wx:if="{{viewMode === 'day'}}" class="section">
|
||||
<view class="day-summary">
|
||||
<view class="summary-item card">
|
||||
@@ -146,6 +147,7 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</block>
|
||||
|
||||
<button wx:if="{{canCreateAppointment}}" class="fab" bindtap="createAppointment">+</button>
|
||||
<button wx:if="{{canCreateAppointment && !calendarError}}" class="fab" bindtap="createAppointment">+</button>
|
||||
</view>
|
||||
|
||||
@@ -139,10 +139,10 @@ const DEVELOP_TARGET = Object.prototype.hasOwnProperty.call(localOverride, 'deve
|
||||
const BASE_DOMAIN = resolveDomain(DOMAIN_MAP, ENV_VERSION, DEVELOP_TARGET)
|
||||
const brandOverride = localOverride.brand || {}
|
||||
const BRAND_CONFIG = {
|
||||
appName: String(brandOverride.appName || '指尖管理师'),
|
||||
productName: String(brandOverride.productName || 'Fingertip Designer'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || 'Fingertip Designer'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:Fingertip Designer')
|
||||
appName: String(brandOverride.appName || '甲屿店务'),
|
||||
productName: String(brandOverride.productName || '甲屿设计师'),
|
||||
defaultShopName: String(brandOverride.defaultShopName || '甲屿设计师'),
|
||||
registerShopPlaceholder: String(brandOverride.registerShopPlaceholder || '例如:甲屿设计师')
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
@@ -3,10 +3,10 @@ module.exports = {
|
||||
requestTimeout: 10000,
|
||||
enableRequestSigning: true,
|
||||
brand: {
|
||||
appName: '指尖管理师',
|
||||
productName: 'Fingertip Designer',
|
||||
defaultShopName: 'Fingertip Designer',
|
||||
registerShopPlaceholder: '例如:Fingertip Designer'
|
||||
appName: '甲屿店务',
|
||||
productName: '甲屿设计师',
|
||||
defaultShopName: '甲屿设计师',
|
||||
registerShopPlaceholder: '例如:甲屿设计师'
|
||||
},
|
||||
domains: {
|
||||
local: 'http://127.0.0.1:80',
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
const date = require('./date')
|
||||
|
||||
const artists = [
|
||||
{ id: 101, name: '小王', shortName: '王', color: '#7BA7C7', status: 1, statusText: '可预约', rangeCount: 0 },
|
||||
{ id: 102, name: '小李', shortName: '李', color: '#8FB89A', status: 1, statusText: '可预约', rangeCount: 0 },
|
||||
{ id: 103, name: '小张', shortName: '张', color: '#A894C7', status: 1, statusText: '可预约', rangeCount: 0 }
|
||||
]
|
||||
|
||||
function countFor(day, index) {
|
||||
const seed = day.getDate() + index * 2 + day.getMonth()
|
||||
if (seed % 7 === 0) return 0
|
||||
return (seed % 4) + 1
|
||||
}
|
||||
|
||||
function buildCalendar(currentDate) {
|
||||
const start = date.startOfMonth(currentDate)
|
||||
const end = date.endOfMonth(currentDate)
|
||||
const daySummaries = []
|
||||
const appointments = []
|
||||
let cursor = new Date(start.getTime())
|
||||
let orderItemId = 1
|
||||
while (cursor <= end) {
|
||||
const dateText = date.formatDate(cursor)
|
||||
const artistCounts = artists.map((artist, index) => {
|
||||
const count = countFor(cursor, index)
|
||||
return {
|
||||
artistId: artist.id,
|
||||
artistName: artist.name,
|
||||
shortName: artist.shortName,
|
||||
color: artist.color,
|
||||
count,
|
||||
status: count >= 4 ? 'full' : count > 0 ? 'working' : 'free'
|
||||
}
|
||||
})
|
||||
const totalCount = artistCounts.reduce((sum, item) => sum + item.count, 0)
|
||||
daySummaries.push({
|
||||
date: dateText,
|
||||
totalCount,
|
||||
artistCounts,
|
||||
dayStatus: totalCount >= 8 ? 'full' : totalCount > 0 ? 'working' : 'free'
|
||||
})
|
||||
artistCounts.forEach((count, artistIndex) => {
|
||||
for (let i = 0; i < Math.min(count.count, 3); i += 1) {
|
||||
const startMinute = 10 * 60 + ((artistIndex * 90 + i * 110 + cursor.getDate() * 5) % 620)
|
||||
const duration = i % 2 === 0 ? 90 : 60
|
||||
const artist = artists[artistIndex]
|
||||
appointments.push({
|
||||
orderId: 9000 + orderItemId,
|
||||
orderItemId,
|
||||
customerName: ['王女士', '陈女士', '林女士', '赵女士'][i % 4],
|
||||
customerPhone: '138****' + String(1000 + orderItemId).slice(-4),
|
||||
productTitle: ['纯色美甲', '猫眼延长', '手部护理', '法式款'][i % 4],
|
||||
artistId: artist.id,
|
||||
artistName: artist.name,
|
||||
artistColor: artist.color,
|
||||
date: dateText,
|
||||
startTime: `${dateText} ${date.timeFromMinutes(startMinute)}:00`,
|
||||
endTime: `${dateText} ${date.timeFromMinutes(startMinute + duration)}:00`,
|
||||
startMinute,
|
||||
durationMinutes: duration,
|
||||
status: i === 2 ? 0 : 1,
|
||||
statusText: i === 2 ? '待确认' : '已确认',
|
||||
remark: ''
|
||||
})
|
||||
orderItemId += 1
|
||||
}
|
||||
})
|
||||
cursor = date.addDays(cursor, 1)
|
||||
}
|
||||
artists.forEach(artist => {
|
||||
artist.rangeCount = appointments.filter(item => item.artistId === artist.id).length
|
||||
})
|
||||
return {
|
||||
businessStartTime: '10:00',
|
||||
businessEndTime: '22:00',
|
||||
slotMinutes: 30,
|
||||
artists,
|
||||
schedules: [],
|
||||
appointments,
|
||||
daySummaries
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
artists,
|
||||
buildCalendar
|
||||
}
|
||||
@@ -9,6 +9,8 @@ const HEADER_NONCE = 'X-Nonce'
|
||||
const HEADER_SIGNATURE = 'X-Signature'
|
||||
const HEADER_SIGNATURE_VERSION = 'X-Sign-Version'
|
||||
|
||||
let sessionExpiredHandling = false
|
||||
|
||||
function buildUrl(url, params) {
|
||||
const sourceParams = params || {}
|
||||
const baseUrl = sourceParams.__baseUrl ? sourceParams.__baseUrl : ADMIN_API_BASE_URL
|
||||
@@ -27,6 +29,47 @@ function normalizeError(message, raw) {
|
||||
return error
|
||||
}
|
||||
|
||||
function resolveResponseMessage(response, fallbackMessage) {
|
||||
const data = response && response.data ? response.data : {}
|
||||
return data.message || fallbackMessage
|
||||
}
|
||||
|
||||
function clearRuntimeSession() {
|
||||
const app = getApp()
|
||||
if (app && typeof app.clearSession === 'function') {
|
||||
app.clearSession()
|
||||
return
|
||||
}
|
||||
auth.clearSession()
|
||||
}
|
||||
|
||||
function redirectToLoginAfterExpired(message) {
|
||||
if (sessionExpiredHandling) {
|
||||
return
|
||||
}
|
||||
sessionExpiredHandling = true
|
||||
clearRuntimeSession()
|
||||
wx.showToast({
|
||||
title: message,
|
||||
icon: 'none',
|
||||
duration: 1200
|
||||
})
|
||||
setTimeout(() => {
|
||||
wx.reLaunch({
|
||||
url: '/pages/login/index',
|
||||
complete() {
|
||||
sessionExpiredHandling = false
|
||||
}
|
||||
})
|
||||
}, 700)
|
||||
}
|
||||
|
||||
function handleUnauthorized(response) {
|
||||
const message = resolveResponseMessage(response, '登录已过期,请重新登录')
|
||||
redirectToLoginAfterExpired(message)
|
||||
return normalizeError(message, response)
|
||||
}
|
||||
|
||||
function extractPath(value) {
|
||||
const target = String(value || '')
|
||||
if (!target) {
|
||||
@@ -71,6 +114,7 @@ function isAuthFreePath(url) {
|
||||
'/auth/register',
|
||||
'/user/send-verification-code',
|
||||
'/user/phone-login',
|
||||
'/user/check/login-shops/',
|
||||
'/legal-agreement/current'
|
||||
].some(path => String(url || '').includes(path))
|
||||
}
|
||||
@@ -134,9 +178,7 @@ function request(options) {
|
||||
},
|
||||
success(response) {
|
||||
if (response.statusCode === 401) {
|
||||
auth.clearSession()
|
||||
wx.reLaunch({ url: '/pages/login/index' })
|
||||
reject(normalizeError('登录已失效,请重新登录', response))
|
||||
reject(handleUnauthorized(response))
|
||||
return
|
||||
}
|
||||
if (response.statusCode >= 400) {
|
||||
@@ -149,6 +191,10 @@ function request(options) {
|
||||
resolve(payload.data)
|
||||
return
|
||||
}
|
||||
if (payload.code === 401) {
|
||||
reject(handleUnauthorized({ data: payload }))
|
||||
return
|
||||
}
|
||||
reject(normalizeError(payload.message || '请求失败', payload))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user