1.3.7 • Published 2 years ago

yiyun-app-sdk v1.3.7

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

子应用API 介绍

通过script方式引入

文件地址:http://dl-mobileres.effio.cn/yiyun.min.js

<script src="./yiyun.min.js"></script>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="./yiyun.min.js"></script>
</head>
<body>
 ...
<script>
        YiYun.onLoad(() => {
            config = YiYun.getConfig();
            result.textContent = `config: ${JSON.stringify(config)}`;
        });
    YiYun.onBack(() => {
        result.textContent = `回退按钮已触发 ${new Date()}`
    });

    document.getElementById('openUrl').onclick = async function openUrl() {
        YiYun.openUrl('https://www.douban.com');
    };

    document.getElementById('closeApp').onclick = function closeApp() {
        YiYun.closeApp();
    };
    ...
</script>
## 通过npm安装

npm install yiyun-app-sdk

## 获取登陆 Authorization 等参数

import {onLoad, getConfig} from 'yiyun-app-sdk'

onLoad(() => { let config = getConfig(); })

只有在onLoad的回调被调用之后,getConfig()才会返回值。

config 为以下格式

{ authToken, // 字符串,登陆 Authorization 值 userTypes, // 字符串数组,原来的jurisdictions值按逗号分割 route, // 页面所需要处理的路由 memberId, // 字符串,用户在当前企业下的成员id organizationId, // 字符串,当前企业的id, memberToken, // 字符串,成员的token qrCodeParams, // 字符串对象,相关二维码事件跳转进来带的参数, priceLevel, // 应用的版本 }

## 获取用户信息

import {getUserInfo} from 'yiyun-app-sdk'

let userInfo = await getUserInfo();

userInfo: { id: '', // userId name: '', // 昵称 profilePicture: '', // 头像 phone: '' //手机号 }

## 扫描二维码

import {scanBarcode} from 'yiyun-app-sdk'

try { let barcode = await scanBarcode(); } catch (err) { if (err.name === 'AbortError') { // 用户点了取消按钮 } // 其他异常 }

## 识别平台二维码
#### 调用

import {scanPlatformBarcode} from 'yiyun-app-sdk'

try { let res = await scanPlatformBarcode(); } catch (err) { if (err.name === 'AbortError') { // 用户点了取消按钮 } // 其他异常: { errCode: 1004, message: '', qrCode: '' } }

#### 返回结果

旧版: { name: '', key1(事件自定义参数名): value1, key2(事件自定义参数名): value2, ... }

新版: { args: { key1: value, key2: value }, version: '2.17.0' } key格式: {appId}.{category}.{key} appId在开放平台应用列表查看,category和key由APP定义

#### 通用异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   name| String |AbortError: 用户取消了操作  |

#### 业务异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002、1003、1004、 1005、1006、1007、1008、1009、1010、1011   |
|   message| string    |错误说明。1001:该二维码未绑定相关事件 1002:该二维码暂无当前应用的相关事件 1003: 二维码已作废 1004: 二维码已过期 1005: 二维码不存在 1006:网络错误 1007:获取平台二维码失败 1008:未开启照相机权限 1009:非当前企业的二维码 1010: 该二维码已被禁用,无法解析 1011: 你暂无权限查看该码  |
|   qrCode| string    |二维码内容   |

## 监听安卓返回按钮触发

import {onBack} from 'yiyun-app-sdk'

onBack(() => { // 安卓按钮已经点击 })

## GPS 定位

import {getCurrentPosition} from 'yiyun-app-sdk'

try { let pos = await getCurrentPosition(); // pos 的结构为 {latitude, longitude} } catch (err) { // 获取定位失败 }

## 录音

import {startRecordAudio, stopRecordAudio} from 'yiyun-app-sdk'

try { await startRecordAudio(); // 开始录音 } catch (err) { // 录音失败 }

try { let data = await stopRecordAudio(); // 结束录音 // data 为录音的data url } catch (err) { // 结束录音失败 }

注意:开始录音后再开始录音,或者结束录音后再结束录音,都会抛异常。

## 在原生浏览器打开 URL

import {openUrl} from 'yiyun-app-sdk'

openUrl('https://www.douban.com')

## 图片预览

import {previewImage} from 'yiyun-app-sdk'

previewImage({ initialIndex: 0, imageList: 'https://dl-todo.tsescloud.com/753700ec-b3c8-4b70-a238-fa0f920ab8e4/3sdR44345FD.jpg', 'https://dl-todo.tsescloud.com/753700ec-b3c8-4b70-a238-fa0f920ab8e4/3sdR4tR98tP.jpg', })

## 关闭应用

import {closeApp} from 'yiyun-app-sdk'

closeApp()

## 文件预览

import {previewFile} from 'yiyun-app-sdk'

previewFile(url)

注意:暂只支持pdf,txt,doc,docx,xls,xlsx,ppt,pptx. 安卓在第一次打开文件时,可能需要较长时间
## 用例

具体用法见exampleFor…….html

## 远程 debug

打开子应用后

安卓可以在 chrome 中打开 chrome://inspect/ 打开对应页面的调试工具
iOS 可以直接在 safari 的开发菜单打开页面对应的调试工具

## 区域选择器
### 引入

import {openAreaSelector} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool |true表示单选,false表示多选(必传)     |    |
|   disable| array    |禁用区域的id列表(可选)     |    |
|   selected| array    |已选区域的id列表(可选)     |    |

#### 例

let result = await openAreaSelector({isOnly: false, selected: 'id', disable: 'id'});

## 设备选择器
### 引入

import {openDeviceSelector} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool |true表示单选,false表示多选(必传)     |    |
|   disable| array    |禁用区域的id列表(可选)     |    |
|   selected| array    |已选区域的id列表(可选)     |    |

#### 例

let result = await openDeviceSelector({isOnly: false, selected: 'id', disable: 'id'});

## 选择部门和成员 *selectDeptAndMember*
### 引入

import {selectDeptAndMember} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   disable| object |||
|   selected| object |||

disable内容说明:

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   members| Array |禁用的成员id列表||
|   depts| Array |禁用的部门id列表||

selected 内容同disable:

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   members| Array |已选的成员id列表||
|   depts| Array |已选的部门id列表||

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   members| Array |member对象的列表||
|   depts| Array |dept对象的列表||
 member对象:

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |成员的用户Id||
|   name| string |成员的姓名||
|   memberId| string |成员的id||

 dept对象:

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| string |部门的id||
|   name| string |部门名||
#### 例

let result = await selectDeptAndMember({ disable: { members: '...','...',..., depts: '...','...',... }, selected: { members: '...','...',..., depts: '...','...',... } }); console(result) //输出结果为 { members: { userId: '', name: '', memberId: '' },{ userId: '', name: '', memberId: '' },... , depts: { id: '', name: '' }, { id: '', name: '' },... }

## 选择成员 *selectMember*
### 引入

import {selectMember} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool |是否单选||
|   disable| array |禁用的成员id列表||
|   selected| array |已选的成员id列表||

#### 返回值为member组数,member对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |成员的用户Id||
|   name| string |成员的姓名||
|   memberId| string |成员的id||

#### 例

let result = await selectMember({ isOnly: false, disable: '...','...',..., selected: '...','...',... }); console(result) //输出结果为 { userId: '', name: '', memberId: '' },{ userId: '', name: '', memberId: '' },...

## 选择部门 *selectDept*
### 引入

import {selectDept} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool |是否单选||
|   disable| array |禁用的部门id列表||
|   selected| array |已选的部门id列表||

#### 返回值为dept组数,dept对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| string |部门的id||
|   name| string |部门名||

#### 例

let result = await selectDept({ isOnly: false, disable: '...','...',..., selected: '...','...',... }); console(result) //输出结果为 { id: '', name: '' },{ id: '', name: '' },...

## 选择某部门下的成员 *selectMemberOfDept*
### 引入

import {selectMemberOfDept} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   deptId| string |部门Id(必填)||
|   isOnly| bool |是否单选||
|   disable| array |禁用的成员id列表||
|   selected| array |已选择的成员id列表||

#### 返回值为member组数,member对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |成员的用户Id||
|   name| string |成员的姓名||
|   memberId| string |成员的id||

#### 例

let result = await selectMemberOfDept({ deptId: '...', isOnly: false, disable: '...','...',..., selected: '...','...',... }); console(result) //输出结果为 { userId: '', name: '', memberId: '' },{ userId: '', name: '', memberId: '' },...

## 选择岗位 *selectPost*
### 引入

import {selectPost} from 'yiyun-app-sdk'

#### 接口参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool |是否单选||
|   disable| array |禁用的岗位id列表||
|   selected| array |已选的岗位id列表||

#### 返回值为post组数,post对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| string |岗位的id||
|   name| string |岗位名||
|   level| string |岗位等级||

#### 例

let result = await selectPost({ isOnly: false, disable: '...','...',..., seletced: '...','...',... }); console(result) //输出结果为 { id: '', name: '', level: '', },{ id: '', name: '', level: '' },...

## 选择联系人 *selectContact*

import {selectContact} from 'yiyun-app-sdk'

selectContact(true) // 接受bool,是否单选

#### 返回值为user数组,user对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| string |用户id||
|   name| string |用名名称||
|   profilePicture| string |用户头像url||

#### 例

let result = await selectContact(false); console(result) //输出结果为 { id: '', name: '', profilePicture: '' },{ id: '', name: '', profilePicture: '' },...

## 选择设备实例(树) *selectModalTree*

import {selectModalTree} from 'yiyun-app-sdk'

#### 返回值为user数组,user对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool|是否单选||
|   selected| array(String) |已选列表,单选时不生效||
|   disable| array(String) |禁用列表,单选时不生效||
|   level| int |可供选择的层级,2.厂区,3.区域,4.生产线,5.工位,默认为5||

#### 例

let result = await selectModalTree({isOnly: false,selected: [],disable: [],level: 3}); //输出结果为 { id: '', isError: '', level: '', name: '', pid: '', }

## 选择设备实例(单层) *selectModal*

import {selectModal} from 'yiyun-app-sdk'

#### 返回值为user数组,user对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool|是否单选||
|   id| String|模型id,用于限定模型的选择范围,不填默认为整个企业||
|   selected| array(String) |已选列表||
|   disable| array(String) |禁用列表||
|   level| int |可供选择的层级,2.厂区,3.区域,4.生产线,5.工位,默认为5||

#### 例

let result = await selectModal({isOnly: false,selected: [],disable: [],level: 3, id: ''}); //输出结果为 { id: '', isError: '', level: '', name: '', pid: '', }

## 选择地图 *selectMap*

import {selectMap} from 'yiyun-app-sdk'

#### 返回值为user数组,user对象如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   isOnly| bool|是否单选||
|   id| String|模型id||
|   selected| array(String) |已选列表||
|   disable| array(String) |禁用列表||

#### 例

let result = await selectMap({isOnly: false,selected: [],disable: [], id: ''}); //输出结果为 { boundary: '', caseId: '', caseName: '', createTime: '', iconId: '', id: '', location: '', mapName: '', mapType: '', modalType: '', }

## 内嵌地图的初始化,改变地图,改变block颜色 *yiyunMap*

import {yiyunMap} from 'yiyun-app-sdk'

#### 例

yiyunMap.init('#map') // dom的id yiyunMap.initGaodeKey('高德key'); yiyunMap.initialMap('地图id', '所属工厂模型实例Id', '块id'); // 第二,第三个参数用于设置中心点 // 如果有区块关联了传入的实例,那么会根据传入的参数改变区块的颜色和透明度 yiyunMap.setBlinkBlockByCase( {id: '3p7ax4iGS31', fillColor: '#666666', fillOpacity: 0.9 }); // 直接改变区块的颜色为指定颜色和透明度 yiyunMap.setBlinkBlockByBlock( {id: '3pTiETyBXpK', fillColor: '#666666', fillOpacity: 0.9 });

## 获取成员实例 *getMembersFromOrganization*

import {getMembersFromOrganization} from 'yiyun-app-sdk'

#### 例

let res = await getMembersFromOrganization( orgId, // 需要查询的组织Id,空表示查询当前用户的企业 isActiveMember // 是否只显示已经激活的成员,true表示只显示已激活(已绑定),false表示显示全部 ) res = [ { id: '部门id', parentId: '父部门Id', code: '部门码', name: '部门名称', createTime: '创建时间戳', memberCount: '当前部门下的成员数量(包括下下级)', type: '类型:member表示人,dept表示部门', children: ... // 包含子部门和部门下的人,以此类推 }, ... , { id: '成员Id', name: '成员名称', headPortrait: '头像', userId: '用户Id', type: '类型:member表示人,dept表示部门', } ]

## 获取岗位实例 *getPostsFromOrganization*

import {getPostsFromOrganization} from 'yiyun-app-sdk'

#### 例

let res = await getPostsFromOrganization( orgId // 需要查询的组织Id,空表示查询当前用户的企业 ) res = [ { id: '岗位Id', name: '岗位名称', level: '岗位层级', createTime: '创建时间戳', memberCount: '岗位上的人数', depts: // 相关的岗位(根据成员的部门-岗位得到的) { id: '岗位Id', name: '岗位名称' }, ... }, ... ]

## 获取部门实例 *getDeptFromOrganization*

import {getDeptFromOrganization} from 'yiyun-app-sdk'

#### 例

let res = await getDeptFromOrganization( orgId // 需要查询的组织Id,空表示查询当前用户的企业 ) res = [ { id: '部门id', parentId: '父部门Id', code: '部门码', name: '部门名称', createTime: '创建时间戳', memberCount: '当前部门下的成员数量(包括下下级)', children: ... // 包含子部门列表,子部门可能存在子部门,以此类推 }, ... ]

## 获取成员岗位实例 *getMemberAndPostFromOrganization*

import {getMemberAndPostFromOrganization} from 'yiyun-app-sdk'

#### 例

let res = await getMemberAndPostFromOrganization( orgId, // 需要查询的组织Id,空表示查询当前用户的企业 isActiveMember // 是否只显示已经激活的成员,true表示只显示已激活(已绑定),false表示显示全部 )

res = [ { id: '部门id', parentId: '父部门Id', code: '部门码', name: '部门名称', createTime: '创建时间戳', memberCount: '当前部门下的成员数量(包括下下级)', type: 'dept', children: ..., { id: '岗位Id', name: '岗位名称', level: '岗位层级', type: 'position' } ..., // 包含子部门、部门下的人及部门下的岗位,以此类推 }, ... , { id: '成员Id', name: '成员名称', headPortrait: '头像', userId: '用户Id', type: 'member', } ]

## 获取部门下的成员实例 *getMemberByDeptFromOrganization*

import {getMemberByDeptFromOrganization} from 'yiyun-app-sdk'

#### 例

let res = await getMemberByDeptFromOrganization( orgId, // 需要查询的组织Id,空表示查询当前用户的企业 deptId // 部门Id(必填) ) res = { id: '成员Id', name: '成员名称', headPortrait: '头像', userId: '用户Id' }, ...

## 分享文件到微信 *shareFileToWechat*

import {shareFileToWechat} from 'yiyun-app-sdk'

#### 例

let res = await shareFileToWechat({ url: 必填,文件的url, name: 必填,文件名称,不能超过50个字符, extension: 必填,文件后缀名,不能超过10个字符

})

## 分享网页到微信 *shareWebPageToWechat*

import {shareWebPageToWechat} from 'yiyun-app-sdk'

#### 例

let res = await shareWebPageToWechat({ url: 必填,网页的url, title: 必填,分享内容的标题, subTitle:必填,分享内容的描述, thumbnail: 必填,缩略图网址, })

## 分享网页到微信(可以调回亦云) *shareWebPageToWechatLoop*
### 注意,如果点击的用户没有购买过应用,会出现'找不到对应的应用'的提示
### 注意,url不能直接如果带参数的话,参数不能是中文

import {shareWebPageToWechatLoop} from 'yiyun-app-sdk'

#### 例

let res = await shareWebPageToWechatLoop({ url: 必填,网页的url, title: 必填,分享内容的标题, subTitle:必填,分享内容的描述, thumbnail: 必填,缩略图网址, })

## 选择E盘本地文件 *selectLocalFile*
### 从亦云本地文件夹中选择文件
### 返回值为文件的本地路径

import {selectLocalFile} from 'yiyun-app-sdk'

#### 例

let res = await selectLocalFile()

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   url| String |本地文件路径||
|   code| int |错误码(未定)||

## 从E盘选择文件 *selectFileFromEDisk*
### 返回值为E盘文件的属性值

import {selectFileFromEDisk} from 'yiyun-app-sdk'

#### 例

let res = await selectFileFromEDisk({ isPersonalDisk: 选填,默认false,true是从个人盘中取文件, false是从当前企业盘中取文件 support: string,例: '1,2', 0.pdf 1.txt 2.doc、docx 3.xls、xlsx 4.ppt、pptx 5.csv 6.jpeg、jpg 7.png 8.gif 9.bmp 10.zip 11.rar 12.7z 13.mp3 14.mov 15.mp4 16.ogg 17.mpv 18.wmv 19.fmp4 20.wav 21.arm 22.flv 23.其他 })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   diskId| String |盘的ID||
|   fileId| String |文件ID||
|   parentId| String |父ID||
|   name| String |文件的显示名称||
|   fullPath| String |E盘文件路径||
|   size| int |文件大小||
|   uploaderName| String |上传人||
|   url| String |文件的url,有效期7天||
|   thumbnail| String |缩略图(仅在是图片时有效)||

## 从E盘选择文件 *selectFoldFromEDisk*
### 返回值为E盘文件夹的属性值

import {selectFoldFromEDisk} from 'yiyun-app-sdk'

#### 例

let res = await selectFoldFromEDisk({ isPersonalDisk: 选填,默认false,true是从个人盘中取文件, false是从当前企业文件夹中取文件 })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   diskId| String |盘的ID||
|   foldId| String |文件ID, 可空||

## 预览E盘文件 *eDiskFilePreview*

import {eDiskFilePreview} from 'yiyun-app-sdk'

#### 例

let res = await eDiskFilePreview({ diskId: 必填,盘ID, fileId: 必填, 文件ID })

## 根据盘id和文件id获取文件的url *getEDiskFileLink*

import {getEDiskFileLink} from 'yiyun-app-sdk'

#### 例

let res = await getEDiskFileLink({ diskId: 必填,盘ID, fileId: 必填, 文件ID })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   url| String |文件的url||
|   expireTime| int |链接的过期时间||

## 上传文件到亦盘 *uploadBase64*

import {uploadBase64} from 'yiyun-app-sdk'

#### 例

let res = await uploadBase64({ isPersonalDisk: bool 默认false 是否上传到个人盘, targetFoldId: String 必填 文件夹id, file:String 必填 文件内容 示例:iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAA3ElEQVQ4je3UMUoDQRSH8QmEEAsJG1BS5QLBc4insPMQEQI2pnELEctszmORJpA2hSi6nZ2, fileName: String 文件名称 必填, extension: String 必填 文件后缀名 })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| String |文件的id,可以用来移除任务和获取上传的结果||
|   filename| String |文件的名称||
|   targetId| String |目标文件夹id||
|   diskId| String |盘ID||
|   size| int |文件大小||

## 上传文件到亦盘 *uploadFile*

import {uploadFile} from 'yiyun-app-sdk'

#### 例

let res = await uploadFile({ isPersonalDisk: bool 默认false 是否上传到个人盘, targetFoldId: String 必填 文件夹id, file:String 必填 文件路径,当前只能通过selectLocalFile方法获取 })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   id| String |文件的id,可以用来移除任务和获取上传的结果||
|   filename| String |文件的名称||
|   targetId| String |目标文件夹id||
|   diskId| String |盘ID||
|   size| int |文件大小||

## 获取文件的上传状态 *getUploadStatus*
#### 上传失败会报错

import {getUploadStatus} from 'yiyun-app-sdk'

#### 例

let res = await getUploadStatus({ id: String 必填 文件id, })

## 取消上传任务 *removeTask*

import {getUploadStatus} from 'yiyun-app-sdk'

#### 例

let res = await removeTask({ id: String 必填 文件id, })

## 监听扫描蓝牙设备 *onScan*
#### 例

onScan((res)=>{ //每次新扫描到设备都会进入这里执行操作 }); res = { id: '设备的uuid', name: '设备名称', }, ...

## 连接设备 *connect*
#### 例

let res = await connect({ uuid: 必填,设备的uuid, })

**返回**

- 0 连接成功
- -1  连接超时
- -2  蓝牙地址格式错误
- -3  打印机与SDK不匹配(握手不通过)

## 获取打印机状态 *currentConnectedDevice*

#### 例

let res = await currentConnectedDevice()

**返回**

- 0 打印机正常连接 
- 1 未连接
- -1 发送失败
-  2 缺纸
-  6 开盖

## 断开当前连接设备 *disconnect*

import {disconnect} from 'yiyun-app-sdk'

#### 例

let res = await disconnect()

## 设置标签高度 *printAreaSize*

import {printAreaSize} from 'yiyun-app-sdk'

#### 例

let res = await YiYun.printAreaSize({参数都是必填 offset:'0', 上下文对象 horizontal:'200',打印机水平方向dpi(根据实际打印机dpi设置) vertical:'200',打印机垂直方向dpi(根据实际打印机dpi设置) height:'1400',标签高度 (单位:dot)200dpi 8 dot = 1mm,300dpi 12 dot = 1mm qty:'1'打印次数 });

## 设置对齐方式 *align*

import {align} from 'yiyun-app-sdk'

#### 例

let res = await align({ align: 'CENTER' 必填,对齐方式,String格式 })

| 参数  | 描述                                                         |
| ----- | ------------------------------------------------------------ |
| align | 'CENTER':居中。<br /> 'LEFT':左对⻬。 <br />'RIGHT':右对⻬。 |

## 文本打印 *printText*
#### 例

let res = await printText({都必填 command:'T', font:'8', x:'50', y:'5', data:'SELF_TEST' })

| 参数    | 描述                                                         |
| ------- | ------------------------------------------------------------ |
| command | 文字的方向<br />'T'':水平。<br />'T90':逆时针旋转90度。 <br />'T180':逆时针旋转180度。<br />'T270':逆时针旋转270度。 |
| font    | 字体点阵大小:(单位:dot)<br />注意:英文固件只支持(0和1)。<br />0:12x24。 <br />1:12x24(中文模式下打印繁体),英文模式下字体变成(9x17)大小 <br />2:8x16。<br />3:20x20。 <br />4:32x32或者16x32,由ID3字体宽高各放大两倍。 <br />7:24x24或者12x24,视中英文而定。 <br />8:24x24或者12x24,视中英文而定。<br />20:16x16或者8x16,视中英文而定。 <br />24:24x24或者12x24,视中英文而定。 <br />55:16x16或者8x16,视中英文而定。 <br />其它默认24x24或者12x24,视中英文而定。 |
| x       | 横坐标(单位 dot)                                             |
| y       | 纵坐标(单位 dot                                              |
| Data    | 文本数据                                                     |                                                             |

## 打印条码 *printCode*

#### 例

let res = await printCode({都必填 command:'BARCODE', codeType:'128', width:'2', ratio:'1', height:'50', x:'0', y:'100', underText:true, number:'7', size:'0', offset:'5', data:'123456789' })

| 参数      | 描述                                                         |
| --------- | ------------------------------------------------------------ |
| command   | 'BARCODE':水平方向<br />'VBARCODE':垂直方向                  |
| codeType  | 条码类型:<br/>UPCA = "UPCA"; UPCA2 = "UPCA2"; UPCA5 = "UPCA5"; UPCE = "UPCE"; UPCE2 = "UPCE2"; UPCE5 = "UPCE5"; EAN13 = "EAN13"; EAN132 = "EAN132"; EAN135 = "EAN135"; EAN8 = "EAN8"; EAN82 = "EAN82"; EAN85 = "EAN85"; code39 = "39"; code39C = "39C"; F39 = "F39"; F39C = "F39C"; code93 = "93"; I2OF5 = "I2OF5"; I2OF5C = "I2OF5C"; I2OF5G = "I2OF5G"; code128 = "128"; UCCEAN128 = "UCCEAN128"; CODABAR = "CODABAR"; CODABAR16 = "CODABAR16"; MSI = "MSI"; MSI10 = "MSI10"; MSI1010 = "MSI1010"; MSI1110 = "MSI1110"; POSTNET = "POSTNET"; FIM = "FIM"; |
| Width     | 窄条的单位宽度                                               |
| ratio     | 宽条窄条的比例<br />0=1.5:1 , 1=2.0:1 , 2=2.5:1 , 3=3.0:1 , 4=3.5:1 ,  20=2.0:1 , 21=2.1:1 , 22=2.2:1 , 23=2.3:1 , 24=2.4:1 , 25=2.5:1 26=2.6:1 , 27=2.7:1 , 28=2.8:1 , 29=2.9:1 , 30=3.0:1 , |
| Height    | 条码高度                                                     |
| x         | 条码的起始横坐标。(单位:dot)                                 |
| y         | 条码的起始纵坐标。(单位:dot)                                 |
| undertext | 条码下方的数据是否可⻅。 ture:可⻅,false:不可⻅。           |
| number    | 字体的类型 (undertext=true才生效) undertext=false也要传,随便填 |
| size      | 字体的大小(undertext=true才生效)undertext=false也要传,随便填 |
| offset    | 条码与文字间的距离(undertext=true才生效)undertext=false也要传,随便填 |
| data      | 条码数据                                                     |

## 打印二维码 *printQR*

#### 例

let res = await printQR({ command:'BARCODE', x:'0', y:'870', m:'4', u:'6', data:'ABC123' })

| 参数    | 描述                                                         |
| ------- | ------------------------------------------------------------ |
| command | 'BARCODE':水平方向<br />'VBARCODE':垂直方向                  |
| x       | 二维码的起始横坐标。(单位:dot)                               |
| y       | 二维码的起始纵坐标。(单位:dot)                               |
| m       | QR的类型:<br/> 1:普通类型 <br />2:在类型1的基础上增加了个别的符号 <br />传'4'即可 |
| u       | 单位宽度/模块的单元高度,范围是1到32默认为6                   |
| data    | 二维码的数据                                                 |



## 打印直线 *printLine*

#### 例

let res = await printLine({ x0:'0', y0:'1030', x1:'400', y1:'1030', width:'1' })

| 参数  | 描述                      |
| ----- | ------------------------- |
| X0    | 起始的X坐标。(单位:dot)   |
| Y0    | 起始的Y坐标。(单位:dot)   |
| X1    | 结尾的X坐标。(单位:dot)   |
| Y1    | 结尾的Y坐标。(单位:dot)   |
| width | 线条的单位宽度。 (默认:1) |

## 打印矩形框 *printBox*

#### 例

let res = await printBox({ x0:'0', y0:'1030', x1:'400', y1:'1030', width:'1' })

| 参数  | 描述                      |
| ----- | ------------------------- |
| X0    | 左上⻆的X坐标。(单位:dot) |
| Y0    | 左上⻆的Y坐标。(单位:dot) |
| X1    | 右下⻆的X坐标。(单位:dot) |
| Y1    | 右下⻆的Y坐标。(单位:dot) |
| width | 线条的单位宽度。 (默认:1) |

## 打印内容 *print*

先设置打印高度,然后调用打印文字或者二维码的函数,最后调用print()就可以打印了

import {print} from 'yiyun-app-sdk'

#### 例

await printAreaSize({offset:'0', horizontal:'200', vertical:'200', height:'1400', qty:'1'}); await align({align:'CENTER'}); await printText({command:'T', font:'8', x:'50', y:'5', data:'SELF_TEST'}); await align({align:'LEFT'}); await printCode({command:'BARCODE', codeType:'128', width:'2', ratio:'1', height:'50', x:'0', y:'100', underText:true, number:'7', size:'0', offset:'5', data:'123456789'}); await printQR({command:'BARCODE', x:'0', y:'870', m:'4', u:'6', data:'ABC123'}); await printLine({x0:'0', y0:'1030',x1:'400',y1:'1030',width:'1'}); await printBox({x0:'0', y0:'1080',x1:'400',y1:'1300',width:'1'}); await print();

**返回**

- 大于0 打印成功
- -1 打印失败

## 打印图片 *printImage*

直接调用该函数打印即可,不用设置高度,也不用调用print()函数

#### 例

let res = await printImage({ imagePath: 必填,图片路径, count: 必填,打印数量 })

**返回**

- 大于0 打印成功
- -1  打印失败
- -2  bitmap为空
- -3  图片数据超过打印机缓冲区

## 设置页面宽度 *pageWidth*
在printAreaSize之后调用

指定⻚面宽度。(单位:dot)
200dpi 8 dot = 1mm
70mm的宽度设置560

#### 例

let res = await pageWidth({width:'560'})

**返回**

- 大于0 发送成功
- -1 发送失败

## 标签定位 *form*
在Print()之前调用,只在标签模式下起作用


#### 例

let res = await form()

**返回**

- 大于0 发送成功
- -1 发送失败

## 文件下载 *downloadFile*

import {downloadFile} from 'yiyun-app-sdk'

#### 例

let res = await downloadFile({ url: '文件地址', onStart: () => { // 开始下载的回调 }, onReceiveProgress: (data) => { // 下载过程中的调用 data为 {receive:10000,total:20000} }, onError: (err) => { // 错误的回调 }, onComplete: () => { // 下载完成的回调 } })

#### 返回值为Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   url| String |文件地址||
|   onStart| Function |下载开始的处理||
|   onReceiveProgress| Function |下载进度的处理||
|   onError| Function |下载错误的处理||
|   onComplete| Function |下载完成的处理||

#### `onReceiveProgress`返回一个Object,内容如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   receive| number |已下载的大小||
|   total| number |总大小||


## 获取设备标识 *getDeviceIdentity*

import {getDeviceIdentity} from 'yiyun-app-sdk'

#### 例

let res = await getDeviceIdentity()

## 发起审批 *toApplyApprove*

import {toApplyApprove} from 'yiyun-app-sdk'

#### 例

await toApplyApprove()

## 打开与某用户的私聊 *openConversation*

import {openConversation} from 'yiyun-app-sdk'

await openConversation(userId)

#### 请求参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |对象的用户id||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001|
|   message| string    |错误说明。1001:用户不存在  |


## 打开与某用户的信息页面 *openUserInfo*

import {openUserInfo} from 'yiyun-app-sdk'

await openUserInfo(userId)

#### 请求参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |对象的用户id||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001|
|   message| string    |错误说明。1001:用户不存在  |


## 获取可以打开的外部导航应用 *getEnableMap*

import {getEnableMap} from 'yiyun-app-sdk'

let res = await getEnableMap({ latitude: , longitude: , })

console.log(res) // 0,1,2

#### 请求参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   latitude| double |目标位置的纬度||
|   longitude| double |目标位置的经度||

#### 返回值为地图枚举的Array
> 其中 0: 高德地图 1:腾讯地图 2:百度地图 3:苹果地图(安卓不会返回该类型)

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001|
|   message| string    |错误说明。1001:经纬度数据有误  |

## 打开外部导航 *openMap*

import {openMap} from 'yiyun-app-sdk'

let res = await openMap({ mapType: 0, latitude: , longitude: , })

#### 请求参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   mapType| num |地图类型的枚举 0: 高德地图 1:腾讯地图 2:百度地图 3:苹果地图(安卓不会返回该类型)||
|   latitude| double |目标位置的纬度||
|   longitude| double |目标位置的经度||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002、1003|
|   message| string    |错误说明。1001:经纬度数据有误 1002: 无法识别的地图类型 1003: 无法打开该地图 |

## 获取wifi信息 *getWifiInfo*

import {getWifiInfo} from 'yiyun-app-sdk'

let res = await getWifiInfo()

#### 返回值为Object 结构如下
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   name| string |Wi-Fi名称||
|   bssid| string |Wi-Fi的bssid||
|   ip| string |Wi-Fi的ip地址||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002|
|   message| string    |错误说明。1001:未连接wifi 1002: 未开启定位权限,无法获取准确的Wi-Fi信息 |

## 发送消息 *sendMessage*

import {sendMessage} from 'yiyun-app-sdk'

let res = await sendMessage({ userId: '', message: { type: 0, data: { text: '123' } } })

#### 请求参数
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   userId| string |消息发送的对象 ||
|   message| object |消息体||

#### message对象说明
| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   type| num |地图类型的枚举 0: 文本消息 4:卡片消息 5:位置消息 ||
|   data| object |对应消息类型的数据对象||

#### data对象说明
当type = 0时

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   text| string |文本内容 ||

当type = 4时

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   title| string |卡片标题 ||
|   content| string |卡片内容 ||

当type = 5时

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   latitude| double |纬度||
|   longitude| double |经度||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002、1003、1004、1005、1006|
|   message| string    |错误说明。1001:用户不存在 1002: 消息体结构有误 1003: 无法识别的消息类型 1004: 文本消息的text不能为空 1005: 卡片消息的title和content不能同时为空 1006: 经纬度数据有误|


## 跳转其他app *navigatorToApp*

import {navigatorToApp} from 'yiyun-app-sdk'

let res = await navigatorToApp({ appId: '', path: '', fregment: '' })

// path 和 fregment 同开放平台处配置看板跳转填写的内容 // 如: app 地址为 "https://aaa.bbb.ccc/index.html", path为 "setting.html", fregment 为 "/route?a=1&b=2" // 则跳转的页面为 "https://aaa.bbb.ccc/setting.html#/route?a=1&b=2"

| 参数名  | 参数类型 | 说明 | 其他|
| -------- | -------- | -------- | -------- |
|   appId| string |目标appId||
|   path| string |目标app项目目录下的页面路径||
|   fregment| string |额外的路由以及参数||

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:2001、2002、2003|
|   message| string    |错误说明。2001: 获取app失败 2002: 应用未购买 2003: 应用未授权|

## 向管理员发送应用权限申请 *applyAppPermissions*

import {applyAppPermissions} from 'yiyun-app-sdk' try { let res = await applyAppPermissions() } catch (e) {

}

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002|
|   message| string    |错误说明。1001:app无需授权 1002: 发送失败|



## 跳转应用权限授权页面 *toSetAppPermissions*

import {toSetAppPermissions} from 'yiyun-app-sdk' try { let res = await toSetAppPermissions() } catch (e) {

}

## 检查NFC权限 *checkNFCPermission*

import {checkNFCPermission} from 'yiyun-app-sdk' try { let res = await checkNFCPermission() // res: true 可用 false 不可用 } catch (e) {

}

## 读取NCF标签 *readNFC*

import {readNFC} from 'yiyun-app-sdk' try { let res = await readNFC() } catch (e) {

}

#### 返回结果
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   id| string |NFC的id|
|   type| string    |NFC的类型|
|   records| List<Object>    |NFC标签的内容|

#### record内容如下

| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   id| string |record的id|
|   data| string    |record的内容|
|   type| string    |内容的类型|
|   tnf| string    |NFCTypeNameFormat, 具体有well_known,mime_media,absolute_uri,external_type,unchanged,unknown,empty|
|   languageCode| string    |语言|

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002、1003、1004、1005、1006、1007、1100、1101|
|   message| string    |错误说明。1001:取消扫描 1002: 扫描超时 1003:系统不支持NDEF 1004: 意外终止 1005: NFC系统繁忙 1006: IO操作异常 1007: NDEF格式有误 1100: 读取失败 1101: NFC不可用|


## 写入NCF标签内容 *writeNFC*

import {writeNFC} from 'yiyun-app-sdk' try { let res = await writeNFC({ 'tnf': 0, 'data': 'iiiiiiiiiiiii' },{ 'tnf': 1, 'data': 'https://effio.cn' },{ 'tnf': 2, 'type': 'text/plain', 'data': '哈哈哈' },{ 'tnf': 2, 'type': 'application/json', 'data': '{"a": 123}' },{ 'tnf': 3, 'type': 'hhh', 'data': '4sXoi112F' }) } catch (e) {

}

#### 接收List<Record> record 内容如下
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   tnf| int    |0: 文本 1: url类型 2: mime_media 3: external_type|
|   type| string    |record的类型,当tnf为0或1时可不传 tnf = 0时,type 固定为"T"(文本类型);tnf = 1时,type 固定为"U"(uri类型)|
|   data| string   |record的内容|

#### 异常说明
| 参数名  | 参数类型 | 说明 |
| -------- | -------- | -------- |
|   errCode| int |错误码:1001、1002、1003、1004、1005、1006、1007、1100、1101|
|   message| string    |错误说明。1001:取消扫描 1002: 扫描超时 1003:系统不支持NDEF 1004: 意外终止 1005: NFC系统繁忙 1006: IO操作异常 1007: NDEF格式有误 1008: 打开了多个NFC识别器 1009: NFC tag不可用 1010: NFC tag不可写 1011: 写入内容超出该NFC tag的容量 1012: 更新失败 1100: 写入失败 1101: NFC不可用|
1.3.7

2 years ago

1.3.6

2 years ago

1.3.5

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.2.52

2 years ago

1.2.53

2 years ago

1.3.0

2 years ago

1.2.45

2 years ago

1.2.46

2 years ago

1.2.44

2 years ago

1.2.47

2 years ago

1.2.48

2 years ago

1.2.50

2 years ago

1.2.51

2 years ago

1.2.43

3 years ago

1.2.41

3 years ago

1.2.42

3 years ago

1.2.40

3 years ago

1.2.39

3 years ago

1.2.38

3 years ago

1.2.35

3 years ago

1.2.36

3 years ago

1.2.37

3 years ago

1.2.28

3 years ago

1.2.29

3 years ago

1.2.30

3 years ago

1.2.31

3 years ago

1.2.34

3 years ago

1.2.32

3 years ago

1.2.33

3 years ago

1.2.27

3 years ago

1.2.26

3 years ago

1.2.23

3 years ago

1.2.24

3 years ago

1.2.25

3 years ago

1.2.22

3 years ago

1.2.20

3 years ago

1.2.21

3 years ago

1.2.19

3 years ago

1.2.18

3 years ago

1.2.17

4 years ago

1.2.16

4 years ago

1.2.15

4 years ago

1.2.14

4 years ago

1.2.13

4 years ago

1.2.9

4 years ago

1.2.12

4 years ago

1.2.10

4 years ago

1.2.11

4 years ago

1.2.8

4 years ago

1.2.7

4 years ago

1.2.6

4 years ago

1.2.5

4 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago