Merge pull request 'Dev' (#60) from dev into sit
发布 Nacos 配置 / publish (push) Successful in 32s
Salon SIT 自动发布 / deploy (push) Failing after 3m3s

Reviewed-on: http://wcy111.top:3000/xiaowang/JayuCloud/pulls/60
This commit was merged in pull request #60.
This commit is contained in:
2026-10-12 10:53:47 +08:00
69 changed files with 1854 additions and 648 deletions
@@ -21,6 +21,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmen
import com.xiaowang.jacyucloudsalon.core.modules.planning.service.PlanningService;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningTodayOverviewVO;
import com.xiaowang.jacyucloudsalon.core.modules.product.service.ProductService;
import com.xiaowang.jacyucloudsalon.core.modules.product.vo.ProductVO;
import com.xiaowang.jacyucloudsalon.core.modules.security.support.AdminScopeHelper;
@@ -72,6 +73,13 @@ public class AdminManagerController {
return Result.success(planningService.getCalendar(currentUser, start, end, artistId));
}
@GetMapping("/planning/today-overview")
@RequirePermission("schedule:view")
public Result<PlanningTodayOverviewVO> todayOverview(HttpServletRequest request) {
UserDO currentUser = adminScopeHelper.getCurrentUser(request);
return Result.success(planningService.getTodayOverview(currentUser));
}
@PostMapping("/planning/appointments")
@RequirePermission("order:process")
@OperationGuard(action = "manager-planning-create-appointment", ttlSeconds = 10, message = "预约创建处理中,请勿重复提交")
@@ -6,12 +6,15 @@ import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmen
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningTodayOverviewVO;
import java.time.LocalDate;
public interface PlanningService {
PlanningCalendarVO getCalendar(UserDO currentUser, LocalDate startDate, LocalDate endDate, Long artistId);
PlanningTodayOverviewVO getTodayOverview(UserDO currentUser);
PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto);
PlanningAppointmentVO getAppointment(UserDO currentUser, Long orderItemId);
@@ -6,6 +6,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmen
import com.xiaowang.jacyucloudsalon.core.modules.planning.dto.PlanningAppointmentStatusDTO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.entity.AppointmentReservationDO;
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleDO;
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.ArtistScheduleExceptionDO;
import com.xiaowang.jacyucloudsalon.core.modules.artist.entity.NailArtistInfoDO;
import com.xiaowang.jacyucloudsalon.core.modules.order.entity.OrderDO;
import com.xiaowang.jacyucloudsalon.core.modules.order.entity.OrderItemDO;
@@ -14,6 +15,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.mapper.AppointmentReservationMapper;
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.ArtistScheduleMapper;
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.ArtistScheduleExceptionMapper;
import com.xiaowang.jacyucloudsalon.core.modules.artist.mapper.NailArtistInfoMapper;
import com.xiaowang.jacyucloudsalon.core.modules.order.mapper.OrderItemMapper;
import com.xiaowang.jacyucloudsalon.core.modules.order.mapper.OrderMapper;
@@ -26,6 +28,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.planning.service.PlanningServic
import com.xiaowang.jacyucloudsalon.core.modules.security.support.AdminScopeHelper;
import com.xiaowang.jacyucloudsalon.core.modules.order.support.OrderStatus;
import com.xiaowang.jacyucloudsalon.core.modules.planning.support.PlanningCalendarSupport;
import com.xiaowang.jacyucloudsalon.core.modules.planning.support.PlanningTodayOverviewSupport;
import com.xiaowang.jacyucloudsalon.core.support.id.TimeOrderedSnowflakeIdGenerator;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningArtistCountVO;
@@ -33,6 +36,7 @@ import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningArtistVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningDaySummaryVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningScheduleVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningTodayOverviewVO;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -75,6 +79,7 @@ public class PlanningServiceImpl implements PlanningService {
private final UserMapper userMapper;
private final NailArtistInfoMapper nailArtistInfoMapper;
private final ArtistScheduleMapper artistScheduleMapper;
private final ArtistScheduleExceptionMapper artistScheduleExceptionMapper;
private final AppointmentReservationMapper appointmentReservationMapper;
private final OrderMapper orderMapper;
private final OrderItemMapper orderItemMapper;
@@ -103,8 +108,10 @@ public class PlanningServiceImpl implements PlanningService {
List<PlanningArtistVO> artists = listArtists(shopId, artistId);
List<ArtistScheduleDO> schedules = listSchedules(shopId, start, end, artistId);
Map<Long, String> artistNames = artists.stream()
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
List<PlanningScheduleVO> scheduleVos = schedules.stream()
.map(schedule -> toScheduleVO(schedule, artists))
.map(schedule -> toScheduleVO(schedule, artistNames))
.sorted(Comparator.comparing(PlanningScheduleVO::getDate)
.thenComparing(PlanningScheduleVO::getStartTime)
.thenComparing(PlanningScheduleVO::getArtistName, Comparator.nullsLast(String::compareTo)))
@@ -129,6 +136,27 @@ public class PlanningServiceImpl implements PlanningService {
return vo;
}
@Override
public PlanningTodayOverviewVO getTodayOverview(UserDO currentUser) {
LocalDate today = LocalDate.now();
Long shopId = requirePlanningShopId(currentUser);
PlanningCalendarVO calendar = getCalendar(currentUser, today, today, null);
QueryWrapper<ArtistScheduleExceptionDO> exceptionWrapper = new QueryWrapper<>();
exceptionWrapper.eq("shop_id", shopId)
.eq("work_date", today)
.eq("is_delete", 0);
Long exceptionCount = artistScheduleExceptionMapper.selectCount(exceptionWrapper);
ShopDO shop = shopMapper.selectById(shopId);
boolean shopOpen = shop != null && !Integer.valueOf(0).equals(shop.getStatus());
return PlanningTodayOverviewSupport.build(
calendar,
today,
LocalTime.now(),
exceptionCount == null ? 0L : exceptionCount,
shopOpen
);
}
@Override
@Transactional
public PlanningAppointmentVO createAppointment(UserDO currentUser, PlanningAppointmentCreateDTO dto) {
@@ -340,9 +368,7 @@ public class PlanningServiceImpl implements PlanningService {
return artistScheduleMapper.selectList(wrapper);
}
private PlanningScheduleVO toScheduleVO(ArtistScheduleDO schedule, List<PlanningArtistVO> artists) {
Map<Long, String> artistNames = artists.stream()
.collect(Collectors.toMap(PlanningArtistVO::getId, PlanningArtistVO::getName, (a, b) -> a));
private PlanningScheduleVO toScheduleVO(ArtistScheduleDO schedule, Map<Long, String> artistNames) {
PlanningScheduleVO vo = new PlanningScheduleVO();
vo.setId(schedule.getId());
vo.setArtistId(schedule.getArtistId());
@@ -518,6 +544,9 @@ public class PlanningServiceImpl implements PlanningService {
Map<Long, Long> countByArtist = dayAppointments.stream()
.filter(appointment -> appointment.getArtistId() != null)
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId, Collectors.counting()));
Map<Long, List<PlanningAppointmentVO>> appointmentsByArtist = dayAppointments.stream()
.filter(appointment -> appointment.getArtistId() != null)
.collect(Collectors.groupingBy(PlanningAppointmentVO::getArtistId));
List<ArtistScheduleDO> daySchedules = schedulesByDate.getOrDefault(date, List.of());
Map<Long, ArtistScheduleDO> scheduleByArtist = daySchedules.stream()
.collect(Collectors.toMap(ArtistScheduleDO::getArtistId, Function.identity(), (a, b) -> a));
@@ -528,9 +557,7 @@ public class PlanningServiceImpl implements PlanningService {
for (PlanningArtistVO artist : artists) {
int count = countByArtist.getOrDefault(artist.getId(), 0L).intValue();
ArtistScheduleDO schedule = scheduleByArtist.get(artist.getId());
List<PlanningAppointmentVO> artistAppointments = dayAppointments.stream()
.filter(appointment -> Objects.equals(appointment.getArtistId(), artist.getId()))
.toList();
List<PlanningAppointmentVO> artistAppointments = appointmentsByArtist.getOrDefault(artist.getId(), List.of());
String artistStatus = resolveArtistDayStatus(artist, schedule, artistAppointments);
if (!"rest".equals(artistStatus)) {
workingArtistCount++;
@@ -0,0 +1,45 @@
package com.xiaowang.jacyucloudsalon.core.modules.planning.support;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningAppointmentVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningArtistVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningCalendarVO;
import com.xiaowang.jacyucloudsalon.core.modules.planning.vo.PlanningTodayOverviewVO;
import java.time.LocalDate;
import java.time.LocalTime;
import java.util.List;
public final class PlanningTodayOverviewSupport {
private PlanningTodayOverviewSupport() {
}
public static PlanningTodayOverviewVO build(PlanningCalendarVO calendar,
LocalDate date,
LocalTime now,
long scheduleExceptions,
boolean shopOpen) {
List<PlanningAppointmentVO> appointments = calendar == null || calendar.getAppointments() == null
? List.of() : calendar.getAppointments();
List<PlanningArtistVO> artists = calendar == null || calendar.getArtists() == null
? List.of() : calendar.getArtists();
int currentMinute = now.getHour() * 60 + now.getMinute();
PlanningTodayOverviewVO overview = new PlanningTodayOverviewVO();
overview.setDate(String.format("%02d月%02d日", date.getMonthValue(), date.getDayOfMonth()));
overview.setTodayAppointments(appointments.size());
overview.setPendingAppointments((int) appointments.stream()
.filter(item -> Integer.valueOf(0).equals(item.getStatus()))
.count());
overview.setUpcomingAppointments((int) appointments.stream()
.filter(item -> item.getStartMinute() != null && item.getStartMinute() >= currentMinute)
.count());
overview.setAvailableEmployees((int) artists.stream()
.filter(item -> !Integer.valueOf(0).equals(item.getStatus()))
.count());
overview.setScheduleExceptions(Math.toIntExact(Math.max(0L, scheduleExceptions)));
overview.setShopOpen(shopOpen);
overview.setShopStatus(shopOpen ? "营业中" : "已暂停");
return overview;
}
}
@@ -0,0 +1,15 @@
package com.xiaowang.jacyucloudsalon.core.modules.planning.vo;
import lombok.Data;
@Data
public class PlanningTodayOverviewVO {
private String date;
private Integer todayAppointments;
private Integer pendingAppointments;
private Integer upcomingAppointments;
private Integer availableEmployees;
private Integer scheduleExceptions;
private Boolean shopOpen;
private String shopStatus;
}
@@ -0,0 +1,64 @@
package com.xiaowang.jacyucloudsalon.core.modules.registration.controller;
import com.xiaowang.jacyucloudsalon.core.common.Result;
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRejectDTO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.entity.WorkbenchRegistrationApplicationDO;
import com.xiaowang.jacyucloudsalon.core.modules.registration.service.WorkbenchRegistrationService;
import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/admin/user/workbench/registration")
public class AdminWorkbenchRegistrationController {
private final WorkbenchRegistrationService registrationService;
private final UserMapper userMapper;
public AdminWorkbenchRegistrationController(WorkbenchRegistrationService registrationService, UserMapper userMapper) {
this.registrationService = registrationService;
this.userMapper = userMapper;
}
@GetMapping("/list")
public Result<List<WorkbenchRegistrationApplicationDO>> list(HttpServletRequest request) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
return Result.success(registrationService.listForReviewer(userId, isPlatformAdmin(user)));
}
@PostMapping("/{id}/approve")
public Result<Boolean> approve(HttpServletRequest request, @PathVariable Long id) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
return Result.success(registrationService.approve(userId, isPlatformAdmin(user), id));
}
@PostMapping("/{id}/reject")
public Result<Boolean> reject(HttpServletRequest request, @PathVariable Long id,
@RequestBody WorkbenchRegistrationRejectDTO requestDTO) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
String reason = requestDTO == null ? null : requestDTO.getReason();
return Result.success(registrationService.reject(userId, isPlatformAdmin(user), id, reason));
}
private boolean isPlatformAdmin(UserDO user) {
return user != null && Integer.valueOf(4).equals(user.getType());
}
private Long requireUserId(HttpServletRequest request) {
Object userId = request.getAttribute("userId");
if (!(userId instanceof Long)) {
throw new IllegalArgumentException("登录状态已失效");
}
return (Long) userId;
}
}
@@ -2,9 +2,7 @@ package com.xiaowang.jacyucloudsalon.core.modules.registration.controller;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xiaowang.jacyucloudsalon.core.common.Result;
import com.xiaowang.jacyucloudsalon.core.modules.registration.dto.WorkbenchRegistrationRejectDTO;
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.service.WorkbenchRegistrationService;
import com.xiaowang.jacyucloudsalon.core.modules.registration.vo.WorkbenchRegistrationStatusVO;
import com.xiaowang.jacyucloudsalon.core.modules.shop.entity.ShopDO;
@@ -13,7 +11,6 @@ import com.xiaowang.jacyucloudsalon.core.modules.user.entity.UserDO;
import com.xiaowang.jacyucloudsalon.core.modules.user.mapper.UserMapper;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@@ -53,32 +50,4 @@ public class WorkbenchRegistrationController {
return Result.success(shopMapper.selectList(Wrappers.lambdaQuery(ShopDO.class).eq(ShopDO::getStatus, 1).eq(ShopDO::getIsDelete, 0).select(ShopDO::getId, ShopDO::getShopName, ShopDO::getAddress).orderByAsc(ShopDO::getShopName)));
}
@GetMapping("/registration/list")
public Result<List<WorkbenchRegistrationApplicationDO>> list(HttpServletRequest request) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
return Result.success(registrationService.listForReviewer(userId, user != null && Integer.valueOf(4).equals(user.getType())));
}
@PostMapping("/registration/{id}/approve")
public Result<Boolean> approve(HttpServletRequest request, @PathVariable Long id) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
return Result.success(registrationService.approve(userId, user != null && Integer.valueOf(4).equals(user.getType()), id));
}
@PostMapping("/registration/{id}/reject")
public Result<Boolean> reject(HttpServletRequest request, @PathVariable Long id, @RequestBody WorkbenchRegistrationRejectDTO requestDTO) {
Long userId = requireUserId(request);
UserDO user = userMapper.selectById(userId);
return Result.success(registrationService.reject(userId, user != null && Integer.valueOf(4).equals(user.getType()), id, requestDTO == null ? null : requestDTO.getReason()));
}
private Long requireUserId(HttpServletRequest request) {
Object userId = request.getAttribute("userId");
if (!(userId instanceof Long)) {
throw new IllegalArgumentException("登录状态已失效");
}
return (Long) userId;
}
}
@@ -0,0 +1,31 @@
package com.xiaowang.jacyucloudsalon.core.modules.registration.controller;
import org.junit.jupiter.api.Test;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.lang.reflect.Method;
import java.util.Arrays;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
class WorkbenchRegistrationControllerMappingTest {
@Test
void separatesMiniProgramRegistrationFromAdminReviewEndpoints() throws Exception {
RequestMapping publicMapping = WorkbenchRegistrationController.class.getAnnotation(RequestMapping.class);
RequestMapping adminMapping = AdminWorkbenchRegistrationController.class.getAnnotation(RequestMapping.class);
assertNotNull(publicMapping);
assertNotNull(adminMapping);
assertArrayEquals(new String[]{"/user/workbench"}, publicMapping.value());
assertArrayEquals(new String[]{"/admin/user/workbench/registration"}, adminMapping.value());
Method listMethod = AdminWorkbenchRegistrationController.class.getMethod("list", javax.servlet.http.HttpServletRequest.class);
GetMapping listMapping = listMethod.getAnnotation(GetMapping.class);
assertNotNull(listMapping);
assertEquals("/list", Arrays.stream(listMapping.value()).findFirst().orElse(""));
}
}
@@ -0,0 +1,66 @@
// @vitest-environment jsdom
import { beforeEach, describe, expect, it, vi } from 'vitest'
import { readFileSync } from 'node:fs'
import { resolve } from 'node:path'
import { completeAdminLogout } from './admin-logout'
describe('completeAdminLogout', () => {
beforeEach(() => {
localStorage.clear()
sessionStorage.clear()
localStorage.setItem('adminAccessToken', 'access')
localStorage.setItem('adminRefreshToken', 'refresh')
localStorage.setItem('adminUserInfo', '{"id":1}')
localStorage.setItem('userPermissions', '["user:view"]')
sessionStorage.setItem('adminAccessToken', 'session-access')
sessionStorage.setItem('adminRefreshToken', 'session-refresh')
localStorage.setItem('accessToken', 'legacy-access')
localStorage.setItem('refreshToken', 'legacy-refresh')
localStorage.setItem('userInfo', '{"id":2}')
sessionStorage.setItem('accessToken', 'legacy-session-access')
})
it('clears the admin session and replaces the current route', async () => {
const replace = vi.fn().mockResolvedValue(undefined)
const requestLogout = vi.fn().mockResolvedValue(true)
await completeAdminLogout({ replace }, requestLogout)
expect(requestLogout).toHaveBeenCalledOnce()
expect(localStorage.getItem('adminAccessToken')).toBeNull()
expect(localStorage.getItem('adminRefreshToken')).toBeNull()
expect(localStorage.getItem('adminUserInfo')).toBeNull()
expect(localStorage.getItem('userPermissions')).toBeNull()
expect(sessionStorage.getItem('adminAccessToken')).toBeNull()
expect(sessionStorage.getItem('adminRefreshToken')).toBeNull()
expect(localStorage.getItem('accessToken')).toBeNull()
expect(localStorage.getItem('refreshToken')).toBeNull()
expect(localStorage.getItem('userInfo')).toBeNull()
expect(sessionStorage.getItem('accessToken')).toBeNull()
expect(replace).toHaveBeenCalledWith('/admin/login')
})
it('still completes local logout when the server request fails', async () => {
const replace = vi.fn().mockResolvedValue(undefined)
const requestLogout = vi.fn().mockRejectedValue(new Error('network unavailable'))
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => undefined)
await completeAdminLogout({ replace }, requestLogout)
expect(localStorage.getItem('adminAccessToken')).toBeNull()
expect(replace).toHaveBeenCalledWith('/admin/login')
expect(consoleError).toHaveBeenCalled()
consoleError.mockRestore()
})
it('keeps admin pages free of hard navigation logout code', () => {
const layout = readFileSync(resolve(process.cwd(), 'src/views/admin/AdminLayout.vue'), 'utf8')
const profile = readFileSync(resolve(process.cwd(), 'src/views/admin/ProfileView.vue'), 'utf8')
expect(layout).not.toContain("window.location.href = '/admin/login'")
expect(profile).not.toContain("window.location.href = '/admin/login'")
expect(layout).toContain('completeAdminLogout(router)')
expect(profile).toContain('completeAdminLogout(router)')
})
})
@@ -0,0 +1,28 @@
import type { Router } from 'vue-router'
import { adminAuthApi } from '@/api/admin'
import { clearAdminBootstrapSession } from '@/utils/admin-auth-bootstrap'
type AdminLogoutRouter = Pick<Router, 'replace'>
type AdminLogoutRequest = () => Promise<unknown>
const clearLegacySharedSession = () => {
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
localStorage.removeItem('userInfo')
sessionStorage.removeItem('accessToken')
}
export const completeAdminLogout = async (
router: AdminLogoutRouter,
requestLogout: AdminLogoutRequest = adminAuthApi.logout
) => {
try {
await requestLogout()
} catch (error) {
console.error('退出登录接口调用失败:', error)
} finally {
clearAdminBootstrapSession()
clearLegacySharedSession()
await router.replace('/admin/login')
}
}
@@ -230,6 +230,7 @@ import { usePermission } from '@/utils/permission'
import { isAllowedForShoplessPlatformAdmin } from '@/utils/platform-admin-permissions'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { notifyShopThemeChanged } from '@/utils/shop-theme'
import { completeAdminLogout } from '@/utils/admin-logout'
import { useAdminViewport } from '@/composables/useAdminViewport'
import { adminNavigationItems, findAdminNavigationItemByPath, type AdminNavIconKey } from '@/config/admin-navigation'
import { BRAND_CONFIG } from '@/config/brand'
@@ -413,23 +414,8 @@ const handleLogout = () => {
cancelText: '取消',
onOk: async () => {
await runWithGlobalLoading(async () => {
try {
await adminAuthApi.logout()
} catch (error) {
console.error('退出失败:', error)
} finally {
localStorage.removeItem('adminAccessToken')
localStorage.removeItem('adminRefreshToken')
localStorage.removeItem('adminUserInfo')
localStorage.removeItem('accessToken')
localStorage.removeItem('refreshToken')
localStorage.removeItem('userInfo')
sessionStorage.removeItem('adminAccessToken')
sessionStorage.removeItem('accessToken')
clearPermissions()
message.success('已退出登录')
window.location.href = '/admin/login'
}
await completeAdminLogout(router)
message.success('已退出登录')
})
}
})
@@ -89,6 +89,7 @@ import { adminAuthApi } from '@/api/admin'
import { usePermission } from '@/utils/permission'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { notifyShopThemeChanged } from '@/utils/shop-theme'
import { completeAdminLogout } from '@/utils/admin-logout'
import {
getAdminCurrentShopName,
getAdminRoleLabel,
@@ -102,7 +103,7 @@ import {
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const router = useRouter()
const { userPermissions, loadUserPermissions, clearPermissions } = usePermission()
const { userPermissions, loadUserPermissions } = usePermission()
/** userInfo is a reactive state variable used by the template and event handlers. */
const userInfo = ref(loadCachedAdminUserInfo())
@@ -188,20 +189,8 @@ const handleLogout = () => {
cancelText: '取消',
onOk: async () => {
await runWithGlobalLoading(async () => {
try {
await adminAuthApi.logout()
} catch (error) {
console.error('退出失败:', error)
} finally {
localStorage.removeItem('adminAccessToken')
localStorage.removeItem('adminRefreshToken')
localStorage.removeItem('adminUserInfo')
localStorage.removeItem('userPermissions')
sessionStorage.removeItem('adminAccessToken')
clearPermissions()
message.success('已退出登录')
window.location.href = '/admin/login'
}
await completeAdminLogout(router)
message.success('已退出登录')
})
}
})
@@ -2,7 +2,13 @@
<div class="registration-page">
<a-page-header title="工作台注册审核" sub-title="审核店长注册申请" />
<a-card :bordered="false">
<a-table :columns="columns" :data-source="applications" :loading="loading" row-key="id">
<a-table
:columns="columns"
:data-source="applications"
:loading="loading"
:scroll="{ x: 'max-content' }"
row-key="id"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'roleType'">{{ record.roleType === 'MANAGER' ? '店长' : '店员' }}</template>
<template v-else-if="column.key === 'status'">{{ statusLabel(record.status) }}</template>
@@ -68,7 +68,7 @@ describe('web theme governance', () => {
it('keeps frontend and backend platform overview permission allowlists aligned', () => {
const frontend = readSource('utils/platform-admin-permissions.ts')
const backend = readFileSync(join(coreRoot, 'com', 'xiaowang', 'fingertipdesigner', 'core', 'modules', 'security', 'support', 'PermissionCatalog.java'), 'utf-8')
const backend = readFileSync(join(coreRoot, 'com', 'xiaowang', 'jacyucloudsalon', 'core', 'modules', 'security', 'support', 'PermissionCatalog.java'), 'utf-8')
expect(backend).toContain('"security:audit:view"')
expect(frontend).toContain("'security:audit:view'")
@@ -17,7 +17,8 @@ import adminApi, {
adminCampaignApi,
adminDashboardApi,
adminInventoryApi,
adminPaymentApi
adminPaymentApi,
adminWorkbenchRegistrationApi
} from '../../src/api/admin'
import api from '../../src/api'
import { afterSaleApi, growthApi, paymentApi } from '../../src/api/order'
@@ -90,6 +91,9 @@ describe('vNext API contracts', () => {
await adminInventoryApi.adjustStock(7, { changeType: 'IN', changeQuantity: 3, remark: 'restock' })
await adminCampaignApi.saveCampaign({ title: 'Summer Set', scene: 'HOME', status: 1 })
await adminDashboardApi.getAnalytics()
await adminWorkbenchRegistrationApi.list()
await adminWorkbenchRegistrationApi.approve(12)
await adminWorkbenchRegistrationApi.reject(12, '资料不完整')
expect(requests).toEqual([
{ method: 'get', url: '/artist-schedule/list', params: { artistId: 9, startDate: '2026-06-01', endDate: '2026-06-07' }, data: undefined },
@@ -100,7 +104,10 @@ describe('vNext API contracts', () => {
{ method: 'post', url: '/inventory/save', params: undefined, data: { itemName: 'Base Gel', category: 'gel', unit: 'bottle', stockQuantity: 12 } },
{ method: 'post', url: '/inventory/7/adjust', params: undefined, data: { changeType: 'IN', changeQuantity: 3, remark: 'restock' } },
{ method: 'post', url: '/campaign/save', params: undefined, data: { title: 'Summer Set', scene: 'HOME', status: 1 } },
{ method: 'get', url: '/dashboard/analytics', params: undefined, data: undefined }
{ method: 'get', url: '/dashboard/analytics', params: undefined, data: undefined },
{ method: 'get', url: '/user/workbench/registration/list', params: undefined, data: undefined },
{ method: 'post', url: '/user/workbench/registration/12/approve', params: undefined, data: undefined },
{ method: 'post', url: '/user/workbench/registration/12/reject', params: undefined, data: { reason: '资料不完整' } }
])
})
+6
View File
@@ -8,6 +8,12 @@ module.exports = {
})
},
todayOverview() {
return request({
url: '/manager/planning/today-overview'
})
},
createAppointment(data) {
return request({
url: '/manager/planning/appointments',
+74
View File
@@ -0,0 +1,74 @@
const assert = require('assert')
const LOGIN_PREFERENCE_KEY = 'jayucloud_salon_login_preference'
const storage = {}
const navigations = []
let codeSequence = 0
let appDefinition
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getStorageSync: key => storage[key],
setStorageSync: (key, value) => { storage[key] = value },
removeStorageSync: key => { delete storage[key] },
login: ({ success }) => success({ code: `code-${++codeSequence}` }),
reLaunch: ({ url }) => { navigations.push(url) }
}
global.getCurrentPages = () => [{ route: 'pages/launch/index' }]
global.App = definition => { appDefinition = definition }
require('./app')
const authApi = require('./api/auth')
function reset(preference) {
Object.keys(storage).forEach(key => delete storage[key])
if (preference) storage[LOGIN_PREFERENCE_KEY] = preference
navigations.length = 0
appDefinition.globalData.userInfo = null
appDefinition.globalData.wechatLoginState = null
codeSequence = 0
}
async function run() {
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
let statusCalled = false
authApi.wechatStatus = async () => { statusCalled = true; return { status: 'READY' } }
authApi.wechatQuickLogin = async () => ({ status: 'SUCCESS', accessToken: 'token', userInfo: { id: 1 } })
await appDefinition.runWechatBootstrap()
assert.deepStrictEqual(navigations, ['/pages/planning/index'])
assert.strictEqual(appDefinition.globalData.userInfo.id, 1)
assert.strictEqual(statusCalled, false)
assert.strictEqual(codeSequence, 1)
reset({ rememberMe: false })
let quickLoginCalled = false
authApi.wechatStatus = async () => ({ status: 'READY' })
authApi.wechatQuickLogin = async () => { quickLoginCalled = true }
await appDefinition.runWechatBootstrap()
assert.deepStrictEqual(navigations, ['/pages/login/index'])
assert.strictEqual(quickLoginCalled, false)
assert.strictEqual(codeSequence, 1)
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
authApi.wechatQuickLogin = async () => { throw new Error('网络异常') }
await appDefinition.runWechatBootstrap()
assert.deepStrictEqual(navigations, ['/pages/login/index'])
assert.strictEqual(storage[LOGIN_PREFERENCE_KEY].rememberMe, true)
assert.strictEqual(appDefinition.globalData.wechatLoginState.status, 'ERROR')
reset({ rememberMe: true, agreementVersions: { USER_TERMS: '1', PRIVACY_POLICY: '1' } })
authApi.wechatQuickLogin = async () => ({ status: 'SELECT_SHOP', ticket: 'ticket', shops: [{ id: 2 }] })
await appDefinition.runWechatBootstrap()
assert.deepStrictEqual(navigations, ['/pages/login/index'])
assert.strictEqual(appDefinition.globalData.wechatLoginState.status, 'SELECT_SHOP')
appDefinition.logoutDevice()
assert.strictEqual(storage[LOGIN_PREFERENCE_KEY], undefined)
assert.strictEqual(appDefinition.globalData.userInfo, null)
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
+22 -8
View File
@@ -1,6 +1,7 @@
const auth = require('./utils/auth')
const authApi = require('./api/auth')
const { BRAND_CONFIG } = require('./utils/config')
const profileCache = require('./utils/profile-cache')
App({
globalData: {
@@ -13,7 +14,6 @@ App({
onLaunch() {
this.bootstrapSession()
this.bootstrapWechatLogin()
},
getWechatCode() {
@@ -26,14 +26,24 @@ App({
},
async bootstrapWechatLogin() {
if (this._wechatBootstrapPromise) return this._wechatBootstrapPromise
this._wechatBootstrapPromise = this.runWechatBootstrap()
try {
return await this._wechatBootstrapPromise
} finally {
this._wechatBootstrapPromise = null
}
},
async runWechatBootstrap() {
try {
const status = await authApi.wechatStatus(await this.getWechatCode())
this.publishWechatLoginState(status)
const preference = auth.getLoginPreference()
if (!preference.rememberMe || status.status !== 'READY') {
if (!preference || !preference.rememberMe) {
const status = await authApi.wechatStatus(await this.getWechatCode())
this.publishWechatLoginState(status)
auth.clearSession()
this.globalData.userInfo = null
this.goLoginIfNeeded()
this.goLogin()
return
}
const result = await authApi.wechatQuickLogin({
@@ -49,7 +59,9 @@ App({
wx.reLaunch({ url: '/pages/planning/index' })
return
}
wx.reLaunch({ url: '/pages/login/index' })
auth.clearSession()
this.globalData.userInfo = null
this.goLogin()
} catch (error) {
auth.clearSession()
this.globalData.userInfo = null
@@ -57,11 +69,11 @@ App({
status: 'ERROR',
message: error.message || '自动登录失败,请点击重试'
})
this.goLoginIfNeeded()
this.goLogin()
}
},
goLoginIfNeeded() {
goLogin() {
const pages = getCurrentPages()
const current = pages.length ? pages[pages.length - 1].route : ''
if (current !== 'pages/login/index') wx.reLaunch({ url: '/pages/login/index' })
@@ -91,11 +103,13 @@ App({
clearSession() {
auth.clearSession()
profileCache.invalidate()
this.globalData.userInfo = null
},
logoutDevice() {
auth.clearDeviceLoginState()
profileCache.invalidate()
this.globalData.userInfo = null
this.globalData.wechatLoginState = null
}
+3
View File
@@ -1,5 +1,6 @@
{
"pages": [
"pages/launch/index",
"pages/login/index",
"pages/register/index",
"pages/planning/index",
@@ -14,12 +15,14 @@
"pages/leave-management/index",
"pages/color-setting/index",
"pages/profile/index",
"pages/profile-edit/index",
"pages/account-settings/index",
"pages/shop-settings/index",
"pages/export/index",
"pages/password/index",
"pages/about/index"
],
"lazyCodeLoading": "requiredComponents",
"window": {
"navigationBarTitleText": "甲屿店务",
"navigationBarBackgroundColor": "#F8F5EF",
+1 -2
View File
@@ -220,8 +220,7 @@ button::after {
left: 0;
z-index: 20;
padding: 14rpx 24rpx calc(14rpx + env(safe-area-inset-bottom));
background: rgba(248, 245, 239, 0.94);
backdrop-filter: blur(18rpx);
background: #f8f5ef;
}
.fab {
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 144 KiB

@@ -1,6 +1,7 @@
const userApi = require('../../api/user')
const authApi = require('../../api/auth')
const auth = require('../../utils/auth')
const profileCache = require('../../utils/profile-cache')
Page({
data: {
@@ -10,15 +11,16 @@ Page({
smsForm: { phone: '', code: '' },
codeLoading: false,
countdown: 0,
timer: null
timer: null,
smsExpanded: false
},
onShow() { this.loadProfile() },
async loadProfile() {
async loadProfile(options = {}) {
this.setData({ loading: true })
try {
const profile = await userApi.info()
const profile = await profileCache.getProfile(options)
this.setData({ profile, 'smsForm.phone': profile.phone || '' })
const app = getApp()
const session = auth.getSession()
@@ -36,6 +38,10 @@ Page({
this.setData({ [`smsForm.${field}`]: value })
},
toggleSms() {
this.setData({ smsExpanded: !this.data.smsExpanded })
},
async bindWechatPhone(event) {
const phoneCode = event.detail && event.detail.code
if (!phoneCode) {
@@ -44,7 +50,8 @@ Page({
this.setData({ binding: true })
try {
await userApi.bindWechatPhone(phoneCode)
await this.loadProfile()
profileCache.invalidate()
await this.loadProfile({ force: true })
wx.showToast({ title: '手机号已绑定' })
} catch (error) {
wx.showToast({ title: error.message || '绑定失败', icon: 'none' })
@@ -90,7 +97,8 @@ Page({
this.setData({ binding: true })
try {
await userApi.bindPhone({ phone: form.phone, verificationCode: form.code })
await this.loadProfile()
profileCache.invalidate()
await this.loadProfile({ force: true })
wx.showToast({ title: '手机号已绑定' })
} catch (error) {
wx.showToast({ title: error.message || '绑定失败', icon: 'none' })
@@ -1,6 +1,16 @@
<view class="page settings-page">
<view class="card identity-card"><view class="identity-mark">微</view><view class="identity-copy"><text class="identity-title">微信身份</text><text class="identity-status">已安全关联当前账号</text></view><text class="linked-badge">已关联</text></view>
<view class="card phone-card"><view class="section-title">手机号</view><view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view><button class="wechat-phone-btn" open-type="getPhoneNumber" loading="{{binding}}" bindgetphonenumber="bindWechatPhone">微信一键{{profile.phoneVerified == 1 ? '更换' : '绑定'}}</button><view class="divider"><text>或使用短信验证码</text></view><view class="field"><input value="{{smsForm.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" /></view><view class="code-row"><input value="{{smsForm.code}}" data-field="code" bindinput="onInput" type="number" maxlength="6" placeholder="6位验证码" /><button bindtap="sendCode" disabled="{{codeLoading || countdown > 0}}">{{countdown > 0 ? countdown + 's' : '获取验证码'}}</button></view><button class="sms-bind-btn" loading="{{binding}}" bindtap="bindSmsPhone">验证并绑定</button></view>
<view class="card phone-card">
<view class="section-title">手机号</view>
<view class="phone-status"><text>{{profile.phoneVerified == 1 ? (profile.maskedPhone || profile.phone) : '尚未绑定'}}</text><text class="status-tag {{profile.phoneVerified == 1 ? 'done' : ''}}">{{profile.phoneVerified == 1 ? '已验证' : '待绑定'}}</text></view>
<button class="wechat-phone-btn" open-type="getPhoneNumber" loading="{{binding}}" bindgetphonenumber="bindWechatPhone">微信一键{{profile.phoneVerified == 1 ? '更换' : '绑定'}}</button>
<view class="sms-entry" bindtap="toggleSms"><text>{{profile.phoneVerified == 1 ? '使用短信验证码更换' : '使用短信验证码绑定'}}</text><text class="sms-arrow {{smsExpanded ? 'expanded' : ''}}">›</text></view>
<view wx:if="{{smsExpanded}}" class="sms-panel">
<view class="field"><input value="{{smsForm.phone}}" data-field="phone" bindinput="onInput" type="number" maxlength="11" placeholder="请输入手机号" /></view>
<view class="code-row"><input value="{{smsForm.code}}" data-field="code" bindinput="onInput" type="number" maxlength="6" placeholder="6位验证码" /><button bindtap="sendCode" disabled="{{codeLoading || countdown > 0}}">{{countdown > 0 ? countdown + 's' : '获取验证码'}}</button></view>
<button class="sms-bind-btn" loading="{{binding}}" bindtap="bindSmsPhone">验证并绑定</button>
</view>
</view>
<view class="account-note">手机号仅用于账号安全与必要联系,不作为微信快捷登录标识。</view>
<button class="logout-btn" bindtap="logout">退出登录</button>
</view>
@@ -1,2 +1,2 @@
.settings-page { padding-top:24rpx; }.identity-card { display:flex; align-items:center; padding:26rpx; }.identity-mark { display:flex; align-items:center; justify-content:center; width:68rpx; height:68rpx; border-radius:20rpx; background:#dcebe1; color:#35634d; font-size:28rpx; font-weight:800; }.identity-copy { display:flex; flex:1; flex-direction:column; margin-left:18rpx; }.identity-title,.section-title { color:#30483c; font-size:28rpx; font-weight:800; }.identity-status { margin-top:6rpx; color:#8a9a91; font-size:21rpx; }.linked-badge,.status-tag { padding:7rpx 14rpx; border-radius:999rpx; background:#e5f2e8; color:#397055; font-size:20rpx; }
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f4f8f5; color:#425b4e; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; font-size:26rpx; line-height:80rpx; }.divider { display:flex; align-items:center; justify-content:center; margin:28rpx 0 18rpx; color:#9aa79f; font-size:20rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#35634d; }.account-note { margin:24rpx 18rpx; color:#8e9c94; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
.phone-card { margin-top:20rpx; padding:28rpx; }.phone-status { display:flex; align-items:center; justify-content:space-between; margin-top:20rpx; padding:20rpx; border-radius:14rpx; background:#f4f8f5; color:#425b4e; font-size:26rpx; }.status-tag { background:#fff0db; color:#9a682e; }.status-tag.done { background:#e5f2e8; color:#397055; }.wechat-phone-btn,.sms-bind-btn { height:80rpx; margin-top:22rpx; border-radius:14rpx; background:#35634d; color:#fff; font-size:26rpx; line-height:80rpx; }.sms-entry { display:flex; min-height:82rpx; align-items:center; margin-top:22rpx; border-top:1rpx solid #e5ebe7; color:#627269; font-size:23rpx; }.sms-arrow { margin-left:auto; color:#95a198; font-size:36rpx; transition:transform 180ms ease; }.sms-arrow.expanded { transform:rotate(90deg); }.sms-panel { padding-top:2rpx; }.field input,.code-row input { box-sizing:border-box; height:78rpx; padding:0 20rpx; border:1rpx solid #dde8e0; border-radius:12rpx; background:#f8faf8; }.code-row { display:flex; gap:12rpx; margin-top:14rpx; }.code-row input { min-width:0; flex:1; }.code-row button { width:190rpx; height:78rpx; padding:0; border-radius:12rpx; background:#e7f0ea; color:#426c57; font-size:23rpx; line-height:78rpx; }.sms-bind-btn { background:#eef4f0; color:#35634d; }.account-note { margin:24rpx 18rpx; color:#8e9c94; font-size:21rpx; line-height:1.6; }.logout-btn { margin-top:52rpx; background:transparent; color:#a24f42; font-size:25rpx; }
+20
View File
@@ -0,0 +1,20 @@
const { BRAND_CONFIG } = require('../../utils/config')
Page({
data: {
appName: BRAND_CONFIG.appName,
message: '正在安全登录…'
},
onLoad() {
this.startLogin()
},
async startLogin() {
try {
await getApp().bootstrapWechatLogin()
} catch (error) {
this.setData({ message: '登录状态检查失败,正在返回登录页…' })
}
}
})
+4
View File
@@ -0,0 +1,4 @@
{
"navigationStyle": "custom",
"backgroundColor": "#FFFFFF"
}
+5
View File
@@ -0,0 +1,5 @@
<view class="launch-page">
<image class="launch-logo" src="/assets/images/app-icon.png" mode="aspectFill"></image>
<text class="launch-name">{{appName}}</text>
<view class="launch-status"><view class="loading-dot"></view><text>{{message}}</text></view>
</view>
+6
View File
@@ -0,0 +1,6 @@
.launch-page { display:flex; min-height:100vh; box-sizing:border-box; flex-direction:column; align-items:center; justify-content:center; padding-bottom:100rpx; background:#fff; }
.launch-logo { width:196rpx; height:196rpx; border-radius:46rpx; }
.launch-name { margin-top:26rpx; color:#202522; font-size:40rpx; font-weight:800; letter-spacing:3rpx; }
.launch-status { display:flex; align-items:center; margin-top:42rpx; color:#8a918d; font-size:23rpx; }
.loading-dot { width:14rpx; height:14rpx; margin-right:14rpx; border-radius:50%; background:#2f8f78; animation:pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity:.25; transform:scale(.75); } 50% { opacity:1; transform:scale(1); } }
+27 -12
View File
@@ -1,6 +1,7 @@
const authApi = require('../../api/auth')
const auth = require('../../utils/auth')
const { BRAND_CONFIG } = require('../../utils/config')
const loginFlow = require('../../utils/login-flow')
function wxLoginCode() {
return new Promise((resolve, reject) => wx.login({
@@ -44,7 +45,17 @@ Page({
consumeAppState() {
const state = getApp().globalData.wechatLoginState
if (state) this.setData({ loginState: state })
if (!state) return
if (state.status === 'SELECT_SHOP' && state.ticket) {
this.setData({
loginState: state,
shopOptions: shopOptions(state),
loginTicket: state.ticket,
shopSelectVisible: true
})
return
}
this.setData({ loginState: state })
},
async loadAgreements() {
@@ -105,22 +116,26 @@ Page({
wx.showToast({ title: this.data.agreementError || '协议版本加载中,请稍后重试', icon: 'none' })
return false
}
if (!this.data.rememberMe) {
const confirmed = await new Promise(resolve => wx.showModal({
title: '仅本次登录',
content: '未勾选“记住我”,下次打开小程序时需要重新点击快捷登录。',
confirmText: '继续登录',
success: result => resolve(result.confirm),
fail: () => resolve(false)
}))
if (!confirmed) return false
}
return true
},
async chooseRememberMode() {
if (this.data.rememberMe) return true
return new Promise(resolve => wx.showModal({
title: '记住登录',
content: loginFlow.REMEMBER_LOGIN_PROMPT,
confirmText: '确认',
cancelText: '取消',
success: result => resolve(loginFlow.resolveRememberChoice(result)),
fail: () => resolve(null)
}))
},
async quickLogin() {
if (this.data.loading || !(await this.ensureCanLogin())) return
this.setData({ loading: true })
const rememberMe = await this.chooseRememberMode()
if (rememberMe === null) return
this.setData({ rememberMe, loading: true })
try {
const result = await authApi.wechatQuickLogin({ wxCode: await wxLoginCode(), ...this.agreementPayload() })
this.setData({ loginState: result })
+2 -2
View File
@@ -3,8 +3,8 @@
<view class="brand-area"><image class="login-logo" src="/assets/images/app-icon.png" mode="aspectFill"></image><text class="brand-name">{{appName}}</text><text class="brand-sub">Salon 门店工作台</text></view>
<view wx:if="{{loginState && loginState.status !== 'READY' && loginState.status !== 'NEW_USER'}}" class="state-line"><text class="state-title">{{loginState.status === 'PENDING_REVIEW' ? '申请审核中' : loginState.status === 'REJECTED' ? '申请需要修改' : loginState.status === 'DISABLED' ? '账号暂不可用' : loginState.status === 'ERROR' ? '连接失败' : '账号状态'}}</text><text class="state-message">{{loginState.registrationRejectReason || loginState.message}}</text></view>
<view class="action-area">
<button class="quick-btn" loading="{{loading}}" disabled="{{loading || agreementLoading}}" bindtap="quickLogin"><text class="wechat-symbol">微</text><text>微信快捷登录</text></button>
<view class="remember-row" bindtap="toggleRememberMe"><view class="check {{rememberMe ? 'checked' : ''}}">{{rememberMe ? '✓' : ''}}</view><text>记住我,下次自动登录</text></view>
<button class="quick-btn" loading="{{loading}}" disabled="{{loading || agreementLoading}}" bindtap="quickLogin"><text class="wechat-symbol">微</text><text>快捷登录</text></button>
<view class="remember-row" bindtap="toggleRememberMe"><view class="check {{rememberMe ? 'checked' : ''}}">{{rememberMe ? '✓' : ''}}</view><text>记住登录,后续可快速登录</text></view>
</view>
</view>
<view class="agreement-footer">
+85 -56
View File
@@ -3,6 +3,8 @@ const dateUtil = require('../../utils/date')
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const { uploadProfileImage } = require('../../utils/upload')
const { normalizeAvatar } = require('../../utils/profile-card')
const profileCache = require('../../utils/profile-cache')
function canCreateAppointment() {
const app = getApp()
@@ -70,8 +72,6 @@ Page({
businessStartTime: '10:00',
businessEndTime: '22:00',
artists: [],
appointments: [],
daySummaries: [],
monthDays: [],
weekDays: [],
dayLanes: [],
@@ -111,17 +111,18 @@ Page({
async refreshAccountPrompts() {
try {
const profile = await userApi.info()
const profile = await profileCache.getProfile()
const session = auth.getSession()
getApp().setSession({ ...session, userInfo: { ...(session.userInfo || {}), ...profile } })
const today = dateUtil.formatDate(new Date())
const dismissed = wx.getStorageSync(auth.PHONE_BANNER_DISMISSED_KEY)
const missingNickname = !String(profile.nickname || '').trim() || String(profile.nickname).startsWith('微信用户')
const avatar = normalizeAvatar(profile.avatar)
const skipped = wx.getStorageSync(auth.PROFILE_PROMPT_SKIPPED_KEY) === '1'
this.setData({
phoneBannerVisible: Number(profile.phoneVerified) !== 1 && dismissed !== today,
profilePromptVisible: !skipped && (missingNickname || !profile.avatar),
profileForm: { nickname: missingNickname ? '' : profile.nickname, avatar: profile.avatar || '' }
profilePromptVisible: !skipped && (missingNickname || !avatar),
profileForm: { nickname: missingNickname ? '' : profile.nickname, avatar }
})
} catch (error) {
// 资料提醒失败不影响规划数据。
@@ -164,6 +165,7 @@ Page({
this.setData({ profileSaving: true })
try {
await userApi.updateInfo({ nickname, avatar: this.data.profileForm.avatar })
profileCache.invalidate()
this.setData({ profilePromptVisible: false })
wx.showToast({ title: '资料已保存' })
} catch (error) {
@@ -175,12 +177,12 @@ Page({
switchView(event) {
this.setData({ viewMode: event.currentTarget.dataset.mode })
this.prepareView()
this.loadCalendar()
},
switchMonthDisplay(event) {
this.setData({ monthDisplayMode: event.currentTarget.dataset.mode })
this.prepareView()
},
toggleMonthRowLabel() {
@@ -194,7 +196,7 @@ Page({
selectedArtistId: id,
selectedArtistName: artist ? artist.name : '全部员工'
})
this.prepareView()
this.loadCalendar()
},
selectDate(event) {
@@ -242,38 +244,45 @@ Page({
async loadCalendar() {
const range = this.resolveRange()
const requestKey = `${range.start}|${range.end}|${this.data.selectedArtistId || ''}`
if (this._calendarInflight && this._calendarInflight.key === requestKey) {
return this._calendarInflight.promise
}
const requestId = (this._calendarRequestId || 0) + 1
this._calendarRequestId = requestId
this.setData({ loading: true })
try {
const data = await planningApi.calendar({
startDate: range.start,
endDate: range.end,
artistId: this.data.selectedArtistId || undefined
})
const promise = planningApi.calendar({
startDate: range.start,
endDate: range.end,
artistId: this.data.selectedArtistId || undefined
}).then(data => {
if (requestId !== this._calendarRequestId) return
this.applyCalendar(data)
this.setData({ calendarError: '' })
} catch (error) {
}).catch(error => {
if (requestId !== this._calendarRequestId) return
this.clearCalendarView()
this.setData({
calendarError: resolveCalendarErrorMessage(error),
selectedArtistId: '',
selectedArtistName: '全部员工'
})
wx.showToast({
title: '规划数据加载失败',
icon: 'none'
})
} finally {
this.setData({ loading: false })
}
wx.showToast({ title: '规划数据加载失败', icon: 'none' })
}).finally(() => {
if (requestId === this._calendarRequestId) this.setData({ loading: false })
if (this._calendarInflight && this._calendarInflight.promise === promise) {
this._calendarInflight = null
}
})
this._calendarInflight = { key: requestKey, promise }
return promise
},
clearCalendarView() {
this._calendarData = { artists: [], appointments: [], daySummaries: [] }
this.setData({
businessStartTime: '10:00',
businessEndTime: '22:00',
artists: [],
appointments: [],
daySummaries: [],
monthDays: [],
weekDays: [],
dayLanes: [],
@@ -302,18 +311,28 @@ Page({
},
applyCalendar(calendar) {
const artists = calendar.artists || []
this.setData({
const snapshot = {
businessStartTime: (calendar.businessStartTime || '10:00').slice(0, 5),
businessEndTime: (calendar.businessEndTime || '22:00').slice(0, 5),
artists,
appointments: calendar.appointments || [],
daySummaries: calendar.daySummaries || []
artists: Array.isArray(calendar.artists) ? calendar.artists : [],
appointments: Array.isArray(calendar.appointments) ? calendar.appointments : [],
daySummaries: Array.isArray(calendar.daySummaries) ? calendar.daySummaries : []
}
this._calendarData = snapshot
this.setData({
businessStartTime: snapshot.businessStartTime,
businessEndTime: snapshot.businessEndTime,
artists: snapshot.artists,
calendarError: '',
...this.buildViewState(snapshot)
})
this.prepareView()
},
prepareView() {
this.setData(this.buildViewState(this._calendarData))
},
buildViewState(calendar = {}) {
const current = this.data.currentDateText
const range = this.resolveRange()
const title = this.data.viewMode === 'month'
@@ -321,20 +340,30 @@ Page({
: this.data.viewMode === 'week'
? `${formatMonthDay(range.start)} - ${formatMonthDay(range.end)}`
: dateUtil.formatCnDate(current)
this.setData({
const state = {
dateTitle: title,
rangeText: this.data.viewMode === 'month' ? '月视图' : this.data.viewMode === 'week' ? '周视图' : '日视图',
weekRange: `${formatMonthDay(range.start)} - ${formatMonthDay(range.end)}`,
monthDays: this.buildMonthDays(),
weekDays: this.buildWeekDays(),
...this.buildDayView()
})
monthDays: [],
weekDays: [],
dayLanes: [],
hours: []
}
if (this.data.viewMode === 'month') {
state.monthDays = this.buildMonthDays(calendar)
return state
}
if (this.data.viewMode === 'week') {
state.weekDays = this.buildWeekDays(calendar)
return state
}
return { ...state, ...this.buildDayView(calendar) }
},
buildMonthDays() {
const summaryMap = this.summaryMap()
buildMonthDays(calendar) {
const summaryMap = this.summaryMap(calendar)
const todayText = dateUtil.formatDate(new Date())
const artistTemplate = this.data.artists.map(artist => ({
const artistTemplate = (calendar.artists || []).map(artist => ({
artistId: artist.id,
artistName: artist.name,
shortName: artist.shortName,
@@ -344,27 +373,27 @@ Page({
}))
return dateUtil.monthGrid(this.data.currentDateText).map(day => {
const summary = summaryMap[day.date] || {}
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || artistTemplate)
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || artistTemplate, calendar)
return {
...day,
isPast: day.date < todayText,
totalCount: summary.totalCount || 0,
dayStatus: summary.dayStatus || 'free',
artistCounts,
expandedBlocks: this.buildExpandedBlocks(artistCounts),
rowBlocks: this.buildRowBlocks(artistCounts)
expandedBlocks: this.data.monthDisplayMode === 'blocks' ? this.buildExpandedBlocks(artistCounts) : [],
rowBlocks: this.data.monthDisplayMode === 'rows' ? this.buildRowBlocks(artistCounts) : []
}
})
},
buildWeekDays() {
buildWeekDays(calendar) {
const start = dateUtil.startOfWeek(this.data.currentDateText)
const summaryMap = this.summaryMap()
const summaryMap = this.summaryMap(calendar)
return this.data.weekLabels.map((label, index) => {
const target = dateUtil.addDays(start, index)
const date = dateUtil.formatDate(target)
const summary = summaryMap[date] || { artistCounts: [], totalCount: 0 }
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || []).filter(count => count.count > 0)
const artistCounts = this.normalizeArtistCounts(summary.artistCounts || [], calendar).filter(count => count.count > 0)
return {
date,
weekName: `周${label}`,
@@ -379,9 +408,9 @@ Page({
})
},
buildDayView() {
const startMinute = dateUtil.minutesOfDay(this.data.businessStartTime)
const endMinute = dateUtil.minutesOfDay(this.data.businessEndTime)
buildDayView(calendar) {
const startMinute = dateUtil.minutesOfDay(calendar.businessStartTime || '10:00')
const endMinute = dateUtil.minutesOfDay(calendar.businessEndTime || '22:00')
const timelineHeight = Math.max(560, endMinute - startMinute)
const laneHeaderHeight = 54
const hours = []
@@ -393,9 +422,9 @@ Page({
})
}
const filteredArtists = this.data.selectedArtistId
? this.data.artists.filter(item => String(item.id) === String(this.data.selectedArtistId))
: this.data.artists
const dayAppointments = this.data.appointments.filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
? (calendar.artists || []).filter(item => String(item.id) === String(this.data.selectedArtistId))
: (calendar.artists || [])
const dayAppointments = (calendar.appointments || []).filter(item => resolveAppointmentDate(item) === this.data.currentDateText)
const lanes = filteredArtists.map(artist => {
const blocks = dayAppointments
.filter(item => String(item.artistId) === String(artist.id))
@@ -424,15 +453,15 @@ Page({
}
},
summaryMap() {
return (this.data.daySummaries || []).reduce((map, item) => {
summaryMap(calendar) {
return (calendar.daySummaries || []).reduce((map, item) => {
map[item.date] = item
return map
}, {})
},
normalizeArtistCounts(counts) {
const colorMap = this.data.artists.reduce((map, artist) => {
normalizeArtistCounts(counts, calendar) {
const colorMap = (calendar.artists || []).reduce((map, artist) => {
map[artist.id] = artist
return map
}, {})
@@ -496,7 +525,7 @@ Page({
},
async quickUpdateStatus(event) {
const appointment = this.data.appointments.find(item => String(item.orderItemId) === String(event.currentTarget.dataset.id))
const appointment = (this._calendarData && this._calendarData.appointments || []).find(item => String(item.orderItemId) === String(event.currentTarget.dataset.id))
if (!appointment) return
try {
await planningApi.updateStatus(appointment.orderId, Number(event.currentTarget.dataset.status))
@@ -512,7 +541,7 @@ Page({
},
quickCancel(event) {
const appointment = this.data.appointments.find(item => String(item.orderItemId) === String(event.currentTarget.dataset.id))
const appointment = (this._calendarData && this._calendarData.appointments || []).find(item => String(item.orderItemId) === String(event.currentTarget.dataset.id))
if (!appointment) return
wx.showModal({
title: '取消预约',
@@ -0,0 +1,77 @@
const assert = require('assert')
const planningApi = require('../../api/planning')
global.wx = {
getAccountInfoSync: () => ({ miniProgram: { envVersion: 'develop' } }),
getDeviceInfo: () => ({ platform: 'devtools' }),
getStorageSync: () => '',
setStorageSync: () => {},
removeStorageSync: () => {},
showToast: () => {}
}
global.getApp = () => ({ globalData: { userInfo: {} } })
let definition
global.Page = value => { definition = value }
require('./index')
function createPage(data = {}) {
const page = {
...definition,
data: { ...definition.data, ...data },
setData(values) {
Object.entries(values).forEach(([key, value]) => {
if (!key.includes('.')) {
this.data[key] = value
return
}
const parts = key.split('.')
let target = this.data
for (let index = 0; index < parts.length - 1; index += 1) {
target = target[parts[index]]
}
target[parts[parts.length - 1]] = value
})
}
}
return page
}
async function run() {
const page = createPage({ viewMode: 'week' })
let monthBuilds = 0
let weekBuilds = 0
let dayBuilds = 0
page.buildMonthDays = () => { monthBuilds += 1; return [] }
page.buildWeekDays = () => { weekBuilds += 1; return [] }
page.buildDayView = () => { dayBuilds += 1; return {} }
page.buildViewState({ artists: [], appointments: [], daySummaries: [] })
assert.deepStrictEqual([monthBuilds, weekBuilds, dayBuilds], [0, 1, 0])
page.data.viewMode = 'month'
page.data.monthDisplayMode = 'count'
const monthDays = definition.buildMonthDays.call(page, {
artists: [{ id: 1, name: '员工', shortName: '员', color: '#000' }],
daySummaries: []
})
assert.strictEqual(monthDays.length, 42)
assert.strictEqual(monthDays.every(item => item.expandedBlocks.length === 0 && item.rowBlocks.length === 0), true)
const requestPage = createPage({ viewMode: 'day', currentDateText: '2026-10-11' })
let calendarRequests = 0
let resolveCalendar
planningApi.calendar = () => {
calendarRequests += 1
return new Promise(resolve => { resolveCalendar = resolve })
}
const requestOne = requestPage.loadCalendar()
const requestTwo = requestPage.loadCalendar()
assert.strictEqual(calendarRequests, 1)
resolveCalendar({ artists: [], appointments: [], daySummaries: [] })
await Promise.all([requestOne, requestTwo])
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
+4 -4
View File
@@ -25,7 +25,6 @@
.control-card {
padding: 18rpx;
animation: pageFadeIn 180ms ease both;
}
.calendar-error-card {
@@ -297,13 +296,14 @@
border-left: 8rpx solid #7ba7c7;
border-radius: 10px;
background: #fff7ee;
box-shadow: 0 8rpx 16rpx rgba(58, 48, 34, 0.08);
transition: transform 160ms ease, box-shadow 160ms ease;
border-top: 1rpx solid rgba(58, 48, 34, 0.06);
border-right: 1rpx solid rgba(58, 48, 34, 0.06);
border-bottom: 1rpx solid rgba(58, 48, 34, 0.06);
transition: transform 160ms ease;
}
.appointment-block:active {
transform: scale(0.98);
box-shadow: 0 4rpx 10rpx rgba(58, 48, 34, 0.08);
}
.appointment-block.pending {
+178
View File
@@ -0,0 +1,178 @@
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const { chooseImageFilePath, uploadProfileImage } = require('../../utils/upload')
const { buildProfileCard, normalizeAvatar } = require('../../utils/profile-card')
const { BRAND_CONFIG } = require('../../utils/config')
const profileCache = require('../../utils/profile-cache')
function resolveRoleText(type) {
const role = Number(type)
if (role === 2) return '店长'
if (role === 3) return '美甲师'
if (role === 4) return '管理员'
return '管理端'
}
function buildPageState(profile, fallbackShopName) {
const source = profile || {}
const card = buildProfileCard(source, fallbackShopName)
return {
profile: source,
avatarText: card.avatarText,
roleText: resolveRoleText(source.type),
shopName: card.shopName,
phoneDisplay: source.maskedPhone || source.phone || '未绑定',
form: {
nickname: source.nickname || '',
avatar: normalizeAvatar(source.avatar),
wechatId: source.wechatId || '',
signature: source.signature || ''
}
}
}
Page({
data: {
loading: true,
saving: false,
avatarUploading: false,
profile: {},
avatarText: '用',
roleText: '管理端',
shopName: BRAND_CONFIG.defaultShopName,
phoneDisplay: '未绑定',
form: { nickname: '', avatar: '', wechatId: '', signature: '' }
},
onLoad() {
const app = getApp()
const state = buildPageState(app.globalData.userInfo || {}, app.globalData.shopName || BRAND_CONFIG.defaultShopName)
this.setData(state)
this.loadProfile()
},
onShow() {
if (!this._refreshAfterAccountSettings) return
this._refreshAfterAccountSettings = false
this.loadProfile()
},
async loadProfile(options = {}) {
this.setData({ loading: true })
try {
const profile = await profileCache.getProfile(options)
this.syncProfileToSession(profile)
} catch (error) {
wx.showToast({ title: error.message || '个人信息加载失败', icon: 'none' })
} finally {
this.setData({ loading: false })
}
},
syncProfileToSession(profile) {
const app = getApp()
const session = auth.getSession()
const current = session.userInfo || app.globalData.userInfo || {}
const next = {
...current,
...profile,
nickname: profile.nickname || '',
avatar: profile.avatar || '',
contactPhone: profile.contactPhone || '',
wechatId: profile.wechatId || '',
signature: profile.signature || '',
shopName: profile.shopName || current.shopName || session.shopName || app.globalData.shopName || ''
}
app.setSession({ ...session, shopName: next.shopName || session.shopName, userInfo: next })
this.setData(buildPageState(next, app.globalData.shopName || BRAND_CONFIG.defaultShopName))
},
onInput(event) {
const field = event.currentTarget.dataset.field
const value = event.detail.value
const nextData = { [`form.${field}`]: value }
if (field === 'nickname') {
nextData.avatarText = Array.from(String(value || '').trim())[0] || '用'
}
this.setData(nextData)
},
onWechatNicknameInput(event) {
const nickname = event.detail.value
this.setData({
'form.nickname': nickname,
avatarText: Array.from(String(nickname || '').trim())[0] || '用'
})
},
goAccountSettings() {
this._refreshAfterAccountSettings = true
wx.navigateTo({
url: '/pages/account-settings/index',
fail: () => { this._refreshAfterAccountSettings = false }
})
},
async uploadAvatar(filePath) {
if (!filePath) return
const previousAvatar = this.data.form.avatar
this.setData({ avatarUploading: true, 'form.avatar': filePath })
try {
const avatar = await uploadProfileImage(filePath)
this.setData({ 'form.avatar': avatar })
} catch (error) {
this.setData({ 'form.avatar': previousAvatar })
throw error
} finally {
this.setData({ avatarUploading: false })
}
},
async chooseAvatar() {
if (this.data.loading || this.data.avatarUploading || this.data.saving) return
try {
const filePath = await chooseImageFilePath()
if (!filePath) return
await this.uploadAvatar(filePath)
} catch (error) {
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
}
},
async chooseWechatAvatar(event) {
if (this.data.loading || this.data.avatarUploading || this.data.saving) return
try {
await this.uploadAvatar(event.detail && event.detail.avatarUrl)
} catch (error) {
wx.showToast({ title: error.message || '微信头像获取失败', icon: 'none' })
}
},
async save() {
if (this.data.saving || this.data.avatarUploading) return
const form = this.data.form
const nickname = String(form.nickname || '').trim()
if (!nickname) {
wx.showToast({ title: '请填写昵称', icon: 'none' })
return
}
this.setData({ saving: true })
try {
await userApi.updateInfo({
nickname,
avatar: form.avatar || '',
wechatId: String(form.wechatId || '').trim(),
signature: String(form.signature || '').trim()
})
profileCache.invalidate()
const profile = await profileCache.getProfile({ force: true })
this.syncProfileToSession(profile)
wx.showToast({ title: '已保存', icon: 'success' })
setTimeout(() => wx.navigateBack(), 350)
} catch (error) {
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
} finally {
this.setData({ saving: false })
}
}
})
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "个人信息"
}
@@ -0,0 +1,44 @@
<view class="page no-tab profile-edit-page">
<view wx:if="{{loading}}" class="loading-line">正在加载个人信息...</view>
<view class="card avatar-card">
<view class="avatar-preview" bindtap="chooseAvatar">
<image wx:if="{{form.avatar}}" src="{{form.avatar}}" mode="aspectFill"></image>
<text wx:else class="avatar-letter">{{avatarText}}</text>
<view class="avatar-change-tip">{{avatarUploading ? '上传中' : '点击更换'}}</view>
</view>
<view class="avatar-copy">
<text class="avatar-title">{{form.nickname || '未设置昵称'}}</text>
<text class="avatar-signature">{{form.signature || '暂无个性签名'}}</text>
</view>
</view>
<view class="wechat-data-actions">
<button class="wechat-data-action" open-type="chooseAvatar" disabled="{{loading || saving || avatarUploading}}" bindchooseavatar="chooseWechatAvatar">
<!-- <view class="wechat-action-mark">像</view> -->
<text>{{avatarUploading ? '头像上传中' : '使用微信头像'}}</text>
</button>
<view class="wechat-data-action nickname-action {{loading || saving || avatarUploading ? 'disabled' : ''}}">
<!-- <view class="wechat-action-mark">昵</view> -->
<text>使用微信昵称</text>
<input class="wechat-nickname-trigger" type="nickname" value="{{form.nickname}}" disabled="{{loading || saving || avatarUploading}}" bindinput="onWechatNicknameInput" />
</view>
</view>
<view class="section-title">基本资料</view>
<view class="card form-card">
<view class="field"><text class="field-label required">昵称</text><input value="{{form.nickname}}" data-field="nickname" bindinput="onInput" maxlength="30" placeholder="请输入昵称" /></view>
<view class="field phone-field" bindtap="goAccountSettings"><text class="field-label">手机号</text><view class="phone-value"><text>{{phoneDisplay}}</text><text class="phone-arrow">›</text></view></view>
<view class="field"><text class="field-label">微信号</text><input value="{{form.wechatId}}" data-field="wechatId" bindinput="onInput" maxlength="50" placeholder="请输入微信号" /></view>
<view class="field signature-field"><text class="field-label">个性签名</text><textarea value="{{form.signature}}" data-field="signature" bindinput="onInput" maxlength="200" placeholder="请输入个人签名" /></view>
</view>
<view class="section-title account-title">账号信息</view>
<view class="card readonly-card">
<view class="readonly-row"><text>登录账号</text><text>{{profile.account || '未设置'}}</text></view>
<view class="readonly-row"><text>所属门店</text><text>{{shopName}}</text></view>
<view class="readonly-row"><text>身份</text><text>{{roleText}}</text></view>
</view>
<view class="fixed-bottom"><button class="primary-btn" loading="{{saving}}" disabled="{{loading || avatarUploading}}" bindtap="save">保存个人信息</button></view>
</view>
@@ -0,0 +1,31 @@
.profile-edit-page { padding-top:24rpx; }
.loading-line { margin-bottom:16rpx; color:#8e9c94; font-size:22rpx; text-align:center; }
.avatar-card { display:flex; align-items:center; padding:26rpx; }
.avatar-preview { position:relative; display:flex; width:112rpx; height:112rpx; flex:none; align-items:center; justify-content:center; overflow:hidden; border-radius:28rpx; background:#6f8f83; color:#fff; font-size:40rpx; font-weight:900; }
.avatar-preview image { width:100%; height:100%; }
.avatar-letter { line-height:1; }
.avatar-change-tip { position:absolute; right:0; bottom:0; left:0; height:34rpx; background:rgba(35,42,39,.62); color:#fff; font-size:17rpx; font-weight:500; line-height:34rpx; text-align:center; }
.avatar-copy { display:flex; min-width:0; flex:1; flex-direction:column; margin-left:20rpx; }
.avatar-title { color:#30483c; font-size:30rpx; font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.avatar-signature { margin-top:10rpx; color:#8a9a91; font-size:22rpx; line-height:1.5; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wechat-data-actions { display:flex; gap:16rpx; margin-top:20rpx; }
.wechat-data-action { position:relative; display:flex; width:auto; min-width:0; height:84rpx; flex:1; align-items:center; justify-content:center; padding:0 18rpx; overflow:hidden; border:1rpx solid rgba(53,99,77,.08); border-radius:18rpx; background:#fffdf8; color:#30483c; font-size:24rpx; font-weight:800; box-shadow:0 8rpx 22rpx rgba(58,48,34,.05); }
.wechat-data-action.disabled { opacity:.55; }
.wechat-action-mark { display:flex; width:40rpx; height:40rpx; flex:none; align-items:center; justify-content:center; margin-right:12rpx; border-radius:12rpx; background:#dcebe1; color:#35634d; font-size:18rpx; }
.nickname-action { box-sizing:border-box; }
.wechat-nickname-trigger { position:absolute; z-index:2; top:0; right:0; bottom:0; left:0; width:100%; height:100%; opacity:0; }
.section-title { margin:30rpx 4rpx 14rpx; }
.form-card { padding:0 24rpx; }
.field-label { width:170rpx; }
.field input,.field textarea { text-align:right; }
.phone-value { display:flex; min-width:0; flex:1; align-items:center; justify-content:flex-end; color:#7f776f; font-size:27rpx; }
.phone-arrow { margin-left:14rpx; color:#aaa198; font-size:38rpx; }
.signature-field { align-items:flex-start; }
.signature-field .field-label { padding-top:34rpx; }
.signature-field textarea { text-align:left; }
.account-title { margin-top:26rpx; }
.readonly-card { padding:0 24rpx; }
.readonly-row { display:flex; min-height:92rpx; align-items:center; justify-content:space-between; gap:30rpx; border-bottom:1rpx solid #eee8df; font-size:25rpx; }
.readonly-row:last-child { border-bottom:0; }
.readonly-row text:first-child { color:#625c55; font-weight:700; }
.readonly-row text:last-child { min-width:0; color:#8a837b; text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
+21 -144
View File
@@ -1,11 +1,8 @@
const { BRAND_CONFIG } = require('../../utils/config')
const userApi = require('../../api/user')
const auth = require('../../utils/auth')
const { chooseImageFilePath, uploadProfileImage } = require('../../utils/upload')
const planningApi = require('../../api/planning')
const employeesApi = require('../../api/employees')
const shopApi = require('../../api/shop')
const dateUtil = require('../../utils/date')
const { buildProfileCard } = require('../../utils/profile-card')
const profileCache = require('../../utils/profile-cache')
function resolveRoleText(type) {
const role = Number(type)
@@ -17,20 +14,8 @@ function resolveRoleText(type) {
Page({
data: {
shopName: BRAND_CONFIG.defaultShopName,
phone: '店长端',
roleText: '管理端',
userInfo: {},
editModalVisible: false,
profileSaving: false,
avatarUploading: false,
profileForm: {
nickname: '',
avatar: '',
contactPhone: '',
wechatId: '',
signature: ''
},
profileCard: buildProfileCard({}, BRAND_CONFIG.defaultShopName),
overviewLoading: false,
overview: {
date: '',
@@ -43,7 +28,7 @@ Page({
shopStatus: '营业中'
},
menus: [
{ title: '个人信息', action: 'editProfile' },
{ title: '个人信息', url: '/pages/profile-edit/index' },
{ title: '账号设置', url: '/pages/account-settings/index' },
{ title: '店铺设置', url: '/pages/shop-settings/index' },
{ title: '数据导出', url: '/pages/export/index' },
@@ -58,36 +43,19 @@ Page({
},
async loadOverview() {
const today = dateUtil.formatDate(new Date())
this.setData({ overviewLoading: true })
try {
const [calendar, shop] = await Promise.all([
planningApi.calendar({ startDate: today, endDate: today }),
shopApi.settings()
])
const appointments = Array.isArray(calendar.appointments) ? calendar.appointments : []
const now = Date.now()
const upcomingAppointments = appointments.filter(item => {
const appointmentTime = new Date(String(item.appointmentTime || item.startTime || '').replace(/-/g, '/')).getTime()
return Number.isFinite(appointmentTime) && appointmentTime >= now
}).length
const artists = Array.isArray(calendar.artists) ? calendar.artists : []
const scheduleRules = await Promise.all(artists.map(artist => employeesApi.scheduleRule({ artistId: artist.id })))
const scheduleExceptions = scheduleRules.reduce((total, setting) => {
const exceptions = Array.isArray(setting && setting.exceptions) ? setting.exceptions : []
return total + exceptions.filter(item => item.workDate === today).length
}, 0)
const shopOpen = Number(shop && shop.status) !== 0
const overview = await planningApi.todayOverview()
this.setData({
overview: {
date: `${today.slice(5, 7)}月${today.slice(8, 10)}日`,
todayAppointments: appointments.length,
pendingAppointments: appointments.filter(item => Number(item.status) === 0).length,
upcomingAppointments,
availableEmployees: artists.filter(item => Number(item.status) !== 0).length,
scheduleExceptions,
shopOpen,
shopStatus: shopOpen ? '营业中' : '已暂停'
date: overview.date || '',
todayAppointments: Number(overview.todayAppointments || 0),
pendingAppointments: Number(overview.pendingAppointments || 0),
upcomingAppointments: Number(overview.upcomingAppointments || 0),
availableEmployees: Number(overview.availableEmployees || 0),
scheduleExceptions: Number(overview.scheduleExceptions || 0),
shopOpen: overview.shopOpen !== false,
shopStatus: overview.shopStatus || (overview.shopOpen === false ? '已暂停' : '营业中')
}
})
} catch (error) {
@@ -109,26 +77,20 @@ Page({
refreshFromSession() {
const app = getApp()
const userInfo = app.globalData.userInfo || {}
const fallbackShopName = app.globalData.shopName || BRAND_CONFIG.defaultShopName
this.setData({
shopName: app.globalData.shopName || BRAND_CONFIG.appName,
phone: userInfo.contactPhone || userInfo.phone || userInfo.account || '店长端',
roleText: resolveRoleText(userInfo.type),
userInfo
profileCard: buildProfileCard(userInfo, fallbackShopName)
})
},
go(event) {
const action = event.currentTarget.dataset.action
if (action === 'editProfile') {
this.openEditProfile()
return
}
wx.navigateTo({ url: event.currentTarget.dataset.url })
},
async loadProfile() {
try {
const profile = await userApi.info()
const profile = await profileCache.getProfile()
this.syncProfileToSession(profile)
} catch (error) {
wx.showToast({ title: error.message || '个人信息加载失败', icon: 'none' })
@@ -152,102 +114,17 @@ Page({
wechatId: profile.wechatId || '',
signature: profile.signature || '',
type: profile.type || currentUserInfo.type,
shopId: profile.shopId || currentUserInfo.shopId
shopId: profile.shopId || currentUserInfo.shopId,
shopName: profile.shopName || currentUserInfo.shopName || session.shopName || app.globalData.shopName || ''
}
app.setSession({
...session,
shopName: nextUserInfo.shopName || session.shopName,
userInfo: nextUserInfo
})
this.setData({
userInfo: nextUserInfo,
phone: nextUserInfo.contactPhone || nextUserInfo.phone || nextUserInfo.account || '店长端',
roleText: resolveRoleText(nextUserInfo.type)
roleText: resolveRoleText(nextUserInfo.type),
profileCard: buildProfileCard(nextUserInfo, BRAND_CONFIG.defaultShopName)
})
},
openEditProfile() {
const userInfo = this.data.userInfo || {}
this.setData({
editModalVisible: true,
profileForm: {
nickname: userInfo.nickname || '',
avatar: userInfo.avatar || '',
contactPhone: userInfo.contactPhone || '',
wechatId: userInfo.wechatId || '',
signature: userInfo.signature || ''
}
})
},
closeEditProfile() {
if (this.data.profileSaving || this.data.avatarUploading) {
return
}
this.setData({ editModalVisible: false })
},
stopTap() {
},
onProfileInput(event) {
const field = event.currentTarget.dataset.field
this.setData({
[`profileForm.${field}`]: event.detail.value
})
},
async chooseProfileAvatar() {
if (this.data.avatarUploading || this.data.profileSaving) {
return
}
try {
const filePath = await chooseImageFilePath()
if (!filePath) {
return
}
this.setData({ avatarUploading: true })
const avatar = await uploadProfileImage(filePath)
this.setData({ 'profileForm.avatar': avatar })
} catch (error) {
wx.showToast({ title: error.message || '头像上传失败', icon: 'none' })
} finally {
this.setData({ avatarUploading: false })
}
},
removeProfileAvatar() {
this.setData({ 'profileForm.avatar': '' })
},
async saveProfile() {
const form = this.data.profileForm
const nickname = String(form.nickname || '').trim()
const contactPhone = String(form.contactPhone || '').trim()
if (contactPhone && !/^1[3-9]\d{9}$/.test(contactPhone)) {
wx.showToast({ title: '请输入正确联系电话', icon: 'none' })
return
}
if (!nickname) {
wx.showToast({ title: '请填写昵称', icon: 'none' })
return
}
this.setData({ profileSaving: true })
try {
await userApi.updateInfo({
nickname,
avatar: form.avatar || '',
contactPhone,
wechatId: String(form.wechatId || '').trim(),
signature: String(form.signature || '').trim()
})
const profile = await userApi.info()
this.syncProfileToSession(profile)
this.setData({ editModalVisible: false })
wx.showToast({ title: '已保存', icon: 'success' })
} catch (error) {
wx.showToast({ title: error.message || '保存失败', icon: 'none' })
} finally {
this.setData({ profileSaving: false })
}
}
})
+7 -49
View File
@@ -1,10 +1,13 @@
<view class="page">
<view class="card profile-card">
<view class="profile-main">
<view class="shop-logo">指</view>
<view class="account-avatar">
<image wx:if="{{profileCard.avatar}}" src="{{profileCard.avatar}}" mode="aspectFill"></image>
<text wx:else>{{profileCard.avatarText}}</text>
</view>
<view class="profile-copy">
<text class="shop-name">{{shopName}}</text>
<text class="phone">{{phone}}</text>
<text class="profile-name">{{profileCard.nickname}}</text>
<text class="profile-shop">{{profileCard.shopName}}</text>
</view>
</view>
<text class="role-badge">{{roleText}}</text>
@@ -46,55 +49,10 @@
</view>
<view class="section menu-list card">
<view wx:for="{{menus}}" wx:key="title" class="menu-row" data-url="{{item.url}}" data-action="{{item.action}}" bindtap="go">
<view wx:for="{{menus}}" wx:key="title" class="menu-row" data-url="{{item.url}}" bindtap="go">
<text>{{item.title}}</text>
<text class="arrow">›</text>
</view>
</view>
<view wx:if="{{editModalVisible}}" class="modal-mask" bindtap="closeEditProfile">
<view class="profile-modal" catchtap="stopTap">
<view class="modal-head">
<text class="modal-title">个人信息</text>
<view class="modal-close" bindtap="closeEditProfile">×</view>
</view>
<view class="profile-avatar-row">
<view wx:if="{{profileForm.avatar}}" class="profile-avatar image-avatar">
<image src="{{profileForm.avatar}}" mode="aspectFill"></image>
</view>
<view wx:else class="profile-avatar">头像</view>
<button class="secondary-btn avatar-btn" loading="{{avatarUploading}}" bindtap="chooseProfileAvatar">上传头像</button>
<button wx:if="{{profileForm.avatar}}" class="text-btn avatar-remove" bindtap="removeProfileAvatar">移除</button>
</view>
<view class="modal-field">
<text class="required-label">昵称</text>
<input value="{{profileForm.nickname}}" data-field="nickname" bindinput="onProfileInput" placeholder="请输入昵称" />
</view>
<view class="modal-field readonly-field">
<text>登录账号</text>
<view>{{userInfo.account || '未设置'}}</view>
</view>
<view class="modal-field readonly-field">
<text>身份</text>
<view>{{roleText}}</view>
</view>
<view class="modal-field readonly-field">
<text>登录手机号</text>
<view>{{userInfo.phone || '未绑定'}}</view>
</view>
<view class="modal-field">
<text>联系电话</text>
<input value="{{profileForm.contactPhone}}" data-field="contactPhone" bindinput="onProfileInput" type="number" maxlength="11" placeholder="请输入联系电话" />
</view>
<view class="modal-field">
<text>微信号</text>
<input value="{{profileForm.wechatId}}" data-field="wechatId" bindinput="onProfileInput" placeholder="请输入微信号" />
</view>
<view class="modal-field">
<text>签名</text>
<textarea value="{{profileForm.signature}}" data-field="signature" bindinput="onProfileInput" placeholder="请输入个人签名" />
</view>
<button class="primary-btn modal-submit" loading="{{profileSaving}}" bindtap="saveProfile">保存个人信息</button>
</view>
</view>
</view>
+11 -174
View File
@@ -17,13 +17,14 @@
min-width: 0;
}
.shop-logo {
.account-avatar {
display: flex;
align-items: center;
justify-content: center;
flex-shrink: 0;
width: 96rpx;
height: 96rpx;
overflow: hidden;
border-radius: 24rpx;
background: #6f8f83;
color: #fff;
@@ -31,12 +32,17 @@
font-weight: 900;
}
.shop-name,
.phone {
.account-avatar image {
width: 100%;
height: 100%;
}
.profile-name,
.profile-shop {
display: block;
}
.shop-name {
.profile-name {
font-size: 34rpx;
font-weight: 800;
overflow: hidden;
@@ -44,7 +50,7 @@
white-space: nowrap;
}
.phone {
.profile-shop {
margin-top: 8rpx;
color: #91897f;
font-size: 24rpx;
@@ -171,172 +177,3 @@
color: #b0a79e;
font-size: 44rpx;
}
.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);
animation: maskIn 180ms ease both;
}
.profile-modal {
width: 100%;
max-height: 88vh;
overflow-y: auto;
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);
animation: modalUp 220ms ease both;
}
.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-radius: 50%;
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);
}
.profile-avatar-row {
display: flex;
align-items: center;
gap: 16rpx;
margin-bottom: 18rpx;
padding: 18rpx;
border-radius: 18rpx;
background: #f7efe7;
}
.profile-avatar {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
width: 92rpx;
height: 92rpx;
overflow: hidden;
border-radius: 50%;
background: #6f8f83;
color: #fff;
font-size: 24rpx;
font-weight: 900;
}
.profile-avatar image {
width: 100%;
height: 100%;
}
.avatar-btn {
flex: 1;
min-width: 0;
max-width: none;
}
.avatar-remove {
flex: 0 0 auto;
}
.modal-field {
margin-bottom: 16rpx;
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,
.modal-field textarea,
.readonly-field view {
width: 100%;
color: #2c2722;
font-size: 28rpx;
}
.modal-field input,
.readonly-field view {
min-height: 58rpx;
line-height: 58rpx;
}
.modal-field textarea {
min-height: 120rpx;
}
.readonly-field view {
color: #7f756b;
}
.modal-submit {
margin-top: 22rpx;
}
@keyframes maskIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes modalUp {
from {
transform: translateY(40rpx);
}
to {
transform: translateY(0);
}
}
+17
View File
@@ -0,0 +1,17 @@
const REMEMBER_LOGIN_PROMPT = '是否保存登录状态,后续可快速登录'
function shouldAutoLogin(preference, status) {
return Boolean(preference && preference.rememberMe && status && status.status === 'READY')
}
function resolveRememberChoice(modalResult) {
if (modalResult && modalResult.confirm) return true
if (modalResult && modalResult.cancel) return false
return null
}
module.exports = {
REMEMBER_LOGIN_PROMPT,
shouldAutoLogin,
resolveRememberChoice
}
+13
View File
@@ -0,0 +1,13 @@
const assert = require('assert')
const loginFlow = require('./login-flow')
assert.strictEqual(loginFlow.REMEMBER_LOGIN_PROMPT, '是否保存登录状态,后续可快速登录')
assert.strictEqual(loginFlow.shouldAutoLogin({ rememberMe: true }, { status: 'READY' }), true)
assert.strictEqual(loginFlow.shouldAutoLogin({ rememberMe: false }, { status: 'READY' }), false)
assert.strictEqual(loginFlow.shouldAutoLogin({ rememberMe: true }, { status: 'PENDING_REVIEW' }), false)
assert.strictEqual(loginFlow.shouldAutoLogin({}, null), false)
assert.strictEqual(loginFlow.resolveRememberChoice({ confirm: true, cancel: false }), true)
assert.strictEqual(loginFlow.resolveRememberChoice({ confirm: false, cancel: true }), false)
assert.strictEqual(loginFlow.resolveRememberChoice({ confirm: false, cancel: false }), null)
assert.strictEqual(loginFlow.resolveRememberChoice(null), null)
+52
View File
@@ -0,0 +1,52 @@
const userApi = require('../api/user')
const DEFAULT_TTL_MS = 30 * 1000
let cachedProfile = null
let expiresAt = 0
let pendingRequest = null
function getProfile(options = {}) {
const force = options.force === true
const ttlMs = Number.isFinite(options.ttlMs) ? Math.max(0, options.ttlMs) : DEFAULT_TTL_MS
const now = Date.now()
if (!force && cachedProfile && now < expiresAt) {
return Promise.resolve(cachedProfile)
}
if (pendingRequest) return pendingRequest
pendingRequest = userApi.info()
.then(profile => {
cachedProfile = profile || {}
expiresAt = Date.now() + ttlMs
return cachedProfile
})
.finally(() => {
pendingRequest = null
})
return pendingRequest
}
function setProfile(profile, ttlMs = DEFAULT_TTL_MS) {
cachedProfile = profile || {}
expiresAt = Date.now() + Math.max(0, ttlMs)
return cachedProfile
}
function invalidate() {
cachedProfile = null
expiresAt = 0
}
function resetForTest() {
invalidate()
pendingRequest = null
}
module.exports = {
DEFAULT_TTL_MS,
getProfile,
setProfile,
invalidate,
resetForTest
}
@@ -0,0 +1,40 @@
const assert = require('assert')
const userApi = require('../api/user')
const profileCache = require('./profile-cache')
async function run() {
let requests = 0
let resolver
userApi.info = () => {
requests += 1
return new Promise(resolve => { resolver = resolve })
}
profileCache.resetForTest()
const first = profileCache.getProfile()
const second = profileCache.getProfile()
assert.strictEqual(requests, 1)
resolver({ id: 1, nickname: '甲屿' })
assert.deepStrictEqual(await first, { id: 1, nickname: '甲屿' })
assert.deepStrictEqual(await second, { id: 1, nickname: '甲屿' })
await profileCache.getProfile()
assert.strictEqual(requests, 1)
userApi.info = async () => {
requests += 1
return { id: 1, nickname: '新昵称' }
}
profileCache.invalidate()
assert.strictEqual((await profileCache.getProfile()).nickname, '新昵称')
assert.strictEqual(requests, 2)
profileCache.setProfile({ id: 2 }, 0)
await profileCache.getProfile()
assert.strictEqual(requests, 3)
}
run().catch(error => {
console.error(error)
process.exitCode = 1
})
+25
View File
@@ -0,0 +1,25 @@
const DEFAULT_AVATAR_URL = 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png'
function cleanText(value) {
return String(value || '').trim()
}
function normalizeAvatar(value) {
const avatar = cleanText(value)
return avatar === DEFAULT_AVATAR_URL ? '' : avatar
}
function buildProfileCard(userInfo, fallbackShopName) {
const user = userInfo || {}
const nickname = cleanText(user.nickname) || cleanText(user.account) || '未设置昵称'
const shopName = cleanText(user.shopName) || cleanText(fallbackShopName) || '未设置门店'
return {
avatar: normalizeAvatar(user.avatar),
avatarText: Array.from(nickname)[0] || '用',
nickname,
shopName
}
}
module.exports = { DEFAULT_AVATAR_URL, buildProfileCard, normalizeAvatar }
@@ -0,0 +1,31 @@
const assert = require('assert')
const { DEFAULT_AVATAR_URL, buildProfileCard, normalizeAvatar } = require('./profile-card')
assert.deepStrictEqual(buildProfileCard({
nickname: '小屿',
avatar: 'https://example.com/avatar.png',
shopName: '甲屿中心店'
}, '默认门店'), {
avatar: 'https://example.com/avatar.png',
avatarText: '小',
nickname: '小屿',
shopName: '甲屿中心店'
})
assert.deepStrictEqual(buildProfileCard({ account: 'manager01' }, '默认门店'), {
avatar: '',
avatarText: 'm',
nickname: 'manager01',
shopName: '默认门店'
})
assert.deepStrictEqual(buildProfileCard({}, ''), {
avatar: '',
avatarText: '未',
nickname: '未设置昵称',
shopName: '未设置门店'
})
assert.strictEqual(normalizeAvatar(DEFAULT_AVATAR_URL), '')
assert.strictEqual(buildProfileCard({ nickname: '小屿', avatar: DEFAULT_AVATAR_URL }, '中心店').avatar, '')
@@ -35,3 +35,13 @@
- 问题:旧记忆和交接文档仍记录“新增表字段后同步更新初始化 SQL”。
- 原因:`0.0.1` 前的上线基线阶段曾把历史 SQL 合并回唯一初始化脚本。
- 处理:初始化入口按端侧拆分;后续变更通过版本化 SQL 与 `docs/scripts/` 中的说明文件迭代。
## 2026-10-10 Salon 基线重整例外
经项目负责人明确要求,将 `docs/scripts/sql/` 下截至 2026-10-10 的全部 Salon 版本 SQL
最终状态重新合并到 `docs/scripts/sql/init/jayucloud-salon.sql`,解决仅执行初始化 SQL 的空库
缺少工作台注册审核表和短信供应商参数的问题。
本次只重整空库基线;经项目负责人确认,已经完整合入初始化基线的历史版本 SQL 已删除,
避免同一结构和种子配置存在多个执行入口。完成本次重整后,后续数据库变更仍遵循上述冻结规则,
除非项目负责人再次明确要求重整初始化基线。
@@ -0,0 +1,35 @@
# Gitea 环境分支保护配置说明
日期:2026-10-12
## 目的
JayuCloud 的环境分支按以下唯一链路晋级:
```text
dev -> sit -> prod
```
`sit` 和 `prod` 禁止任何用户(包括管理员)直接推送、强制推送或通过网页直接修改。`sit` 只接受 `dev` 来源的拉取请求,`prod` 只接受 `sit` 来源的拉取请求。
来源分支必须位于当前 JayuCloud 仓库;外部仓库中的同名 `dev` 或 `sit` 分支同样会被拒绝。
## 配置组成
- Gitea 原生分支保护:禁止直接写入、强推和管理员绕过。
- Gitea Actions 必需检查:验证拉取请求的来源和目标分支组合。
- 检查使用 `pull_request_target` 执行目标分支中的固定定义,不执行来源分支代码、不读取 Secret,来源分支无法篡改检查逻辑。
- 不新增人工审批数量要求。
## 运维注意事项
- 发布到 SIT:创建或更新 `dev -> sit` 拉取请求。
- 发布到生产:SIT 验证完成后创建或更新 `sit -> prod` 拉取请求。
- 不要为了紧急发布关闭保护规则;修复应先进入 `dev`,再按环境链路晋级。
- 如果来源检查本身故障,按设计文档中的恢复方式处理并记录临时放宽。
## 首次引导记录
启用保护时三个环境分支存在尚未晋级的业务差异。为避免安装检查时发布这些差异,经项目负责人确认,只将来源检查工作流以 `[skip ci]` 独立提交直接引导到尚未保护的 `sit`、`prod`。保护启用后该例外永久失效。
详细规则、启用顺序和验证方法见 `docs/superpowers/specs/2026-10-12-Gitea环境分支保护-design.md`。
@@ -0,0 +1,34 @@
# Salon 初始化 SQL 历史脚本合并说明
## 原因
仅执行 `docs/scripts/sql/init/jayucloud-salon.sql` 的空库缺少
`t_workbench_registration_application`,导致后台注册审核查询报表不存在。
同时,目录中的短信供应商版本脚本也未完全进入空库基线。
## 合并范围
截至 2026-10-10,`docs/scripts/sql/` 下四个 Salon 版本脚本的最终状态已合入
`docs/scripts/sql/init/jayucloud-salon.sql`:
- `工作台注册审核_20260907.sql`:补入注册审核申请表、唯一索引和查询索引。
- `短信供应商全局切换_20260906.sql`:补入 `SMS_PROVIDER=SPUG` 系统参数。
- `短信模板编码映射调整_20260906.sql`:初始化种子已统一使用 `SPUG_SMS_VERIFY_1`。
- `短信模板编码统一修复_20260915.sql`:六个短信场景初始化为启用、未删除、SPUG 发送方式。
两个短信模板脚本的最终状态在合并前已存在于初始化种子中,因此没有重复追加事务更新和结果查询。
ArtList 初始化 SQL 未混入 Salon 专属表和参数。完成核对后,上述四个已合并的版本 SQL 已删除,
`docs/scripts/sql/` 只保留 Salon 与 ArtList 两个初始化入口。
## 使用方式
- 新空库:只需执行 `docs/scripts/sql/init/jayucloud-salon.sql`。
- 已初始化数据库:不要重复执行完整初始化 SQL。需要补齐注册审核表时,应从初始化 SQL 中单独执行
`t_workbench_registration_application` 的 `CREATE TABLE IF NOT EXISTS` 语句;不得对已有数据库重跑完整初始化文件。
## 验证
- 初始化 SQL 必须包含 `t_workbench_registration_application` 建表语句。
- 初始化 SQL 必须包含 `SMS_PROVIDER` 参数种子。
- 六个 Salon 短信验证码场景必须使用 `SPUG_SMS_VERIFY_1`、`SPUG` 且启用。
- 已合入的重复历史 SQL 已删除;不连接或修改任何实际数据库环境。
@@ -24,9 +24,11 @@
## 小程序行为
- 每次启动先获取新的微信 code 探测状态;探测 code 不复用于登录。
- 本机开启“记住我”且状态为 `READY` 时,再获取新 code 自动登录。
- 小程序以独立启动鉴权页作为首屏,避免已记住用户启动时短暂显示登录页或提前触发规划页业务请求。
- 本机开启“记住登录”且状态为 `READY` 时,再获取新 code 自动登录并直接进入规划页;自动登录失败则回到登录页,且保留本机记住偏好以便重试。
- 未勾选“记住登录”时点击快捷登录,会弹出“记住 / 不记住”二选一提示;选择后立即按对应策略登录,不需要再次点击登录按钮。
- 登录后可在“账号设置”使用微信一键绑定或短信验证码绑定手机号。
- 规划页未绑定手机号横幅可关闭到当天;主动退出会清除会话、记住我、当天横幅关闭状态和资料提示跳过状态。
- 规划页未绑定手机号横幅可关闭到当天;主动退出会清除会话、记住登录偏好、当天横幅关闭状态和资料提示跳过状态,并回到登录页。
- 昵称和头像缺失时使用 `chooseAvatar` 与 `input type="nickname"` 引导完善,可在本机跳过。
## 部署前检查
+28 -1
View File
@@ -4,6 +4,8 @@
-- 种子数据原则:只保留运行必需配置;不写入门店、商品、订单、客户、库存流水、测试消息等业务样例数据。
-- 默认平台管理员账号:xiaowang,默认密码沿用当前 bcrypt 值。
-- Linux MySQL 环境库名大小写敏感,数据源必须指向 jayucloud_salon。
-- 2026-10-10 已吸收 docs/scripts/sql 下全部 Salon 版本 SQL 的最终状态:
-- 工作台注册审核、短信供应商全局切换、短信模板编码映射调整、短信模板编码统一修复。
CREATE DATABASE IF NOT EXISTS jayucloud_salon DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
use jayucloud_salon;
@@ -635,6 +637,30 @@ create index idx_type
on t_user (type)
comment '按用户类型查询的索引';
-- 工作台注册审核申请
CREATE TABLE IF NOT EXISTS `t_workbench_registration_application`
(
`id` bigint NOT NULL COMMENT '申请ID',
`application_no` varchar(40) NOT NULL COMMENT '申请编号',
`user_id` bigint NOT NULL COMMENT '申请用户ID',
`role_type` varchar(20) NOT NULL COMMENT '申请身份:MANAGER/STAFF',
`shop_id` bigint NULL COMMENT '目标店铺ID',
`shop_name` varchar(120) NULL COMMENT '店铺名称快照',
`shop_address` varchar(255) NULL COMMENT '店铺地址快照',
`status` varchar(30) NOT NULL COMMENT '状态:PENDING_ADMIN/PENDING_MANAGER/APPROVED/REJECTED',
`reviewer_id` bigint NULL COMMENT '审核人ID',
`reviewed_at` datetime NULL COMMENT '审核时间',
`reject_reason` varchar(500) NULL COMMENT '驳回原因',
`is_delete` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_workbench_registration_application_no` (`application_no`),
KEY `idx_workbench_registration_user` (`user_id`),
KEY `idx_workbench_registration_shop_status` (`shop_id`, `status`),
KEY `idx_workbench_registration_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Salon店务工作台注册审核申请';
-- auto-generated definition
create table t_user_coupon
(
@@ -2249,7 +2275,8 @@ VALUES
(313931273555139001, 'MAP', 'TENCENT_MAP_KEY', '腾讯 Web Key', '', 0, '用于后台腾讯地图选点和 Web 展示;请在后台参数管理中填入真实 Key 后启用', NOW(), NOW(), 0),
(313931273555139002, 'MAP', 'AMAP_WEB_KEY', '高德 Web Key', '', 0, '用于后台高德地图选点和 Web 展示;Web 端 Key 与小程序 Key 分开维护', NOW(), NOW(), 0),
(313931273555139003, 'MAP', 'AMAP_MINI_KEY', '高德小程序 Key', '', 0, '用于后续小程序端高德 SDK/API 调用;不要与 Web Key 混用', NOW(), NOW(), 0),
(313931273555139004, 'USER', 'DEFAULT_PASSWORD', '后台新增用户默认密码', 'Fingertip@123', 1, '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类', NOW(), NOW(), 0)
(313931273555139004, 'USER', 'DEFAULT_PASSWORD', '后台新增用户默认密码', 'Fingertip@123', 1, '后台新增用户不填写密码时使用;需满足 8-32 位且至少包含数字、小写字母、大写字母、特殊符号中的 3 类', NOW(), NOW(), 0),
(313931273555139010, 'SMS', 'SMS_PROVIDER', '短信供应商', 'SPUG', 1, '全局切换短信供应商时同步验证码模板和 MessageHub 通道', NOW(), NOW(), 0)
ON DUPLICATE KEY UPDATE
config_name = VALUES(config_name),
remark = VALUES(remark),
@@ -1,21 +0,0 @@
CREATE TABLE IF NOT EXISTS `t_workbench_registration_application` (
`id` bigint NOT NULL COMMENT '申请ID',
`application_no` varchar(40) NOT NULL COMMENT '申请编号',
`user_id` bigint NOT NULL COMMENT '申请用户ID',
`role_type` varchar(20) NOT NULL COMMENT '申请身份:MANAGER/STAFF',
`shop_id` bigint DEFAULT NULL COMMENT '目标店铺ID',
`shop_name` varchar(120) DEFAULT NULL COMMENT '店铺名称快照',
`shop_address` varchar(255) DEFAULT NULL COMMENT '店铺地址快照',
`status` varchar(30) NOT NULL COMMENT '状态:PENDING_ADMIN/PENDING_MANAGER/APPROVED/REJECTED',
`reviewer_id` bigint DEFAULT NULL COMMENT '审核人ID',
`reviewed_at` datetime DEFAULT NULL COMMENT '审核时间',
`reject_reason` varchar(500) DEFAULT NULL COMMENT '驳回原因',
`is_delete` tinyint unsigned NOT NULL DEFAULT 0 COMMENT '逻辑删除:0-未删,1-已删',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_workbench_registration_application_no` (`application_no`),
KEY `idx_workbench_registration_user` (`user_id`),
KEY `idx_workbench_registration_shop_status` (`shop_id`, `status`),
KEY `idx_workbench_registration_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Salon店务工作台注册审核申请';
@@ -1,14 +0,0 @@
-- Salon 短信供应商全局切换配置
-- 版本:0.0.1
-- 说明:初始化全局短信供应商为 Spug;管理员可在系统设置中切换并同步短信场景。
INSERT INTO t_system_parameter_config (
id, config_group, config_key, config_name, config_value, enabled, remark, create_time, update_time, is_delete
) VALUES (
313931273555139010, 'SMS', 'SMS_PROVIDER', '短信供应商', 'SPUG', 1,
'全局切换短信供应商时同步验证码模板和 MessageHub 通道', NOW(), NOW(), 0
)
ON DUPLICATE KEY UPDATE
config_name = VALUES(config_name),
remark = VALUES(remark),
update_time = NOW();
@@ -1,39 +0,0 @@
-- Salon 短信验证码模板编码映射调整
-- 版本:0.0.1
-- 说明:当前 Salon 使用 Spug 短信,模板 SPUG_SMS_VERIFY_1 支持 name、code、number 参数。
START TRANSACTION;
UPDATE t_messagehub_push_config
SET template_code = CASE scene_code
WHEN 'USER_REGISTER_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
WHEN 'USER_LOGIN_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
WHEN 'USER_RESET_PASSWORD_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
WHEN 'USER_BIND_PHONE_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
WHEN 'USER_CHANGE_PHONE_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
WHEN 'USER_CHANGE_PASSWORD_SMS_CODE' THEN 'SPUG_SMS_VERIFY_1'
END,
channel_id = NULL,
send_method = 'SPUG',
update_time = NOW()
WHERE platform = 'SMS'
AND source_system = 'jayucloud-salon'
AND scene_code IN (
'USER_REGISTER_SMS_CODE',
'USER_LOGIN_SMS_CODE',
'USER_RESET_PASSWORD_SMS_CODE',
'USER_BIND_PHONE_SMS_CODE',
'USER_CHANGE_PHONE_SMS_CODE',
'USER_CHANGE_PASSWORD_SMS_CODE'
)
AND is_delete = 0;
COMMIT;
SELECT scene_code, template_code, channel_id, send_method
FROM t_messagehub_push_config
WHERE platform = 'SMS'
AND source_system = 'jayucloud-salon'
AND scene_code LIKE 'USER_%_SMS_CODE'
AND is_delete = 0
ORDER BY scene_code;
@@ -1,39 +0,0 @@
-- Salon Spug 短信模板编码统一修复
-- 版本:0.0.1
-- 说明:将店务端六个短信验证码场景统一映射到当前 Spug 模板 SPUG_SMS_VERIFY_1。
START TRANSACTION;
UPDATE t_messagehub_push_config
SET template_code = 'SPUG_SMS_VERIFY_1',
channel_id = NULL,
send_method = 'SPUG',
enabled = 1,
is_delete = 0,
update_time = NOW()
WHERE platform = 'SMS'
AND source_system = 'jayucloud-salon'
AND scene_code IN (
'USER_REGISTER_SMS_CODE',
'USER_LOGIN_SMS_CODE',
'USER_RESET_PASSWORD_SMS_CODE',
'USER_BIND_PHONE_SMS_CODE',
'USER_CHANGE_PHONE_SMS_CODE',
'USER_CHANGE_PASSWORD_SMS_CODE'
);
COMMIT;
SELECT scene_code, template_code, channel_id, send_method, enabled, is_delete
FROM t_messagehub_push_config
WHERE platform = 'SMS'
AND source_system = 'jayucloud-salon'
AND scene_code IN (
'USER_REGISTER_SMS_CODE',
'USER_LOGIN_SMS_CODE',
'USER_RESET_PASSWORD_SMS_CODE',
'USER_BIND_PHONE_SMS_CODE',
'USER_CHANGE_PHONE_SMS_CODE',
'USER_CHANGE_PASSWORD_SMS_CODE'
)
ORDER BY scene_code;
@@ -0,0 +1,24 @@
# Salon 后台注册审核与退出修复实施计划
## 目标
修复后台注册审核接口 404,并将重复的后台退出逻辑收敛为无刷新退出流程,消除登录页闪屏。
## 实施步骤
1. 新增后台注册审核控制器,使用 `/admin/user/workbench/registration` 前缀,迁移列表、通过和驳回接口。
2. 从原 `/user/workbench` 控制器移除三个审核端点,仅保留小程序注册相关接口。
3. 补充控制器路径契约测试,锁定后台审核与小程序注册的路径边界。
4. 新增后台退出工具,统一调用退出接口、清理会话及权限、重置鉴权状态并通过 Router replace 跳转。
5. 调整后台布局和个人页复用退出工具,删除重复缓存清理及整页刷新代码。
6. 补充退出工具测试和前端静态契约测试,检查不存在后台退出 `window.location.href`。
7. 运行 Salon Core 测试与编译、Salon Frontend 单元测试与构建。
8. 检查最终差异、静态引用和受影响文件,创建中文 Git 提交。
## 验收条件
- `/admin/api/user/workbench/registration/list` 经 Gateway 重写后能命中 Core 后台审核控制器。
- 原小程序注册、重提、状态和可选门店接口路径不变。
- 后台布局和个人页退出后直接进入 `/admin/login`,不触发整页刷新。
- 会话和权限缓存完整清理,退出接口失败时仍能完成本地退出。
- 相关测试和构建通过,变更不包含无关文件。
@@ -0,0 +1,25 @@
# Salon 小程序记住登录体验优化实施计划
## 目标
让用户在记住登录选择弹窗中一次完成选择和登录,并让已记住用户冷启动时绕过登录页直接进入规划页。
## 实施步骤
1. 提取登录选择与启动鉴权的纯函数,定义记住选择、自动登录资格和目标页面决策。
2. 新增纯函数单元测试,覆盖记住/不记住、协议阻断、READY 自动登录和失败回登录页。
3. 新增轻量启动鉴权页并注册为 `app.json` 首页面,页面仅显示加载状态。
4. 重构 `app.js` 启动流程:单次执行状态探测,已记住 READY 用户自动登录成功后直达规划页,其余状态进入登录页。
5. 调整登录页记住提示语;未勾选时弹出“记住/不记住”选择,选择后立即执行对应登录。
6. 保证多门店确认沿用本轮选择的记住策略,成功后保存偏好。
7. 保持主动退出清除记住状态并回登录页;自动登录失败回登录页但不额外触发登录。
8. 更新小程序登录说明和项目变更记录。
9. 运行新增 Node 测试、静态契约检查和可用的小程序测试,检查最终差异后创建中文提交。
## 验收条件
- 已记住 READY 用户启动过程不进入登录页。
- 未勾选时弹窗两个按钮均只需点击一次即可继续登录。
- 记住选择准确写入本机,多门店流程不丢失选择。
- 主动退出后重新进入登录页;自动登录失败也回登录页并显示错误。
- 协议未勾选时不发起登录。
@@ -0,0 +1,26 @@
# Gitea 环境分支保护实施计划
日期:2026-10-12
## 目标
启用 `dev -> sit -> prod` 唯一晋级链路,禁止所有用户(包括管理员)直接写入 `sit`、`prod`。
## 实施步骤
1. 新增 `.gitea/workflows/environment-promotion-guard.yml`,通过 `pull_request_target` 固定使用目标分支中的检查定义,仅在目标为 `sit` 或 `prod` 的拉取请求上运行;工作流不检出或执行来源代码,也不读取 Secret。
2. 检查来源仓库必须是当前 JayuCloud 仓库,并检查 `sit <- dev` 和 `prod <- sit` 两种组合;其余组合或缺少事件字段时明确失败。
3. 在 `dev` 提交工作流、设计修订、计划和配置说明,并推送到远端。
4. 分别从 `origin/sit`、`origin/prod` 建立临时隔离工作树,只复制该工作流,以 `[skip ci]` 提交并直接推送。
5. 使用验证拉取请求收集 Gitea 实际状态检查上下文并确认检查结果。
6. 通过 Gitea API 创建 `sit`、`prod` 保护规则:关闭直接推送和强推,清空所有允许名单,启用必需状态检查,禁止管理员覆盖。
7. 使用临时无业务改动提交验证两个分支的直接推送均被拒绝。
8. 查询 API 复核最终规则,关闭验证拉取请求并删除临时远端分支和工作树。
## 验收标准
- `sit` 只允许 `dev` 来源拉取请求通过来源检查。
- `prod` 只允许 `sit` 来源拉取请求通过来源检查。
- 所有人(包括管理员)无法直接推送或强推 `sit`、`prod`。
- 两个保护规则没有任何用户、团队、部署密钥或管理员绕过入口。
- 引导过程不包含业务文件,不触发 SIT 或生产部署。
@@ -0,0 +1,21 @@
# Salon 个人信息页头像卡精简设计
## 目标
精简个人信息页顶部头像卡,突出用户本人资料,移除说明性文案和独立操作按钮。
## 设计
- 整个头像区域作为更换头像入口,点击即打开现有图片选择流程。
- 头像底部增加轻量半透明遮罩,显示“点击更换”;上传期间显示“上传中”。
- 头像右侧只展示当前昵称和个性签名,两项随下方表单输入即时变化。
- 昵称或签名为空时分别显示“未设置昵称”和“暂无个性签名”。
- 删除独立“上传/更换”按钮、“移除当前头像”入口,以及“个人头像”“上传清晰头像”等说明文案。
- 下方基本资料、账号信息和保存流程保持不变。
## 验收
- 点击头像可选择并上传新头像。
- 头像内部始终有简洁的更换提示,不额外占用横向空间。
- 右侧只出现昵称和个性签名。
- 头像上传与保存期间仍能阻止重复操作,并保留原有失败提示。
@@ -0,0 +1,33 @@
# Salon 个人资料与手机号入口优化设计
## 目标
明确区分个人展示资料与账号安全资料:个人信息页只编辑昵称、头像、微信号和个性签名;手机号统一在账号设置中绑定或更换。同时提供符合微信规范的头像昵称填写入口,并精简账号设置的默认展示。
## 个人信息页
- 联系方式改为只读手机号,优先展示脱敏号码,未绑定时展示“未绑定”。
- 点击手机号行跳转到账号设置,不再通过个人资料保存接口提交 `contactPhone`。
- 新增“使用微信资料”折叠入口。
- 展开后使用 `button open-type="chooseAvatar"` 获取微信头像临时文件并上传,使用 `input type="nickname"` 接收微信昵称建议。
- 微信头像和昵称写入当前资料表单,继续由页面底部“保存个人信息”统一保存。
- 保留点击顶部头像从相册或相机更换头像的原有入口。
## 账号设置页
- 微信一键绑定或更换手机号继续直接展示。
- 短信验证码绑定区域默认折叠,只展示“使用短信验证码绑定/更换”的入口行。
- 点击入口展开手机号、验证码、获取验证码和验证绑定控件;再次点击收起。
- 发送验证码倒计时与绑定逻辑保持不变。
## 微信能力约束
微信不再可靠支持一次授权直接返回真实头像和昵称,因此不使用旧 `getUserProfile`。页面以一个“使用微信资料”入口聚合微信合规组件,用户选择后同步填入表单。
## 验收
- 个人信息页无法编辑或提交手机号,点击手机号可进入账号设置。
- 微信资料入口默认收起,展开后可选择头像并填写微信昵称。
- 账号设置短信绑定默认收起,展开后原有验证码绑定功能正常。
- 保存个人资料不会覆盖登录手机号或联系电话字段。
- 当前登录页未提交改动不进入本任务提交。
@@ -0,0 +1,64 @@
# Salon 后台注册审核与退出修复设计
## 目标
- 修复后台注册审核页面请求 `registration/list` 时返回 404 的问题。
- 消除后台退出登录过程中短暂出现窄屏登录布局的闪屏。
- 清理与退出流程直接相关的重复会话清理代码,不扩大到无关页面或业务重构。
## 根因
后台前端以 `/admin/api` 为管理接口前缀。Gateway 会将
`/admin/api/user/workbench/registration/**` 重写为
`/admin/user/workbench/registration/**`,但 Core 中现有控制器只注册了
`/user/workbench/registration/**`,因此审核接口无法命中。
后台布局页和后台个人页各自维护了一套退出实现。两处都手工删除多项缓存,随后通过
`window.location.href` 强制整页加载登录页。页面卸载、重新初始化和响应式样式生效之间
存在可见过渡,造成退出后短暂显示窄屏登录布局。
## 方案
### 注册审核接口
保留 `WorkbenchRegistrationController` 中面向小程序的注册、重提、状态查询和可选门店接口,
其 `/user/workbench` 前缀不变。将审核列表、通过和驳回三个管理操作迁移到独立的后台控制器,
统一使用 `/admin/user/workbench/registration` 前缀。
这样既与 Gateway 的后台路径重写规则一致,也避免把小程序注册接口同时暴露到后台路径。
后台控制器继续复用原有 `WorkbenchRegistrationService`、用户身份判断和返回结构,不改变
审核业务规则。
### 退出流程
新增一个后台会话退出工具,集中完成:
- 尽力调用后台退出接口;接口失败仍允许本地退出。
- 清除后台及历史兼容会话缓存和权限缓存。
- 重置后台启动鉴权状态。
- 使用 Vue Router 的 `replace('/admin/login')` 完成无刷新跳转。
`AdminLayout.vue` 和后台 `ProfileView.vue` 仅保留确认弹窗与成功提示,共用该工具,删除两处
重复的缓存清理和 `window.location.href` 跳转代码。正常的桌面/移动端后台布局继续保留。
## 错误处理
- 后台退出接口异常只记录日志,不阻止本地会话清理和跳转。
- 注册审核接口沿用全局鉴权与异常响应;未登录或无权限时不会返回审核数据。
- 不改变小程序注册接口路径,避免引入移动端回归。
## 验证
- Core 控制器测试覆盖后台审核列表路径,并确认原小程序注册路径仍存在。
- 前端 API 契约测试确认审核请求仍使用 `/user/workbench/registration/**`,由后台基础地址补齐
`/admin/api`。
- 为统一退出工具增加测试,确认缓存被清理且使用路由替换跳转。
- 运行 Salon Core Maven 测试/编译和 Salon Frontend 测试/构建。
- 提交前检查 Git 变更范围;GitNexus 当前不可用时记录原因,并以静态引用和测试结果替代。
## 非目标
- 不删除后台移动端适配代码。
- 不修改小程序登录与注册业务。
- 不修改 Gateway 路由、Nacos 配置、数据库或初始化 SQL。
- 不清理与本次两个问题无直接关系的页面或模块。
@@ -0,0 +1,40 @@
# Salon 小程序个人信息独立页面设计
## 目标
将“我的”页面中的个人信息编辑弹窗迁移为独立页面,页面结构和视觉层级与“账号设置”保持一致。“我的”页面只负责展示账号摘要和提供导航入口。
## 页面结构
- 新增 `/pages/profile-edit/index`,导航栏标题为“个人信息”。
- 顶部头像卡展示当前头像或昵称首字,并提供上传、更换和移除头像操作。
- 基本资料卡编辑昵称、联系电话、微信号和个性签名。
- 账号信息卡只读展示登录账号、所属门店和身份。
- 页面底部固定“保存个人信息”按钮,保存期间禁用重复提交。
## 数据流
- 页面显示时调用现有 `/user/info` 接口加载最新资料。
- 头像继续使用现有图片选择与资料图片上传能力。
- 保存继续调用现有 `PUT /user/info`,成功后重新获取资料并同步到本机会话。
- 返回“我的”页面时,现有 `onShow` 会重新读取会话并刷新顶部账号卡。
- 后端返回的通用默认头像地址在前端视为未设置头像,页面展示昵称首字,避免透明圆形占位图露出容器底色。
## 原页面清理
- “个人信息”菜单改为导航到独立页面。
- 从“我的”页面删除编辑弹窗、表单状态、头像上传和保存方法及对应样式。
- 保留“我的”页面资料加载逻辑,用于刷新顶部账号卡。
## 错误处理
- 资料加载失败时保留会话中的资料作为页面初始值,并允许重试。
- 头像选择取消不提示错误;上传失败保留原头像。
- 联系电话格式或昵称校验失败时不提交。
- 保存失败保留用户输入,成功后提示并返回上一页。
## 范围与验收
- 仅修改 Salon 小程序,不调整后端接口、数据库或配置。
- 当前工作区中登录页相关未提交改动不纳入本任务。
- 验收覆盖独立页面导航、资料加载、头像兜底、表单校验、保存同步及旧弹窗代码清理。
@@ -0,0 +1,30 @@
# Salon 小程序“我的”页面账号卡设计
## 目标
将“我的”页面顶部卡片从固定品牌信息改为当前登录账号信息,让用户能直接确认当前身份。
## 展示规则
- 左侧优先显示用户头像;头像为空时显示昵称首字,昵称也为空时显示“用”。
- 主标题显示用户昵称;昵称为空时依次使用登录账号和“未设置昵称”兜底。
- 副标题显示当前所属门店;优先使用当前会话中的门店名称,没有时使用产品默认门店名称。
- 右侧继续显示当前角色标签,不改变角色映射规则。
## 数据与刷新
- 页面首次显示时从全局会话立即渲染,避免等待接口期间显示固定品牌占位。
- 用户资料接口返回后同步头像和昵称到会话,并重新计算账号卡展示字段。
- 编辑个人资料成功后沿用现有资料同步路径,账号卡立即更新。
## 范围
- 仅修改 `JC-Salon-WeChat/pages/profile` 页面及相关说明、测试。
- 不修改个人资料接口、登录接口、数据库或后端服务。
- 不包含当前工作区中登录页相关的未提交改动。
## 验收
- 有头像和昵称时显示真实头像、昵称、所属门店及角色。
- 无头像时显示昵称首字,无昵称时显示稳定兜底内容。
- 修改头像或昵称并保存后,顶部卡片立即刷新。
@@ -0,0 +1,74 @@
# Salon 小程序记住登录体验优化设计
## 目标
- 将未勾选记住登录时的二次提示改为一次选择即可继续登录。
- 已记住且可登录的用户再次打开小程序时不展示登录页,直接进入规划页。
- 主动退出清除本机记住状态并回到登录页。
- 自动登录失败按确认要求回到登录页并展示失败信息。
## 登录页交互
登录页继续保留微信快捷登录、记住登录选项和协议勾选。记住登录提示语统一为
“记住登录,后续可快速登录”。
点击微信快捷登录时先校验协议:
1. 未同意协议时继续阻止登录,并引导用户勾选协议。
2. 已勾选记住登录时直接按记住模式登录。
3. 未勾选记住登录时弹出选择框,提示“勾选记住登录之后,后续可快速登录。”,按钮为
“记住”和“不记住”。点击任一按钮后立即按对应模式继续登录,不需要再次点击快捷登录。
多门店选择、新用户申请、审核中、驳回和禁用状态沿用现有处理。记住策略需要贯穿多门店
确认流程,最终登录成功后再保存到本机。
## 启动鉴权
新增独立启动鉴权页并将其设为小程序首个页面。该页面只负责展示品牌加载状态和承载启动鉴权,
不发送规划业务请求。
启动流程:
1. App 读取本机会话和记住登录偏好。
2. 获取微信 code 并探测账号状态。
3. 本机已记住且状态为 `READY` 时,获取新的 code 执行快捷登录。
4. 登录成功后直接 `reLaunch` 到规划页,整个过程不进入登录页。
5. 未记住、新用户、审核中、驳回、禁用、网络异常或自动登录失败时进入登录页,并传递/保留
当前状态供登录页展示。
启动鉴权必须保证同一轮启动只执行一次,避免启动页和登录页重复触发微信登录请求。
## 主动退出与会话边界
账号设置中的主动退出继续调用后端退出接口,然后清除:
- 当前会话;
- 记住登录偏好;
- 手机号提醒当天关闭状态;
- 资料完善跳过状态。
退出后直接进入登录页。普通页面重新显示、切换前后台或重新进入规划页不会清除记住状态。
服务端会话失效仍按现有统一请求处理进入登录页,但不主动删除记住偏好;用户可以在登录页重试。
## 错误处理
- 协议加载失败时不发起登录,并允许用户重试协议加载。
- 自动登录的探测、微信 code 或后端请求失败时进入登录页,显示明确的连接/登录失败信息。
- 登录选择弹窗关闭或调用失败时不修改已保存的记住偏好。
- 新用户和非 `READY` 状态不尝试自动登录,避免创建重复用户或签发无效会话。
## 测试与验收
- 未勾选记住登录时,弹窗按钮文案为“记住”和“不记住”,两种选择都会直接发起一次登录。
- 已勾选时不弹窗,直接登录并保存记住偏好。
- 已记住且账号 `READY` 的冷启动不进入登录页,自动登录成功后直接进入规划页。
- 未记住、主动退出和自动登录失败均进入登录页。
- 多门店选择后保存用户在本轮登录选择的记住策略。
- 协议未同意时不弹记住选择、不调用快捷登录接口。
- 小程序现有测试和新增启动/登录状态机测试通过,不修改后端接口和数据库。
## 非目标
- 不修改微信 OpenID 登录接口、Token 时长和审核业务规则。
- 不调整登录页整体视觉风格。
- 不修改 ArtList 小程序。
@@ -0,0 +1,20 @@
# Salon 微信头像选择即时预览修复设计
## 问题
个人信息页通过微信头像选择器返回时,页面 `onShow` 会重新加载服务端旧资料,可能覆盖刚选择的头像。同时头像必须等待上传完成后才更新,网络较慢时用户会认为选择没有生效。
## 修复
- 页面首次加载改为在 `onLoad` 主动请求一次资料,不再每次 `onShow` 无条件刷新。
- 只有点击手机号进入账号设置后,返回个人信息页才重新加载资料,用于刷新手机号。
- 选择头像后立即把微信临时文件作为预览图显示,再执行上传。
- 上传成功后将预览替换为正式图片地址;上传失败时恢复原头像并保留错误提示。
- 相册/相机头像选择与微信头像选择共用同一套即时预览和回滚逻辑。
## 验收
- 选择微信头像后页面立即显示新头像。
- 微信原生选择器关闭后不会被旧服务端资料覆盖。
- 上传失败能恢复选择前头像。
- 从账号设置返回后手机号仍能刷新。
@@ -0,0 +1,20 @@
# Salon 微信资料双按钮设计
## 目标
将个人信息页单一“使用微信资料”折叠入口改为两个并排操作,减少层级并明确头像、昵称是两项独立授权。
## 设计
- 左侧为“使用微信头像”按钮,直接使用 `open-type="chooseAvatar"` 唤起微信头像选择。
- 右侧为“使用微信昵称”控件,使用 `input type="nickname"` 保留微信昵称建议能力,并通过样式呈现为与左侧一致的按钮。
- 两个按钮等宽、同高,直接显示,不再展开二级面板。
- 微信昵称选中后更新资料表单和头像首字,但按钮仍显示固定操作文案。
- 删除旧的“使用微信资料”入口、展开状态、箭头、头像预览面板及相关样式。
## 验收
- 页面直接显示左右两个微信资料按钮。
- 左侧能选择并上传微信头像,继续使用即时预览和失败回滚。
- 右侧点击后能唤起微信原生昵称建议并写入昵称表单。
- 不再出现旧的折叠入口与二级面板。
@@ -0,0 +1,85 @@
# Salon 小程序全链路性能优化设计
## 背景与目标
当前性能问题来自冷启动串行登录、页面重复请求、个人中心按员工逐个请求排班规则、规划页同时构建三套视图,以及首包大图片。优化必须保持登录状态判断、门店权限、规划数据和页面交互结果不变,不修改用户尚未提交的登录页与个人信息模板改动。
验收目标:
- 已记住登录的冷启动减少一次 `wx.login` 和一次状态探测请求。
- 个人中心请求数不再随员工数量增长。
- 规划页一次只构建当前视图,完整预约列表不进入渲染层数据。
- 同一日历条件下的并发请求合并,用户资料短时间内复用并可显式失效。
- 首包大图显著缩小,非首屏页面进入分包。
- 小程序单元测试和 Salon Core Maven 测试、编译通过。
## 方案比较
### 方案一:仅前端局部节流
增加防抖和少量缓存,改动小,但无法消除个人中心 N+1 请求,也不能解决规划页无效计算和首包问题。
### 方案二:前后端协同优化(采用)
后端提供个人中心汇总数据,前端建立请求复用和资料缓存,规划页按当前视图构建数据,同时优化首包资源。收益覆盖启动、网络、脚本执行和渲染四个阶段,业务行为保持不变。
### 方案三:重写规划页或切换 Skyline
理论上可进一步提升复杂列表性能,但风险高、验证成本大,当前数据规模不需要进行渲染引擎迁移。
## 详细设计
### 冷启动登录
- 本机存在有效“记住登录”偏好时,直接获取一次微信 code 调用快捷登录;快捷登录本身返回审核中、驳回、禁用、多门店选择等状态,不再预先调用状态探测接口。
- 未记住登录时保持状态探测,不创建用户、不签发 Token,并停留登录页。
- 保留启动 Promise 去重和失败回登录页逻辑。
### 用户资料缓存
- 新增进程内用户资料缓存,提供短 TTL、并发 Promise 合并、强制刷新和失效能力。
- 规划页、个人中心、个人资料和账号设置复用该入口。
- 修改资料、绑定手机号或退出登录后立即失效;需要展示刚修改结果的场景强制刷新。
- 缓存只减少读取请求,不改变服务端数据权威性。
### 个人中心汇总
- Salon Core 新增当前门店“今日概览”只读接口,一次返回预约数量、待确认数量、后续预约数量、可预约员工、请假/调班待处理数量和营业状态。
- 服务端在门店权限范围内聚合查询,避免客户端先取员工列表再逐人查询排班规则。
- 小程序个人中心并行读取资料与单个概览接口,请求数固定,不随员工数增长。
### 规划页计算与渲染
- 完整日历响应保存在 Page 的非响应字段中,不把完整预约、排班和日汇总数组写入 `data`。
- 根据当前模式只构建日、周或月视图;切换模式时基于已加载范围决定是否复用或重新请求。
- `setData` 只发送当前视图所需字段,避免先写原始数据再写派生数据。
- 相同请求条件正在加载时复用 Promise;较早请求晚于新请求返回时不得覆盖新结果。
- 页面回显刷新继续由现有脏标记触发,不引入可能展示旧预约数据的长期缓存。
### 首包与样式
- 将 1254×1254、约 1.49 MB 的应用图标缩放压缩到适合小程序展示的尺寸。
- 优先压缩主包大图并启用按需组件注入;压缩后若整体体积已低于 500 KB,则保留现有页面目录,避免为边际收益搬迁路由。只有后续主包再次明显增长时再拆分非首屏页面。
- 仅减少低端设备代价较高且不影响信息表达的模糊、常驻动画和重复阴影;保留整体视觉风格。
## 错误处理与兼容性
- 缓存请求失败不写入缓存,下一次进入页面允许重试。
- 概览接口失败只提示概览加载失败,不阻断个人资料展示。
- 自动登录失败仍保留记住偏好并回到登录页。
- 旧后端接口继续保留,Web 和其他调用方不受影响。
## 测试计划
- 为自动登录分支、资料缓存并发合并/失效、规划页当前视图构建和请求去重补充单元测试。
- 为今日概览服务补充门店范围、数量统计和空数据测试。
- 运行小程序现有测试及新增测试。
- 运行 Salon Core Maven 测试和编译。
- 检查 app.json 分包配置、所有页面路由和资源引用。
- 提交前核对 Git 差异,确保不包含用户原有未提交文件。
## 非目标
- 不切换 Skyline 渲染引擎。
- 不修改业务接口权限规则、数据库结构、Nacos 或真实环境配置。
- 不改变登录页、个人信息页当前正在进行的产品改动。
@@ -0,0 +1,67 @@
# Gitea 环境分支保护设计
日期:2026-10-12
## 目标
为 JayuCloud 仓库固定发布晋级链路,避免任何用户(包括管理员)直接修改测试和生产分支:
```text
dev -> sit -> prod
```
## 分支规则
### sit
- 禁止直接推送、强制推送和网页直接修改。
- 不配置用户、团队、部署密钥或管理员绕过名单。
- 只允许来源分支为 `dev` 的拉取请求合并到 `sit`。
### prod
- 禁止直接推送、强制推送和网页直接修改。
- 不配置用户、团队、部署密钥或管理员绕过名单。
- 只允许来源分支为 `sit` 的拉取请求合并到 `prod`。
## 实现方式
Gitea 原生分支保护负责禁止直接写入和管理员绕过。Gitea 27.3.4 的分支保护接口不能按拉取请求来源分支设置规则,因此仓库增加一个 Gitea Actions 来源分支检查。检查使用 `pull_request_target`,固定执行目标受保护分支中的工作流,来源分支不能通过修改工作流绕过规则。该工作流不检出或执行来源代码,也不读取 Secret。
- 拉取请求目标为 `sit` 时,只接受来源 `dev`。
- 拉取请求目标为 `prod` 时,只接受来源 `sit`。
- 来源仓库必须是当前 JayuCloud 仓库,外部仓库中的同名分支不能通过检查。
- 其他目标分支不由该检查限制。
- 无法识别来源或目标分支时检查失败,避免异常事件被误判为允许。
该检查作为 `sit` 和 `prod` 的必需状态检查。管理员合并覆盖被关闭,因此检查失败、缺失或尚未完成时,所有用户都不能合并。
本次不新增人工审批数量要求,保持现有发布操作习惯;保护只约束写入方式和分支晋级顺序。
## 初次启用顺序
实施前核对发现,`dev`、`sit`、`prod` 当前存在大量尚未晋级的业务提交。为避免安装保护规则时意外触发 SIT 或生产发布,经项目负责人确认采用一次性安全引导例外:
1. 在 `dev` 增加来源分支检查工作流、实施计划和配置说明,提交信息包含 `[skip ci]`。
2. 从各目标分支当前提交创建隔离工作树,只加入同一来源检查工作流,以 `[skip ci]` 独立提交并直接写入尚未保护的 `sit`、`prod`。
3. 创建不合并的验证拉取请求,确认检查上下文名称及正确、错误来源的结果。
4. 在 Gitea 为 `sit` 和 `prod` 创建原生保护规则,把来源分支检查设为必需检查。
5. 验证直接推送被拒绝后关闭验证拉取请求并清理临时分支。
一次性引导不携带业务文件、不触发环境部署。保护规则启用后不再允许该例外,所有后续提交永久遵循 `dev -> sit -> prod`。
## 验证
- 尝试直接向 `sit` 推送,预期被拒绝。
- 尝试直接向 `prod` 推送,预期被拒绝。
- 对 `dev -> sit` 拉取请求,来源分支检查必须成功。
- 对非 `dev -> sit` 拉取请求,来源分支检查必须失败并阻止合并。
- 对 `sit -> prod` 拉取请求,来源分支检查必须成功。
- 对非 `sit -> prod` 拉取请求,来源分支检查必须失败并阻止合并。
- 查询 Gitea API,确认两个保护规则均未配置绕过名单、禁止强推,并阻止管理员覆盖必需检查。
验证使用临时分支或无内容提交时,不向受保护分支留下无关业务改动;验证产生的临时分支和拉取请求在完成后清理或关闭。
## 恢复方式
若来源检查配置异常,先修复 `dev` 上的检查文件并按正常晋级链路发布。只有仓库完全无法晋级时,才由管理员临时移除对应必需检查;问题修复后立即恢复原规则。任何临时放宽都必须记录原因和持续时间。
+62
View File
@@ -1,5 +1,57 @@
# 项目变更记录
## 2026-10-10 Salon 微信资料双按钮
- 将个人信息页“使用微信资料”折叠入口改为左右两个等宽按钮:左侧使用微信头像,右侧使用微信昵称。
- 微信昵称按钮以透明 `nickname` 输入覆盖实现,保留微信原生昵称建议能力,同时固定显示操作文案。
- 删除旧展开状态、箭头和二级头像昵称面板,减少操作层级。
## 2026-10-10 Salon 微信头像选择即时预览修复
- 修复微信头像选择器返回页面时 `onShow` 重新加载旧资料、覆盖新头像的问题。
- 选择微信头像或本地图片后立即预览,上传成功替换为正式地址,上传失败恢复原头像。
- 个人信息页仅首次进入和从账号设置返回时刷新资料,避免系统选择器唤回页面时重置未保存表单。
## 2026-10-10 Salon 个人资料与手机号入口优化
- 个人信息页手机号改为只读展示,点击跳转账号设置;个人资料保存请求不再提交联系电话或手机号字段。
- 新增默认折叠的“使用微信资料”区域,通过微信 `chooseAvatar` 与 `nickname` 合规组件填充当前头像和昵称。
- 账号设置中的短信验证码绑定区域默认折叠,微信一键绑定保持直接展示,展开后沿用原有验证码流程。
## 2026-10-10 Salon 个人信息页头像卡精简
- 个人信息页移除独立头像上传按钮、移除头像入口和说明文案,改为直接点击头像更换。
- 头像内部增加“点击更换/上传中”轻提示,右侧仅展示昵称和个性签名,并随表单输入即时更新。
## 2026-10-10 Salon 小程序个人信息独立页面
- 新增独立“个人信息”页面,页面结构与账号设置统一,承载头像、昵称、联系电话、微信号和个性签名编辑,以及账号、门店和身份只读信息。
- “我的”页面个人信息入口改为页面导航,删除原有底部弹窗、表单状态、上传保存方法和冗余样式。
- 保存后同步本机会话并返回“我的”页面,顶部账号卡可立即刷新。
- 将后端通用外链默认头像识别为未设置头像,“我的”和“个人信息”页面统一使用昵称首字兜底,首页资料完善提示仍会正确引导上传真实头像。
## 2026-10-10 Salon 小程序“我的”页面账号卡优化
- “我的”页面顶部卡片改为展示当前账号头像、昵称、所属门店和角色,不再展示固定品牌图标与“店长端”占位信息。
- 头像缺失时显示昵称首字;昵称缺失时使用登录账号或明确占位文案,门店名称优先取当前用户所属门店。
- 统一首次会话渲染、资料接口刷新和编辑保存后的展示规则,并补充账号卡兜底逻辑测试。
## 2026-10-10 Salon 小程序记住登录体验优化
- 新增独立启动鉴权页;已记住且账号状态正常的用户启动后自动登录并直接进入规划页,不再短暂显示登录页。
- 登录页文案调整为“记住登录,后续可快速登录”;未勾选时弹窗提供“记住 / 不记住”,选择任一项后立即按对应策略登录。
- 自动登录失败统一回到登录页且保留记住偏好;主动退出继续清除本机会话和记住偏好并回到登录页。
- 新增登录决策纯函数测试;GitNexus 当前无可调用服务,本次以静态调用链检查和小程序 Node 测试替代影响分析。
## 2026-10-10 Salon 后台注册审核与退出修复
- 将注册审核列表、通过和驳回接口拆分到 `/admin/user/workbench/registration/**`,与 Gateway 后台路径重写保持一致,修复审核页面 404。
- 后台布局与个人页共用统一退出流程,集中清理会话和权限并使用前端路由替换跳转,移除两处重复的整页刷新退出代码。
- 注册审核表格补充横向滚动配置;修正前端测试仍引用旧 `fingertipdesigner` Java 包路径的问题。
- 按负责人明确要求重整 Salon 空库基线,将 `docs/scripts/sql/` 下全部 Salon 版本 SQL 的最终状态合入初始化 SQL,补齐注册审核表和短信供应商参数;核对完成后删除四个已合并的重复版本 SQL。
- 未连接或修改实际数据库;当前已初始化数据库仍需从初始化 SQL 中单独执行注册审核表建表语句,不能重跑完整初始化文件。
- GitNexus 当前没有可调用服务,改用静态引用检查、Core 测试与编译、前端 83 项测试和生产构建验证。
## 2026-10-10 Salon 小程序 OpenID 快捷登录改造
- Salon 小程序登录页收敛为微信快捷登录,支持启动状态探测、本机记住登录、多门店选择、审核状态与驳回重提。
@@ -91,3 +143,13 @@
- 当前已确认的 Salon SIT 主机继续使用 Core `181`、Gateway `180`;普通中间件与业务参数仍由 SIT Nacos配置提供。
- 新增版本化说明 `docs/scripts/后端Nacos启动引导环境变量修复_20261012.md`,记录原因、范围和验证方式。
# 2026-10-12 Gitea 环境分支保护设计
- 固定环境分支晋级链路为 `dev -> sit -> prod`。
- 设计 `sit`、`prod` 全员禁止直接写入和强推的原生保护规则,管理员无绕过权限。
- 设计拉取请求来源分支必需检查:`sit` 仅允许 `dev`,`prod` 仅允许 `sit`。
- 新增配置说明:`docs/scripts/Gitea环境分支保护配置说明_20261012.md`。
- 新增设计文档:`docs/superpowers/specs/2026-10-12-Gitea环境分支保护-design.md`。
- 新增来源检查工作流:`.gitea/workflows/environment-promotion-guard.yml`。
- 当前环境分支存在未晋级业务差异,首次启用按已确认的一次性安全引导执行;只向 `sit`、`prod` 写入检查工作流,不携带业务改动。