spec.md 4.5 KB

app-shell Specification

Purpose

This specification defines the native WeChat Mini Program app shell for 普瑞互联网医院智慧医院小程序 V2.0, including base project structure, routing, custom tabBar, global UI tokens, unified request wrapping, login/hospital initialization skeletons, and legacy resource reuse helpers.

Requirements

Requirement: Native Mini Program Structure

The source directory SHALL contain a native WeChat Mini Program structure with app.js, app.json, app.wxss, project.config.json, sitemap.json, pages, components, custom-tab-bar, utils, and assets entry points.

Scenario: Import basic project

  • WHEN a developer imports 04-新项目源码_source/pri-smart-hospital-miniprogram in WeChat DevTools
  • THEN the project has the required native mini program entry files
  • AND no empty subPackages item is registered in app.json.

Requirement: Base Routing And Placeholder Pages

The app shell SHALL register the five first-level tab pages, the hospital switch placeholder page, and the common error page.

Scenario: Open tab placeholders

  • WHEN a user opens 首页、就诊指引、缴费、消息、我的
  • THEN each page renders a visible placeholder state
  • AND unfinished business entries are presented as unavailable or module pending
  • AND no concrete registration, payment, patient editing, order detail, report, or message detail workflow is executed.

Requirement: Custom TabBar Skeleton

The app shell SHALL provide a custom tabBar component with selected state, unselected state, badge placeholders, and configurable guidance tab visibility.

Scenario: Guidance tab visibility

  • WHEN tabBarSettings.guideHospConfig is Y
  • THEN the guidance tab can be shown
  • WHEN tabBarSettings.guideHospConfig is not Y
  • THEN the guidance tab can be hidden by configuration.

Requirement: Global UI Tokens And Base States

The app shell SHALL provide project-level UI tokens and common classes for page background, hero area, cards, buttons, text, loading, empty, error, disabled, and image fallback states.

Scenario: Placeholder page styling

  • WHEN a placeholder page renders
  • THEN it uses the light blue background, white cards, blue/cyan brand accents, readable text hierarchy, and minimum 44px touch targets from the UI standard.

Requirement: Unified Request Wrapper

The app shell SHALL provide a request wrapper for the legacy unified gateway that supports business code, data/params, namespace, session: [userData], HISFlag, UPPFlag, and the fixed Basic authorization required by the current legacy gateway contract.

Scenario: Build the legacy request

  • WHEN request({ code: "01050001", data: {} }) is called
  • THEN the generated body includes code, HISFlag: "N", UPPFlag: "N", session: [userData], and params
  • AND the request attaches the configured legacy Basic authorization header
  • AND the request and response remain subject to the existing business error handling.

Requirement: Login And Hospital Initialization Skeleton

The app shell SHALL restore the legacy login, hospital initialization and IM configuration chain, including hospital imAppID / imSecret, app SDKAPPID / SECRETKEY, client-side UserSig generation and TIM login.

Scenario: Initialize hospital and IM configuration

  • WHEN hospital initialization or hospital switching receives imAppID and imSecret
  • THEN the app maps them into the current hospital and user context
  • AND updates globalData.SDKAPPID and globalData.SECRETKEY
  • AND generates the legacy UserSig for the current IM user
  • AND initializes or refreshes TIM login.

Scenario: Reuse the generated room credentials

  • GIVEN the app has generated a UserSig through the approved legacy chain
  • WHEN an IM or TRTC room context is built
  • THEN the room receives the current SDKAppID, UserSig and IM user identifier
  • AND missing business or room identifiers still produce a normal error state.

Requirement: Resource Reuse Configuration

The app shell SHALL provide configuration and helper functions for legacy image host, upload URL, download URL, image URL joining, and image failure fallback.

Scenario: Server image reuse

  • WHEN a business module receives a server image path
  • THEN it can use the resource helper to join the configured server host
  • AND the app shell does not migrate server images into local static assets.