### Full app.json Configuration Example for DarkMode Source: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/darkmode.html This `app.json` example demonstrates how to configure `window` and `tabBar` properties using DarkMode variables defined in `theme.json`. It includes background colors, text styles, and icon paths for different themes. ```json { "window": { "navigationBarBackgroundColor": "@navBgColor", "navigationBarTextStyle": "@navTxtStyle", "backgroundColor": "@bgColor", "backgroundTextStyle": "@bgTxtStyle", "backgroundColorTop": "@bgColorTop", "backgroundColorBottom": "@bgColorBottom" }, "tabBar": { "color": "@tabFontColor", "selectedColor": "@tabSelectedColor", "backgroundColor": "@tabBgColor", "borderStyle": "@tabBorderStyle", "list": [{ "iconPath": "@iconPath1", "selectedIconPath": "@selectedIconPath1" }, { "iconPath": "@iconPath2", "selectedIconPath": "@selectedIconPath2" }] } } ``` -------------------------------- ### Example Response for Ad Unit List (get_adunit_list) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/ad/ad-data-interface.html This JSON example shows the data structure returned when requesting a list of configured ad units, including their IDs, names, and statuses. ```json { "base_resp":{ "err_msg":"ok", "ret":0 }, "ad_unit":[ { "ad_slot":"SLOT_ID_WEAPP_REWARD_VIDEO", "ad_unit_id":"adunit-e9418ee19XXXXX", "ad_unit_name":"rewaXXXX", "ad_unit_size":[ { "height":166, "width":582 } ], "ad_unit_status":"AD_UNIT_STATUS_ON", "ad_unit_type":"AD_UNIT_TYPE_REWARED_VIDEO", "appid":"wx0afc78670fXXXX", "video_duration_max":30, "video_duration_min":6 } ], "total_num":1 } ``` -------------------------------- ### Start Compass Sensor (JavaScript) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/plugin-intro.html The `wx.startCompass` API is used to begin listening for compass data. ```JavaScript wx.startCompass ``` -------------------------------- ### Example Response for Publisher Settlement Data (publisher_settlement) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/ad/ad-data-interface.html This JSON example demonstrates the structure of settlement and revenue data, including total revenue, settled amounts, and detailed settlement periods per ad slot. ```json { "base_resp":{ "err_msg":"ok", "ret":0 }, "body":"深圳市腾讯计算机系统有限公司", "penalty_all":0, "revenue_all":5178368698, "settled_revenue_all":2613696765, "settlement_list":[ { "date":"2020-03-25", "zone":"2020年3月1日至15日", "month":"202003", "order":1, "sett_status":1, "settled_revenue":718926045, "sett_no":"XXX", "mail_send_cnt":"0", "slot_revenue":[ { "slot_id":"SLOT_ID_WEAPP_BANNER", "slot_settled_revenue":34139443 }, { "slot_id":"SLOT_ID_WEAPP_REWARD_VIDEO", "slot_settled_revenue":684786602 } ] } ], "total_num":1 } ``` -------------------------------- ### Clone XNET Mini Program Repository and Install Dependencies Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/inference/tutorial_int8.html Use this command to clone the XNET Mini Program repository and install the necessary Python dependencies for the quantization tools. ```bash git clone https://github.com/wechat-miniprogram/xnet-miniprogram.git && cd xnet-miniprogram/nncs && pip install -r requirements.txt ``` -------------------------------- ### Start Accelerometer Sensor (JavaScript) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/plugin-intro.html The `wx.startAccelerometer` API is used to begin listening for accelerometer data. ```JavaScript wx.startAccelerometer ``` -------------------------------- ### Install Skyline Skills Source: https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/skyline/skills.html Use this command to add Skyline Skills to your project. ```bash npx skills add wechat-miniprogram/skyline-skills ``` -------------------------------- ### 配置 `app.json` 全局设置 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/config.html Use this `app.json` example to define global settings for your Mini Program, including page routes, window appearance, tab bar items, network timeouts, and debug mode. ```json { "pages": [ "pages/index/index", "pages/logs/index" ], "window": { "navigationBarTitleText": "Demo" }, "tabBar": { "list": [{ "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/logs/index", "text": "日志" }] }, "networkTimeout": { "request": 10000, "downloadFile": 10000 }, "debug": true } ``` -------------------------------- ### Mini-Program Exported Content Example Source: https://developers.weixin.qq.com/miniprogram/dev/framework/plugin/using.html An example of content exported from a mini-program's `index.js` file, which can then be accessed by the plugin. ```javascript // index.js module.exports = { whoami: 'Wechat MiniProgram' } ``` -------------------------------- ### open Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/voip-sdk/hal.html Calls the specified audio input/output device to obtain a device instance. ```APIDOC ## open ### Description Calls the specified audio input/output device to obtain a device instance. ### Function Signature ```c wx_error_t (*open)(struct wx_audio_module* module, const char* id, wx_audio_device_type_t device_type, struct wx_audio_device** device_out); ``` ### Parameters - **module** (struct wx_audio_module*) - context - **id** (const char*) - Same as `get_device_info`'s `id` - **device_type** (wx_audio_device_type_t) - Same as `get_number_of_devices`'s device_type - **device_out** (struct wx_audio_device**) - Returns the corresponding device instance. See subsequent `wx_audio_device` type description. ### Return Value - **wx_error_t** - The SDK uses this return value to determine if the obtained device instance is valid. - **Error Codes**: - **WXERROR_OK** - Success ``` -------------------------------- ### Example of Final Encrypted Reply (JSON) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/server-ability/message-push.html A complete example of an encrypted JSON reply message, demonstrating the populated fields after encryption and signature generation. ```json { "Encrypt": "ELGduP2YcVatjqIS+eZbp80MNLoAUWvzzyJxgGzxZO/5sAvd070Bs6qrLARC9nVHm48Y4hyRbtzve1L32tmxSQ==", "MsgSignature": "1b9339964ed2e271e7c7b6ff2b0ef902fc94dea1", "TimeStamp": 1713424427, "Nonce": "415670741" } ``` -------------------------------- ### Content JSON Example for Status 8 (After-sales Closed) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2007.html This example illustrates the `content_json` for an order where the after-sales ticket has been closed, requiring only the jump path. ```json {"cur_status":8,"wxa_path_query":"pages/index/index"} ``` -------------------------------- ### wx_init Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/voip/cloud-server-sdk.html Initializes the WMPF SDK, providing essential device information and starting its operations. This is an asynchronous function that requires network connectivity. ```APIDOC ## wx_init(const wx_init_config_t* config, wx_get_module_t get_module) ### Description Initializes the WMPF SDK. Before any other WMPF calls, `wx_init()` must be invoked to provide basic device information and start WMPF. This is an asynchronous function that makes network requests, so ensure network connectivity. ### Parameters - **config** (const wx_init_config_t*) - Required - Initialization parameters, containing initial device information. (nonnull) - **common** (wx_struct_t) - Common structure. - **log_dir** (const char*) - Optional - Directory for WMPF logs. If NULL, WMPF will not output logs. - **data_dir** (const char*) - Required - Directory for WMPF data files. Contains important, one-time registration information. Back up if clearing device data. - **product_id** (int) - Required - Product ID. Set to 0. - **host_appid** (const char*) - Required - HostAppID. Set to NULL. - **device_id** (const char*) - Required - Unique device identifier (SN), defined by the manufacturer. - **device_signature** (const char*) - Required - Device signature. Set to NULL. - **device_signature_version** (int) - Required - Device signature version. Set to 0. - **model_id** (const char*) - Required - Model ID, obtained from the Mini Program admin backend during device access. Important credential for Mini Program device-related interfaces. - **wxa_appid** (const char*) - Required - Mini Program AppID. Required for VoIP scenarios. - **wxa_flavor** (wx_wxa_flavor_t) - Required - Mini Program version (release, debug, demo). Consult Mini Program developers for debug/experience versions. - **rpmb_device** (const char*) - Optional - RPMB device path (e.g., /dev/mmXXXXX) if RPMB is available and Key is writable. - **h265_only** (bool) - Optional - If true, only H265 is supported for video streams. If false, WeChat VoIP backend adapts. If true, both sending and receiving will be H265. - **video_landscape** (bool) - Optional - If true, SDK receives 4:3 video streams (e.g., 320x240). If false, 3:4 (e.g., 240x320). - **subscribe_video_length** (int) - Optional - Subscribes to a specific video resolution's long edge (320 or 640). Requires WeChat backend activation. 320: 320x240 (landscape) or 240x320 (portrait). 640: 480x640 (portrait only). - **subscribe_video_rotation** (int) - Optional - Subscribes to a specific video stream rotation. 1: 0-degree stream. Others: rotated stream (default). Beta feature. - **subscribe_video_ratio** (int) - Optional - Subscribes to a specific video stream aspect ratio (e.g., 75 for 240x320, 133 for 320x240). Beta feature. - **subscribe_video_maxfps** (int) - Optional - Subscribes to a maximum FPS for received video streams (5-15). Beta feature. - **get_module** (wx_get_module_t) - Required - Callback function for WMPF to get vendor-provided interfaces. (nonnull) ### Return Value - **wx_operation_t** - Returns an operation handle. ### Error Codes - **WXERROR_INVALID_ARGUMENT**: Invalid input parameters, or product ID, device ID, device signature mismatch. - **WXERROR_TIMEOUT**: Timeout. - **WXERROR_RESOURCE_EXHAUSTED**: Network not connected or local disk write failed. - **WXERROR_FAILED_PRECONDITION**: Device not registered via adddevice, `wx_init` already called, or incorrect system time. - **WXERROR_INTERNAL**: Other internal errors. ``` -------------------------------- ### Content JSON Example for Status 7 (After-sales Ended) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2007.html This example provides the `content_json` for an order where after-sales service has concluded, requiring only the jump path. ```json {"cur_status":7,"wxa_path_query":"pages/index/index"} ``` -------------------------------- ### Content JSON Example for Ticket Status: Expired (cur_status: 10) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Expired' status. Only the mini-program path is required. ```json "{\"cur_status\":10, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Example Mini Program Directory Structure with Subpackages Source: https://developers.weixin.qq.com/miniprogram/dev/framework/subpackages/basic.html Illustrates the recommended directory layout for a WeChat Mini Program that utilizes subpackages, showing how `packageA` and `packageB` are organized alongside the main package. ```plaintext ├── app.js ├── app.json ├── app.wxss ├── packageA │ └── pages │ ├── cat │ └── dog ├── packageB │ └── pages │ ├── apple │ └── banana ├── pages │ ├── index │ └── logs └── utils ``` -------------------------------- ### Run Quantization Training Script Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/inference/tutorial_int8.html Execute this command from the project root to start the quantization-aware training process for the ImageNet classification demo. ```bash cd demo/imagenet_classification && python train_imagenet_onnx.py ``` -------------------------------- ### Content JSON Example for Ticket Status: Refunding (cur_status: 6) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Refunding' status. Only the mini-program path is required. ```json "{\"cur_status\":6, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Example Worker directory structure Source: https://developers.weixin.qq.com/miniprogram/dev/framework/workers.html Illustrates the recommended directory structure for Worker files, showing how multiple worker entry points and utility files can be organized. ```text ├── app.js ├── app.json ├── project.config.json └── workers ├── request │ ├── index.js │ └── utils.js └── response └── index.js ``` -------------------------------- ### Content JSON Example for Ticket Status: Used (cur_status: 5) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Used' status. Only the mini-program path is required. ```json "{\"cur_status\":5, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Content JSON Example for Ticket Status: To Be Used (cur_status: 4) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'To Be Used' status. Only the mini-program path is required. ```json "{\"cur_status\":4, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Implement hal_get_module for Hardware Abstraction Layer in C Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/voip-sdk/hal.html This example demonstrates how to implement the `hal_get_module` function to return specific `wx_module` instances (audio, camera, crypto) based on their IDs. It returns `WXERROR_UNIMPLEMENTED` if a module is not supported, such as `wx_video_module` on a device without a screen. ```C // 假设已经实现了如下module: extern struct wx_audio_module audio_module; extern struct wx_camera_module camera_module; extern struct wx_crypto_module crypto_module; // 现实现HAL获取Module的函数如下: wx_error_t hal_get_module(const char* id, struct wx_module** module_out) { if (!strcmp(id, WX_AUDIO_MODULE_ID)) { *module_out = (struct wx_module*)&audio_module; return WXERROR_OK; } else if (!strcmp(id, WX_CAMERA_MODULE_ID)) { *module_out = (struct wx_module*)&camera_module; return WXERROR_OK; } else if (!strcmp(id, WX_CRYPTO_MODULE_ID)) { *module_out = (struct wx_module*)&crypto_module; return WXERROR_OK; } // 假设当前设备没有屏幕,因此不需提供 wx_video_module,那么就返回 WXERROR_UNIMPLEMENTED return WXERROR_UNIMPLEMENTED; } ``` -------------------------------- ### Update SelectorQuery IDs to not start with numbers Source: https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/glass-easel/migration Selector IDs in `SelectorQuery` must now follow CSS selector rules and cannot start with a number. Rename IDs to comply with this standard. ```javascript this.createSelectorQuery() .select('#1') .exec(res => { }) ``` ```javascript this.createSelectorQuery() .select('#element-1') .exec(res => { }) ``` -------------------------------- ### Verify Mini Program Plugin Introduction (JavaScript) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/voip-plugin/index_camera.html Use `requirePlugin` to import the plugin and log its default export to confirm successful integration. ```javascript const wmpfVoip = requirePlugin('wmpf-voip').default console.log(wmpfVoip) // 有结果即表示引入插件成功 ``` -------------------------------- ### Content JSON Example for Ticket Status: Order Canceled (cur_status: 9) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Order Canceled' status. Only the mini-program path is required. ```json "{\"cur_status\":9, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### 小程序冷启动时根据用户角色重定向到不同首页 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/app-service/route-rewrite.html 在小程序冷启动(`appLaunch`)且特定场景下,根据 `wx.getStorageSync` 中存储的用户角色(如顾客或商家),通过 `wx.rewriteRoute` 将用户重定向到对应的首页。 ```javascript wx.onBeforeAppRoute(res => { if (res.openType === 'appLaunch') { const enterOptions = wx.getEnterOptionsSync() if (enterOptions.scene === 1089) { const userRole = wx.getStorageSync('user-role') if (userRole === 'customer') { wx.rewriteRoute({ url: '/pages/customer-index/index' }) } else if (userRole === 'merchant') { wx.rewriteRoute({ url: '/pages/merchant-index/index' }) } else { /* do nothing */ } } } }) ``` -------------------------------- ### Content JSON Example for Ticket Status: Refund Failed (cur_status: 8) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Refund Failed' status. Only the mini-program path is required. ```json "{\"cur_status\":8, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### wx.getUserInfo 正确用法: 在应用 onLaunch 中调用 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/performance/api-frequency.html 此代码片段展示了 wx.getUserInfo 的正确用法,在小程序启动时 (onLaunch) 调用一次,以减少接口调用频率。 ```javascript App({ onLaunch() { wx.getUserInfo() } }) ``` -------------------------------- ### Content JSON Example for Ticket Status: Refund Successful (cur_status: 7) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Refund Successful' status. Only the mini-program path is required. ```json "{\"cur_status\":7, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Content JSON Example for Ticket Status: Issuance Failed (cur_status: 3) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Issuance Failed' status. Only the mini-program path is required. ```json "{\"cur_status\":3, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### Start Device Motion Listening (JavaScript) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/user-privacy/plugin-intro.html The `wx.startDeviceMotionListening` API is used to begin listening for device motion data, including orientation. ```JavaScript wx.startDeviceMotionListening ``` -------------------------------- ### init Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/device-register-sdk.html SDK 初始化。其它接口在调用之前需要保证 init 成功。 ```APIDOC ## init ### Description SDK initialization. Other interfaces require successful initialization before being called. ### Method Signature ```java boolean init() ``` ``` -------------------------------- ### Content JSON Example for Status 2 (In Production) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2007.html This example illustrates the `content_json` for an order currently in production, including product details, queue number, and estimated wait times. ```json {"cur_status":2,"product_count": 5,"product_list":{"info_list":[{"product_img":"https://res.wx.qq.com/op_res/DiSd8fVjXuHr5K9U73oRr74fMqnT5r9_GmI3mbfLOn2RpC_aENIPjYPPhPN_YnNKnUhyuAy8yLqNRAlh_JCsWQ","product_name":"阿白","product_path_query":"pages/index/index"}]},"queue_number": "S0121","min_wait_time": 600,"max_wait_time": 900,"wxa_path_query":"pages/index/index"} ``` -------------------------------- ### 获取文件系统管理器 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/ability/file-system.html 在使用文件系统功能前,需要先通过 wx.getFileSystemManager() 获取全局唯一的文件系统管理器实例。 ```javascript var fs = wx.getFileSystemManager() ``` -------------------------------- ### wx.bindEmployeeRelation Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/laboruse/intro.html 开发者可以通过接口,给与小程序有用工关系的用户调用订阅弹窗,允许后的用户,可以在「小程序助手」插件中收到绑定系统消息。 ```APIDOC ## wx.bindEmployeeRelation ### Description Developers can use this interface to prompt users with an employment relationship to the mini-program to subscribe. After permission, users can receive binding system messages in the "Mini Program Assistant" plugin. ### Method Signature `wx.bindEmployeeRelation(Object object)` ### Parameters - **object** (Object) - Required - Configuration object for the API call. (No specific fields provided in source) ### Example Usage ```javascript wx.bindEmployeeRelation({ success(res) { console.log('Binding successful', res); }, fail(err) { console.error('Binding failed', err); } }); ``` ``` -------------------------------- ### JSON Example for Status ID 1: 已支付 (Paid) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2009.html Example JSON payload for updating a flight status to 'Paid'. This status requires flight details and a Mini Program path. ```json {"cur_status":1,"flight_no": "CA1000","planned_departure_time": 1690855200,"planned_arrival_time": 1690869600,"departure_city": {"domestic_region":"广州市", "domestic_poi":"ABC大酒店","oversea_areas":"莫斯科"}, "arrival_city": {"domestic_region":"北京市", "domestic_poi":"人民广场","oversea_areas":"莫斯科","wxa_path_query":"pages/index/index"}} ``` -------------------------------- ### Retrieve Plugin Startup Parameters Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/voip-plugin/api/getPluginEnterOptions.html This snippet demonstrates how to use `getPluginEnterOptions` from the `wmpf-voip` plugin to obtain the startup parameters when a mini-program is entered from a plugin page. ```javascript const wmpfVoip = requirePlugin('wmpf-voip').default const query = wmpfVoip.getPluginEnterOptions() ``` -------------------------------- ### Configure Page Restart Strategy for Cold Start Source: https://developers.weixin.qq.com/miniprogram/dev/framework/runtime/operating-mechanism.html Apply this configuration in a page's JSON file or app.json to define the page behavior during a cold start when no specific path is provided. ```JSON { "restartStrategy": "homePage" } ``` -------------------------------- ### Content JSON Example for Ticket Status: Paid (cur_status: 1) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2011.html This example shows the `content_json` structure for a ticket in 'Paid' status. It includes product details, start/expiration times, and a mini-program path. ```json "{\"cur_status\":1, \"product_list\":{\"info_list\":[{\"product_img\": \"https://res.wx.qq.com/op_res/DiSd8fVjXuHr5K9U73oRr-0imv0GklZrlRRj_mZmbnO0jT349XT-qIzT_DmjQsDLSO3xZbUTbOP--HA_BosOoA\", \"product_name\":\"TIT创意园\", \"product_path_query\":\"pages/index/index\", \"count\": 1, \"single_price\": 111}]}, \"start_use_time\": 1690819200, \"expiration_time\": 1690905599, \"wxa_path_query\":\"pages/index/index\"}" ``` -------------------------------- ### wx.getSetting 正确用法: 缓存结果并按需调用 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/performance/api-frequency.html 此代码片段展示了 wx.getSetting 的正确用法,通过缓存接口返回结果并在需要时检查权限,避免不必要的频繁调用。 ```javascript let setting wx.getSetting({ success(res) { setting = res } }) // 在需要获取地理位置时 if (setting.authSetting['scope.userLocation']) { wx.getLocation({ success(res) {}, fail(res) { if (res.errMsg.indexOf('auth deny') >= 0) { // 如果权限没有开,引导用户打开设置页开启地理位置授权 } } }) } ``` -------------------------------- ### JSON Example for Status ID 16: 航班已取消 (Flight Cancelled) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2009.html Example JSON payload for updating a flight status to 'Flight Cancelled'. This status primarily requires a Mini Program path. ```json {"cur_status":16,"wxa_path_query":"pages/index/index"} ``` -------------------------------- ### 获取蓝牙低功耗设备服务 Source: https://developers.weixin.qq.com/miniprogram/dev/framework/device/ble.html 连接成功后,调用 `wx.getBLEDeviceServices` 获取设备提供的所有服务。开发者可以根据业务需求选择一个主服务进行后续通信。 ```javascript wx.getBLEDeviceServices({ deviceId, // 搜索到设备的 deviceId success: (res) => { for (let i = 0; i < res.services.length; i++) { if (res.services[i].isPrimary) { // 可根据具体业务需要,选择一个主服务进行通信 } } } }) ``` -------------------------------- ### JSON Example for Status ID 15: 订单已取消 (Order Cancelled) Source: https://developers.weixin.qq.com/miniprogram/dev/framework/open-ability/subscribe-message-template/2009.html Example JSON payload for updating a flight status to 'Order Cancelled'. This status primarily requires a Mini Program path. ```json {"cur_status":15,"wxa_path_query":"pages/index/index"} ```