# WIF-UTS-Plugin **Repository Path**: wif-netfly/wif-uts-plugin ## Basic Information - **Project Name**: WIF-UTS-Plugin - **Description**: 网飞系统服务调用 uniapp uts插件 演示demo,插件地址:https://ext.dcloud.net.cn/plugin?id=21336 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2024-12-17 - **Last Updated**: 2025-01-06 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # WIF-UTS-Plugin # 插件集成说明 ## 插件引入 将uts插件`wif-service`放入项目的`uni_modules`目录下,在界面中导入相应插件功能,如下: ```js // 导入要使用的插件 import { bindService, requestBrightnessAdj, requestVolumeAdj, //..... } from "../../uni_modules/wif-service"; ``` ## 初始化 在使用插件功能之前,需要先进行初始化,初始化成功后即可使用其他功能: `返回值 bind 为 true 即为初始化成功` ```js onLoad() { bindService({ result: (bind) => { console.log("bindService response bind:" + bind) } }); } ``` ## 功能说明 ### 操作回调处理 插件操作的回调处理函数,用于根据返回的 `resultCode` 显示操作的成功或失败信息: ```js const SUCCESS = 1; const FAIL = 0; const ERROR = -1; // 操作回调处理 handleResponse(res) { let resultCode = res.code; if (resultCode === SUCCESS) { this.showToast("操作成功"); } else { this.showToast("操作失败:" + res.msg); } } ``` --- ### 插件功能接口 #### 1. **重启设备** 此接口实现网飞设备的重启。 ```js btnResetDevice() { requestReboot({ response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) }, ``` **返回结果:** ```bash {"code":1,"msg":"","type":"reboot"} ``` --- #### 2. **显示和隐藏状态栏(霸屏)** 此接口实现状态栏和导航栏的全局隐藏,适用于前台应用的霸屏显示。 `isChecked 为 true 或 false` ```js requestStatusBar({ param: isChecked, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"status_bar"} ``` --- #### 3. **打开和关闭热点** 此接口实现设备热点的打开和关闭。 `isChecked 为 true 或 false` ```js requestHotspot({ param: isChecked, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"hotspot"} ``` --- #### 4. **打开和关闭WIFI** 此接口实现设备WIFI的打开和关闭。 `isChecked 为 true 或 false` ```js requestWifi({ param: isChecked, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"wifi"} ``` --- #### 5. **设置音量** 此接口实现设备音量的调节(范围:0-100)。 ```js requestVolumeAdj({ param: volumeLastValue, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"volume"} ``` --- #### 6. **设置亮度** 此接口实现设备亮度的调节,亮度请求参数值为百分比含义,例如参数为 6 时,指的是调节为最大亮度的 6%。 ```js requestBrightnessAdj({ param: lastValue, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"brightness"} ``` --- #### 7. **恢复出厂设置** 此接口实现设备的恢复出厂设置。 ```js requestFactoryReset({ response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"factory_reset"} ``` --- #### 8. **设置热点** 此接口实现热点名称和密码的配置。 `参数 arg1 为热点的名称,arg2 为热点的密码` ```js requestHotspotConfig({ arg1: this.hot_ssid, arg2: this.hot_pwd, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"hotspot_config"} ``` --- #### 9. **静默安装** 此接口实现应用的静默安装。 ```js requestInstall({ param: "sdcard/weixin.apk", response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果(安装失败时会返回错误码 PackageManager):** ```bash {"code":0,"msg":"errorCode: -3","type":"install"} ``` --- #### 10. **静默卸载** 此接口实现应用的静默卸载。 ```js requestUninstall({ param: "com.tencent.mm", response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"uninstall"} ``` --- #### 11. **设备别名** 此接口实现给设备设置别名,别名会在网飞管理平台显示。 > **注意:此接口调用存在网络请求。** ```js requestDeviceAlias({ param: "万达广场", response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"alias"} ``` --- #### 12. **返回桌面** 此接口实现网飞管理平台配置的默认应用返回桌面,持续 5 分钟。 ```js requestBackToHome({ response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"start_home"} ``` --- #### 13. **WIFI 设置** 此接口实现 WIFI 连接和静态 IP 配置。 ```js requestWifiConfig({ arg1: this.wifi_ssid, arg2: this.wifi_pwd, arg3: this.wifi_ip, arg4: this.wifi_dns1, arg5: this.wifi_dns2, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":0,"msg":"Wifi connect fail: WWW","type":"wifi_config"} ``` --- #### 14. **以太网设置** 此接口实现以太网静态 IP 配置。 ```js requestEthernetConfig({ arg1: this.ethernet_ip, arg2: this.ethernet_netmask, arg3: this.ethernet_gateway, arg4: this.ethernet_dns1, arg5: this.ethernet_dns2, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"ethernet_config"} ``` --- #### 15. **获取位置信息** 此接口实现获取设备位置信息。位置信息数据源为百度位置接口,位置信息每次开机或断网重连时会从百度更新。 ```js requestGetLocation({ response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"data":{"address":"中国河南省郑州市中原区石佛镇王屋路","latitude":34.801424,"longitude":113.608487,"poi":"河南省大学科技园","time":"2021-12-15 15:21:00"},"msg":"","type":"location"} ``` --- #### 16. **设置系统时间** 此接口实现设置新的系统时间(时间不低于 2022-01-01)。 ```js requestSysTime({ param: this.sys_time, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"set_time"} ``` --- #### 17. **自动获取时间** 此接口实现控制自动获取时间开关。 `isChecked 为 true 或 false` ```js requestAutoTime({ param: isChecked, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"auto_time"} ``` --- #### 18. **风扇控制** 此接口实现 R02 和 R10 主板的风扇打开和关闭控制。 `isChecked 为 true 或 false` ```js requestFan({ param: isChecked, response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"fan_control"} ``` --- #### 19. **重启 4G 模块** 此接口实现 B 系列和 K 系列主板的 4G 模块重启功能。 > **注意:建议每天重启次数不超过 20 次,否则可能会影响 4G 模组的寿命。** ```js requestReset4G({ response: (json) => { //由于返回的json为json字符串 这里要使用 JSON.parse 转为JSON对象 this.handleResponse(JSON.parse(json)) } }) ``` **返回结果:** ```bash {"code":1,"msg":"","type":"reboot_modem"} ```