Files
luo b2ed8b5df4
All checks were successful
构建并部署前端到生产环境 / build-and-deploy (push) Successful in 1m6s
feat: 分销码
2026-10-08 12:26:39 +08:00

1.8 KiB

MODIFIED Requirements

Requirement: Agent users can view their shop distribution code

The authenticated home page SHALL show a "View my distribution code" shortcut immediately after withdrawal management only when the current user's user_type is 3. The shortcut SHALL use src/static/icons/分销码.png. Opening it SHALL use the current user's shop_id to retrieve that shop's distribution_code from /api/admin/shops/{shop_id} and display a QR code encoding the absolute registration URL formed from VITE_API_BASE_URL, /agent-registration, and the URL-encoded distribution_code query parameter. The code SHALL be generated locally and SHALL NOT be sent to a third-party QR service.

Scenario: Agent sees and opens the shortcut

  • GIVEN /api/auth/me returns a user with user_type 3 and a valid shop_id
  • WHEN the home page displays its quick actions
  • THEN "View my distribution code" appears immediately after withdrawal management with the supplied distribution-code icon
  • AND opening it displays a QR code whose decoded value is ${VITE_API_BASE_URL}/agent-registration?distribution_code=${encodeURIComponent(distribution_code)}

Scenario: Non-agent does not see the shortcut

  • GIVEN /api/auth/me returns a user whose user_type is not 3
  • WHEN the home page displays its quick actions
  • THEN the distribution-code shortcut is not shown
  • AND direct navigation to the distribution-code page does not reveal a code

Scenario: Shop or distribution code is unavailable

  • GIVEN an agent opens the distribution-code page
  • WHEN the current account has no shop_id, the shop request fails, or the shop has no distribution_code
  • THEN no QR code is rendered
  • AND the page explains that the distribution code is currently unavailable