更新记录
1.0.2(2024-01-03)
一、测试
1.0.1(2024-01-03)
一、完善文档
1.0.0(2024-01-03)
首次提交
查看更多
平台兼容性
App |
快应用 |
微信小程序 |
支付宝小程序 |
百度小程序 |
字节小程序 |
QQ小程序 |
HBuilderX 3.6.8,Android:5.0,iOS:不支持 |
× |
× |
× |
× |
× |
× |
钉钉小程序 |
快手小程序 |
飞书小程序 |
京东小程序 |
× |
× |
× |
× |
H5-Safari |
Android Browser |
微信浏览器(Android) |
QQ浏览器(Android) |
Chrome |
IE |
Edge |
Firefox |
PC-Safari |
× |
× |
× |
× |
× |
× |
× |
× |
× |
华为ScanKit统一扫码插件目前支持仅Android
请先试用、若觉得合适,可购买插件。购买后,使用流程和试用一样。一经购买,概不退换,请谨慎试用/购买。
代码示例
<template>
<view class="content">
<view class="result_view">扫描结果:{{result}}</view>
<view class="item" @click="selectScanMode('defaultMode')">开启扫描</view>
</view>
</template>
<script>
import getHwscanManager from '@/uni_modules/hd-hwscan';
const hwscanManager = getHwscanManager();
export default {
data() {
return {
result: "",
}
},
methods: {
// 选择扫描类型
selectScanMode(mode) {
let scanOption = {
scanMode: mode, //扫描模式
scanType: [],
scanResultImage: false, //是否返回扫描图片
pictureBase64: "", //要识别的图片(转base64)
scanTypeOptions: {
scanTitle: "华为扫描", //导航栏标题
showPhotoAlbum: true, //显示扫描相册
showLight: false, //显示手电筒
showScanFrame: true, //是否显示扫描框
showLine: true, //是否显示扫描线条
scanLineColor: "#6065ff", //扫描线条背景色
lineAnimationDuration: 3, //扫码线条动画时间 默认 3秒
sleep: 3, //连续扫描时间间隔,默认1秒
showScanMessage: true, //显示扫描框上方提示文字
scanMessage: "将码放入取景框,即可自动扫描", //扫描框上方提示文字
scanFrameSize: 300, //扫描框大小
scanFrameBackgroudColor: "#2123bcd4", //扫描框背景
scanFrameStrokeColor: "#e1ffff", //扫描框外边框
scanContinue: false, //连续扫描
scanFrameRoundedCorner: 6 //扫描框圆角
}
}
// console.log("scanOptions",scanOption)
hwscanManager.hwScan(scanOption, (res) => {
this.result = res.result
console.log("扫描结果:" + res.result);
/* uni.showToast({
title: res.result,
icon: 'none',
duration: 1500
}) */
});
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
width: 750rpx;
background-color: #ffffff;
align-items: center;
}
.result_view {
display: flex;
justify-content: center;
width: 750rpx;
padding: 10rpx 20rpx;
box-sizing: border-box;
}
.item {
display: flex;
align-items: center;
justify-content: center;
width: 690rpx;
height: 90rpx;
background-image: linear-gradient(to right, #d0d0d0, #d39694);
color: #ffffff;
margin-top: 20rpx;
border-radius: 15rpx;
}
.result_photo {
width: 750rpx;
background-color: #2a690e;
margin-top: 20rpx;
}
</style>
开发文档
UTS 语法
UTS API插件
UTS 组件插件
Hello UTS