--- alwaysApply: true --- # Trae AI Coding Rules for Book-Hi ## 1. Project Context & Technology Stack - **Framework**: uni-app + Vue 2 - **UI Library**: uView UI v1 (Prefix: `u-`, no import needed for `easycom` components) - **CSS**: SCSS with `scoped`, use `rpx` for responsiveness. - **State Management**: Vuex (`store/`) - **Environment**: `.env.js` manages `apiUrl`. ## 2. Architecture & Directory Structure - **Main Package**: `pages/` (Tabbar pages only: home, mine, sell, cart). - **Subpackages**: - `pages-sell`: Mall/Selling features. - `pages-car`: Shopping cart & Order flow. - `pages-mine`: User center sub-pages. - `pages-home`: Home sub-pages. - **Static Assets**: - Global: `static/` - Subpackage-specific: `pages-xxx/static/` ## 3. Development Guidelines ### 3.1 API Integration (Strict) - **Configuration**: `api/config.js` (Interceptor handles token & errors). - **Definition**: - **Location**: `api/modules/*.js` (e.g., `mall.js`, `user.js`). - **Naming**: Suffix with `Ajax` (e.g., `getGoodsListAjax`). - **Format**: `(params) => uni.$u.http.post('/path', params)` - **Usage**: - **Standard**: `this.$u.api.methodName(params).then(res => ...)` - **Direct**: `uni.$u.http.post('/path', params).then(res => ...)` (Allowed for simple/temp requests) - **Response Handling**: - Success: `res.code == 200` - Error: Handled globally by interceptor (Toast), `401` triggers silent login. ### 3.2 Component Development - **Global**: `components/` (Register in `main.js` if generic). - **Local/Business**: `pages-xxx/components/` (Import locally). - **uView Usage**: Use `u-` components directly (e.g., ``, ``). ### 3.3 Routing - **Jump**: `uni.navigateTo` for subpages, `uni.switchTab` for tabbar. - **Path**: ALWAYS use absolute paths (e.g., `/pages-sell/pages/detail`). ### 3.4 Styling - **Scoped**: `