同步操作将从 szp11/UniApp-Android-Plugins 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
项目说明
项目结构
uni-app_plug-in
├─uniplugin_Demo uniApp插件实例工程
│ └─nativeplugins 插件存放路径
│ ├─Huiy-Card 身份证插件
│ ├─Huiy-Office Office文件预览插件
│ ├─Huiy-Printer 打印机插件
│ ├─Huiy-Sale 售货机插件
│ ├─Huiy-Scanner 扫码枪插件
│ └─Huiy-Sensor 陀螺仪插件
│
├─UniPlugin-Android Android插件工程,插件源码
│ ├─app App程序,可运行
│ ├─huiy_card 身份证组件module
│ ├─huiy_office Office文件预览组件module
│ ├─huiy_printer 打印机组件module
│ ├─huiy_sale 售货机组件module
│ ├─huiy_scaner 扫码枪组件module
│ └─huiy_sensor 陀螺仪组件module
│
陀螺仪插件使用说明
var testModule = uni.requireNativePlugin("Huiy-SensorModule")
testModule.registerSensorAFunc(
(ret) => {
this.degree = ret.degree;
this.x = ret.x;
this.y = ret.y;
this.z = ret.z;
})
返回参数包括 degree,x,y,z
degree 当前方向角度,取值范围0~360, 0-北 90-东 180-南 270-西
x,y,z 陀螺仪传感器返回的 x,y,z三轴的原始数据,取值范围为 -PI~PI
var ret = testModule.unRegisterSensorFunc(); `
var ret = testModule.getSensorInfoFunc();`
var ret = testModule.toDegree180Func({
'value': -1
});
modal.toast({
message: "toDegree360:"+ret.degree,
duration: 1.5
});
var ret = testModule.toDegree360Func({
'value': -1
});
modal.toast({
message: "toDegree360:"+ret.degree,
duration: 1.5
});
扫码枪插件使用说明
var testModule = uni.requireNativePlugin("Huiy-ScannerModule")
var globalEvent = uni.requireNativePlugin('globalEvent');
globalEvent.addEventListener('scannerEvent', function(e) {
console.log("scannerEvent:" + that);
that.i = e.barcode;
modal.toast({
message: "globalEvent收到:" + e.scannerId + " " + e.type + " " + e.msg + " " + e.barcode + " " + e.barType,
duration: 1.5
});
});
其中 scannerId扫码枪id,type 消息类型,msg 消息内容,barcode 扫码内容,barType二维码类型
testModule.initScannerAFunc(
(ret) => {
modal.toast({
message: "init:" + JSON.stringify(ret),
duration: 1.5
});
});`
testModule.connectScannerAFunc(
(ret) => {
modal.toast({
message: "init:" + JSON.stringify(ret),
duration: 1.5
});
});`
此时使用扫码枪扫描二维码或条形码,扫描结果会通过上面注册的回调返回数据
testModule.disconnectScannerAFunc(
(ret) => {
modal.toast({
message: "init:" + JSON.stringify(ret),
duration: 1.5
});
});`
条码打印机插件使用说明
var testModule = uni.requireNativePlugin("Huiy-PrinterModule")
globalEvent.addEventListener('myEvent', function(e) {
console.log("globalEvent:" + that);
that.i = e.degree;
modal.toast({
message: "myEvent收到:" + e.type + " " + e.msg,
duration: 1.5
});
});
其中 type 消息类型,msg 消息内容
var ret = testModule.getUsbDevListFunc();
var ret = testModule.connectUsbDevFunc({
'name': this.conDev
});
var ret = testModule.printerLabel(json);
其中json为json报文,用于描述打印标签的内容,具体举例如下:
{
"direction": 0,
"gap": 20,
"height": 30,
"mirror": 0,
"width": 40,
"x": 0,
"y": 0,
"printInfoList": [{
"cellWidth": 5,
"font": "TSS24.BF2",
"height": 100,
"readable": 0,
"rotation": 0,
"scaleX": 2,
"scaleY": 2,
"text": "悠悠奶茶",
"type": 1,
"x": 60,
"y": 10
}, {
"cellWidth": 3,
"height": 100,
"level": "L",
"readable": 0,
"rotation": 0,
"scaleX": 0,
"scaleY": 0,
"text": "barcode1234567",
"type": 2,
"x": 200,
"y": 75
}, {
"barType": "128",
"cellWidth": 5,
"height": 50,
"readable": 1,
"rotation": 0,
"scaleX": 0,
"scaleY": 0,
"text": "7654321",
"type": 3,
"x": 30,
"y": 160
}]
}
最上方direction、gap、width、height、mirror、x、y 用于描述标签信息,具体参数说明如下:
public int width = 40; // 标签尺寸(宽)
public int height = 30; // 标签尺寸(高)
public int gap = 20; // 标签之间的间距
public int x; // 打印起始坐标(x)
public int y; // 打印起始坐标(y)
public int direction; // 打印方向类型:正向打印(0),反方向打印,从下往上(1);
public int mirror; // 是否镜像类型:正常(0), 开启镜像(1);
printInfoList中的内容用于描述打印内容,具体参数说明如下:
// 公共参数
public int type; // 打印内容的类型: 打印文字(1),打印二维码(2),打印条形码(3)
public int x; // 打印起始坐标x
public int y; // 打印起始坐标y
public int rotation; // 旋转角度:0 90 150 270
public String text; // 打印文字的内容
// 打印文字相关
public String font; // 字体类型:1-10、简体中文("TSS24.BF2"),繁体中文("TST24.BF2"), 韩语("K");
public int scaleX; // x轴放大系数: 1-10
public int scaleY; // y轴放大系数: 1-10
// 打印二维码相关
public String level; // 纠错级别:L M Q H
public int cellWidth = 5;
// 打印条形码相关
public int readable; //是否打印可识别字符 DISABLE(0),EANBEL(1);
public int height = 100; // 条形码高度
public String barType; // 条形码编码类型: CODE128 ..
Office文件预览插件使用说明
<officeFrame ref="officeView" officeUrl="/storage/emulated/0/excel001.xlsx" style="width:1260;height:700" @onInit="onInit" @click="officeClick"></officeFrame>
可以通过width、height 属性控制控件大小
onInit(e) {
this.name = "onInit --> "+e.detail.type + " "+ e.detail.msg+ " "+ e.detail.progress+ " "+ e.detail.isSuccess;
},
其中
type 回调类型 1.内核下载中 2. 内核下载完成 3.内核安装完成 4.控件初始化完成(需根据isSuccess判断是否成功),
msg 当前状态描述
progress 下载进度
isSuccess 控件是否加载成功
officeClick(e) {
this.name = "loadFile"
this.$refs.officeView.loadFile("/sdcard/ppt001.pptx");
},
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。