Create portable QR scanning page module with: - WeChat native camera integration with overlay system - Animated QR targeting arcs and visual feedback - Torch/flash controls and camera setup - Inline modal system (verification, guide, service) - Return page navigation support via query parameter - Debug overlay and device detection - Complete asset bundle (arc.png, qrmarkers.png, buttons) Module can be integrated into other WeChat Mini Programs by copying pages/emblemscanner/ directory. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
6.0 KiB
6.0 KiB
QR Scanner Module Development Progress
Project Goal
Create a self-contained, portable QR scanning page module that can be easily integrated into other WeChat Mini Programs. The module should include all scanning functionality in a single directory and accept an entry query parameter to redirect to different pages upon successful scan and verification.
Feature Checklist - Extracted from Existing Code
✅ Core QR Processing
- WebAssembly QR Tool Integration -
qrtool.wx.jslibrary for QR code processing (TODO: Add library) - Dual Processing Modes:
- Worker-based processing (iPhone devices) -
worker/index.js(TODO: Implement) - Synchronous processing (Android devices) -
precheck.js(TODO: Implement)
- Worker-based processing (iPhone devices) -
- QR Pattern Validation - Emblem-specific QR code pattern matching (TODO: Add validation)
- Frame Pre-checking - Validate QR frames before full processing (TODO: Implement)
- Angle Detection - QR code angle detection and correction (TODO: Implement)
✅ Camera System
- Native Camera Interface - WeChat camera component integration ✅
- Web-view Camera Fallback -
pages/camwebview/for problematic devices (TODO: Add fallback) - Device-specific Camera Rules - API-driven zoom and camera settings per phone model (TODO: Implement API integration)
- Dynamic Zoom Control - Initial zoom + QR-found zoom adjustment (TODO: Implement)
- Torch/Flash Control - Manual and automatic torch management ✅
- Auto-torch Detection - API-based torch recommendation system (TODO: Implement API integration)
✅ UI Components & Visual Feedback
- QR Targeting Overlay - Animated corner arcs for QR positioning ✅
- Visual State Indicators - Progress states (searching, found, verifying) ✅
- Hint Text System - Dynamic user guidance messages ✅
- Debug Overlay - Development/diagnostic information display ✅
- Modal System: ✅
- Verification spinner (
verifyspin) ✅ - Failed verification (
verifyfailed) ✅ - Scan guide tutorial (
scanguide) ✅ - Service modal (
servicemodal) ✅ - Tooltip component (
tooltip) ✅
- Verification spinner (
✅ API Integration & Data Flow
- Image Upload System - Multi-frame submission to backend
- Verification Pipeline - QR code verification with themblem.com API
- Camera Rules API - Device-specific camera configuration fetching
- Auto-torch API - Torch recommendation based on QR code
- Event Tracking - Frame upload and analytics events
- Session Management - Unique session ID generation and tracking
✅ Phone Model & Runtime Configuration
- Device Detection - Phone model identification and global data storage
- Processing Mode Selection - Worker vs synchronous based on device type
- Camera Sensitivity Adjustment - Device-specific camera sensitivity settings
- Performance Optimization - Frame upload throttling and batch processing
✅ Navigation & Integration
- Entry Point Configuration - Support for return page query parameter ✅
- Return Page Routing - Navigate to specified page after successful scan and verification ✅
✅ Error Handling & Recovery
- Verification Failure Flow - Retry and service contact options
- Upload Failure Recovery - Network error handling
- Worker Failure Fallback - Graceful degradation to sync mode
- Camera Permission Handling - User permission flow management
✅ Assets & Resources
- Static Image Assets:
- QR targeting arcs (
/static/arc.png) - QR positioning markers (
/static/qrmarkers.png) - UI action icons (
/assets/play-button.png,/assets/flash-button.png)
- QR targeting arcs (
- WebAssembly Binary -
qrtool.wx.jsQR processing library - Animation Assets - Lottie animations for loading states
Module Structure Design
/qr-scanner-module/
├── qr-scanner.js # Main page logic
├── qr-scanner.wxml # UI template
├── qr-scanner.wxss # Styling
├── qr-scanner.json # Page configuration
├── lib/
│ ├── qrtool.wx.js # WebAssembly QR library
│ ├── precheck.js # QR validation logic
│ ├── upload.js # API communication
│ └── utils.js # Utility functions
├── components/ # UI components
│ ├── tooltip/
│ ├── verifyspin/
│ ├── verifyfailed/
│ ├── scanguide/
│ └── servicemodal/
├── worker/
│ └── index.js # WebAssembly worker
└── assets/ # Static resources
├── images/
└── animations/
Integration Requirements
Required Query Parameters
return_page- Target page to navigate to after successful verification
Required Global Dependencies
- WeChat Mini Program camera API
- WebAssembly support
- Worker thread support (iOS)
- Canvas 2D context for image processing
External API Dependencies
{server_url}/api/v1/camera-rules/- Camera configuration{server_url}/api/v1/check-auto-torch/- Torch recommendations- Verification endpoint for QR code validation
- Event tracking endpoints
Success Criteria
- Self-contained Module - All functionality within single directory
- Platform Portability - Easy integration into other mini programs
- Device Compatibility - Support for iOS/Android with appropriate fallbacks
- Performance Optimization - Efficient WebAssembly + Worker threading
- Robust Error Handling - Graceful failure modes and user feedback
- Configurable Integration - Flexible redirect and mode parameters
- Asset Independence - Bundled resources with minimal external dependencies
Current Status: PLANNING PHASE ⏳
Next steps:
- Create module directory structure
- Extract and consolidate existing code
- Implement portable integration interface
- Test cross-platform compatibility