# Wearable device Weixin Mini Program framework
# 1. Product Description
Weixin Mini Program framework has been adapted to watch wearable devices, can be for RTOS (real-time operating system) and other low-power device scenarios, to achieve the minimum available Weixin Mini Program operation.
# 2. technology program
Due to the limited CPU performance and memory size of mainstream wearable devices in the market (less than 8M of total memory), we have implemented the smallest available Weixin Mini Program framework, providing:
- Familiar with WXML + WXSS + JS Weixin Mini Program development experience
- The most necessary Weixin Mini Program wx interface
- Basically complete Weixin Mini Program page framework and component system
- Basic WXSS styles and built-in component support
- Weixin Mini Program Package Compiler
- Simulating the debugging environment
Hardware resources for wearable devices are very limited.In order to reduce the storage footprint, the Weixin Mini Program framework provides only a subset of ordinary Mini Programs, and developers are requested to implement Mini Programs in strict accordance with the feature list provided in this document. Due to the large differences in interface capabilities, it is generally necessary for developers to develop new Mini Programs for the wearable device separately.
# 2.1 UI capabilities
# 2.1.1 Component Framework
You can use the Page, Component capabilities in Weixin Mini Program.Supports complete WXML, WXSS syntax.
# 2.1.1.1 Features supported
You can use App, getApp, Page, getCurrentPages, Component in Weixin Mini Program.Supports ES6 import / export and CommonJSrequire two JS module loading mechanisms.
# 2.1.1.2 Differences in use
Note the following differences when using the Weixin Mini Program component framework:
- The styleIsolation of a component needs to be configured in JSON and is not supported in component options
- Addglobalclass is no longer supported. Please use styleIsolation instead
- When using inter-component communication and events , you can define the export attribute directly without declaring
wx://component-export。
# 2.1.1.3 Features not yet supported
The following capabilities are not currently supported
behavior
WXS
The following methods for custom component are not supported:
- createSelectorQuery
- createIntersectionObserver
- createMediaQueryObserver
- getTabBar
- animate
- clearAnimation
- applyAnimatedStyle
- clearAnimatedStyle
- setUpdatePerformanceListener
# 2.1.2 Built-in components
Only the following built-in components are currently supported
# 2.1.2.1 view
Attributes: none
# 2.1.2.2 image
Attributes:
| attribute | type | Default values | Required to fill in | Introductions |
|---|---|---|---|---|
| src | string | no | Image resource address. If you use a picture resource in a code package, src must be an absolute path. |
Dxplaination:
- It is not recommended that high-definition pictures be displayed. Some wearable devices have a screen resolution edge of only 200-300 pixels, and have limited memory, too large images cannot be rendered clearly and may cause memory overflow.
- It is not recommended to use the picture component to display Weixin Mini Program code, two-dimensional code, bar code, etc. It is recommended to use the qrcode component.
# 2.1.2.3 text
Attributes: none
# 2.1.2.4 qrcode
A proprietary component of the Weixin Mini Program framework for wearable devices, capable of generating and rendering binary code based on input text.
Given resource consumption, wearable devices are not advised to use pictures to display QR codes.
For the need to show the Weixin Mini Program code, you can refer to the [scan ordinary link two-dimensional code open Mini Program
。
| attribute | type | Required to fill in | Default values | Introductions |
|---|---|---|---|---|
| value | string | no | "" | QR code text content |
| light-color | HexColor | no | #000000 | QR code color |
| dark-color | HexColor | no | #FFFFFF | QR code background color |
# 2.1.2.5 scroll-view
| attribute | type | Default values | Required to fill in | Introductions |
|---|---|---|---|---|
| enable-flex | boolean | false | no | Enable flexbox layout. When turned on, the front nodal point declares display: flex to be the flexcontainer and acts on its child nodes. |
# 2.1.2.6 swiper/swiper-item
swiper support attributes:
| attribute | type | Default values | Required to fill in | Introductions |
|---|---|---|---|---|
| current | number | 0 | no | Index of the current slider |
| bind:change | eventhandle | no | A change event is triggered when current changes, event.detail = {current, source} |
# 2.1.3 WXSS Styles
- Display: block / flex (flexible box layout supported), inline / inline-block / inline-flex / grid not supported
- Position absolute layout (top, right, bottom, left)
- Width, height, margin, padding and other component size settings
- color and other text attributes
- Border-related properties: border-radius does not support setting the size of the four corners separately, and does not support the percentage writing.
- Background related attributes: background-image, background-color
- Font settings such as font-size are not supported
Subelement selectors, descendent selectors and successor selectors are not supported; if you have related development needs, implement them with a normal selector.
Note: WXML supports inline styles, but not binding (you cannot modify the style attribute value of a WXML component with setData ()).
# 2.2 Weixin Mini Program Configuration
# 2.2.1 app.json
# Configuration items:
| attribute | type | Required to fill in | Introductions |
|---|---|---|---|
| entryPagePath | string | no | Weixin Mini Program Default Start Home |
| pages | string[] | yes | List of page paths |
| networkTimeout | Object | no | Network Overtime |
| window | Object | no | Default window performance for the entire world |
| usingComponents | Object | no | Global custom component configuration |
# window:
Used to set Weixin Mini Program's view bar, navigation bar, title, window background. The wearable Mini Program framework only supports setting the window background color.
| attribute | type | Required to fill in | Default values | Introductions |
|---|---|---|---|---|
| backgroundColor | HexColor | no | #FFFFFF | The background color of the window |
# networkTimeout
The timeout time of all types of network requests is milliseconds.The Weixin Mini Program framework only supports setting the timeout time for requests.
| attribute | type | Required to fill in | Default values | Introductions |
|---|---|---|---|---|
| request | number | no | 60_000 | Timeout of wx.request in milliseconds. |
# 2.2.2 component.json
# Configuration items
| attribute | type | Required to fill in | Introductions |
|---|---|---|---|
| component | boolean | no | A custom component consists of JSON, WXML, WXSS, JS 4 files. If you set component to true, you declare this set of files as a custom component |
| styleIsolation | string | no | Style isolation |
| usingComponents | Object | no | Global custom component configuration |
# styleIsolation
| value | Introductions |
|---|---|
| isolated | Enables style isolation so that styles specified with class will not affect each other inside and outside of custom components (default in general) |
| apply-shared | Indicates that the page wxss style will affect the custom component, but the style specified in the custom component wxss will not affect the page |
| shared | Indicates that the page wxss style will affect the custom component, and the style specified in the custom component wxss will also affect the page and other custom components that are set up to apply-shared or shared. |
# 2.2.3 page.json
Each Weixin Mini Program page can use the same name.jsonfile to configure the window behavior of the page, and the configuration items in the page overlap the same configuration items in apagejson window.
# Configuration items:
| attribute | type | Required to fill in | Default values | Introductions |
|---|---|---|---|---|
| backgroundColor | HexColor | no | #FFFFFF | The background color of the window |
# 2.3 Interface capabilities
- The JSAPI invocation method is consistent with the complete version, supporting callback and Promise two forms of invocation, please refer to the relevant documentation for details.
- This section only explains the differences between the complete version and the complete version, please refer to the official website documentation for the complete API interface. In order to avoid repetition, this article omits the explaination of the success / fail / complete callback function in the parameter, such as no special explaination, all provide the success / fail / complete callback interface consistent with the complete version
# 2.3.1 WeChat Ecological capacity
- Wx.login: Consistent
- Wx.checksession: Consistent
- wx.getAccountInfoSync: consistent
# 2.3.2 System Information
- Wx.getwindowinfo: Consistent. Additional return value screenShape.
- Wx.getDeviceInfo: Only supports returning brand, model, system, platform, cpuType, memorySize. Additional return value deviceType.
New Return Value for wx.getWindowInfo
| attribute | type | Introductions |
|---|---|---|
| screenShape | string | Rect: square screen; Round Round Screen |
New Return Value for wx.getDeviceInfo
| attribute | type | Introductions |
|---|---|---|
| deviceType | string | Optional values: watch, phone, tv, vehicle, pc |
NOTE:
This framework does not providewx.getSystemInfoseries interface, please usegetWindowInfo / getDeviceInfoinstead.
# 2.3.3 Network requests
wx.request()
- Parameters only support url, data, header, timeout, method (only support GET, POST), dataType, responseType, redirect.
- The returned RequestTask only supports abort
- The success callback parameter supports only data, statusCode, header
- Fail Callback Parameters Consistent
Be careful
- File system support is not currently available, so wx.downloadFile / wx.uploadFile is not supported at this time.
- Currently only https is supported, and other types of network requests such as TCP, UDP, WebSocket are not supported.
# 2.3.4 Page routing
- Wx.navigateto: Parameters only support url
- wx.navigateBack: Consistent
- Wx.redirectTo: Consistent
- Wx.relaunch: Consistent
Note: ThetabBar is not available yet
# 2.3.5 Data storage
- wx.getStorageInfo (sync): Consistent
- Wx.setstorage (Sync): Parameters only support key, data
- Wx.getstorage (Sync): Parameters only support key
- Wx.removestorage (Sync): Consistent
- Wx.clearstorage (Sync): Consistent
Be careful
- Currently only KV storage is provided, file storage is not provided.
- Encrypted storage is not supported for now
# 2.3.6 UI
- Wx.showtoast: Consistent
- Wx.hidetoast: noConflict is not supported, toast and loading are not mixed by default
- Wx.showloading: Consistent
- Wx.hideloading: noConflict is not supported, toast and loading are not mixed by default
- wx.showModal: The parameter does not support editable and placeholderText.
- Wx.getMenuButtonBoundingClientRect: Consistent
Note: No navigationBar, tabBar, homeButton
# 2. 3.7 Life Cycle
- Wx.getlaunchoptionssync: Parameters only support path, scene, query
- Wx.getenteroptionssync: Parameters only support path, scene, query
- Wx.onunhandledrejection: Consistent
- Wx.onerror: Consistent
- Wx.onpagenotfound: Consistent
- Wx.onAppShow: Parameters only support path, scene, query
- Wx.onapphide: Consistent
# 2.3.8 Events
- bind:touchstart
- bind:touchend
- bind:tap
- bind:longpress
Where event objects only support type, target, currentTarget fields, and target / currentTarget only supports dataset fields.
# 2.3.9 Others
- Console.log / info / error / warn / debug: The output is printed in the emulator's command line window and can be used to debug Weixin Mini Program logic via console.log.
- setTimeout/clearTimeout
- setInterval/clearInterval
# 2.4 Other differences
- Weixin Mini Program plugin is not supported
- Weixin Mini Program Subcontracting is not supported
# 3. The development process
# 3.1 Register a wearable device Weixin Mini Program Framework-AppID
Preconditions: The name needs to have a common Weixin Mini Program AppID, and as the administrator of the Mini Program.
Steps:
- Open WeChat developer platform
- Sign in by scanning code
- Click "Go to the console"
- Select "My Business -- Weixin Mini Program"
- In the upper right corner of the page, switch to the ordinary Mini Program that the wearable device Weixin Mini Program wants to attach to.
- Switch to Hardware Settings
- Click on "Request to create"
! [Request to create] (https://res.wx.qq.com/op_res/A16GIDL5mvuCu5bJb5xkqWfGBiXIFRceEDDVijk9h1O-SxFIiuYXYfj8_40BQg6-Cck8CO_oAt056O73Ia8zyQ )
- Create success, get "wearable AppID"
! [Created successfully] (https://res.wx.qq.com/op_res/A16GIDL5mvuCu5bJb5xkqdvnIOps_GPn8C5hUz1jPqBby0mcrNc4cVcj86i0FC9ZvJaeOOKSOgGbPigsiWbSww )
# 3.2 Install Developer Tools Extension
- Open "WeChat Developer Tools" (version number ≥ 2.01.2507252 is required, it is recommended to download the latest nightly version of developer tools for use)
- Select Settings - Expand Settings in the toolbar
- In the pop-up page, select the left side of the "Mimic plug-in" and the right side of the installation of "low power hardware Weixin Mini Program mode"
# 3.3 Enable low power Weixin Mini Program mode
After installing the plug-in, switch development mode to "Low Power Hardware Weixin Mini Program mode"
# 3.4 Development debugging
Click "Details" to make sure that the AppID is set up with the WeChat developer platform.
We do not recommend that developers compile JS code to ES5.Wearable Weixin Mini Program framework supports ES2023, and reducing unnecessary polyfill helps to significantly save the final Mini Program code package volume, which in turn saves runtime memory footprint.
# 3.5 Experience and release
When you are finished developing, click Upload in the WeChat Developer Tools.The newly uploaded version overrides the old "Development Version Weixin Mini Program."
Developers can go to WeChat Developer Platform to manage Weixin Mini Program versions, submit them for review, and publish them online.
# 4. Contact Us
Interested hardware manufacturers, Weixin Mini Program developers, welcome to contact us by email:wx_iot@tencent.com。