更新记录
1.0.9(2025-04-01)
添加参数: 1、photoAlbumTitle //右上角相册文字(默认相册 2、loadingTip //手动关闭时,菊花弹框文字提示(默认没文字提示,只有菊花转
1.0.8(2024-12-02)
优化
1.0.7(2024-12-01)
修复iOS打包问题
查看更多平台兼容性
uni-app
Vue2 | Vue3 | Chrome | Safari | app-vue | app-nvue | Android | iOS | 鸿蒙 |
---|---|---|---|---|---|---|---|---|
√ | √ | - | - | - | - | - | - | - |
微信小程序 | 支付宝小程序 | 抖音小程序 | 百度小程序 | 快手小程序 | 京东小程序 | 鸿蒙元服务 | QQ小程序 | 飞书小程序 | 快应用-华为 | 快应用-联盟 |
---|---|---|---|---|---|---|---|---|---|---|
- | - | - | - | - | - | - | - | - | - | - |
安卓、苹果单次、持续扫二维码、条形码
试用需打包自定基座
引用插件1(.vue)
import {
scan, //持续回调时使用
onScan,
closeScanPage,
reScan
} from '@/uni_modules/u-zm-scan'
方法调用
//1、单次扫码(自动关闭扫码界面)
onScan({
title: "扫一扫",
vibrateEnable: true, //是否震动
animated: true, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
isInvertcolors: true, //是否反色识别(默认false
isHidePhotoAlbum: true, //是否隐藏相册(默认false
success: function(response) {
console.log("扫码结果:" + response)
// isDoneAutoCloseEnable:false时,手动关闭扫码界面
setTimeout(() => {
// closeScanPage()
reScan("二维码无效") //(注:调用方法时,需要使用scan()方法打开扫码 确保持续回调)
}, 3000)
},
fail: function(err) {
console.log("fail:", err);
}
})
//2、单次扫码(手动关闭扫码界面)
scan({
title: "扫一扫",
vibrateEnable: true, //是否震动
isContinuous: false, //是否持续扫码
animated: true, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
isInvertcolors: true, //是否反色识别(默认false
isHidePhotoAlbum: true, //是否隐藏相册(默认false
photoAlbumTitle: "本地图片", //右上角相册文字(默认相册
isDoneAutoCloseEnable: false, //单次扫码成功后自动关闭扫码界面(默认true),设false时需要手动调用zmScan.closeScanPage()
loadingTip: "处理中", //手动关闭时,菊花弹框文字提示(默认没文字提示,只有菊花转
success: function(response) {
console.log("扫码结果:" + response)
// isDoneAutoCloseEnable:false时,手动关闭扫码界面
setTimeout(() => {
// closeScanPage()
reScan("二维码无效") //(注:调用方法时,需要使用scan()方法打开扫码 确保持续回调)
}, 3000)
},
fail: function(err) {
console.log("fail:", err);
}
})
//3、持续扫码(需要持续回调 所以使用scan())
scan({
title: "持续扫码",
vibrateEnable: true, //是否震动
isContinuous: true, //是否持续扫码
animated: false, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
isShowResultTip: false, //持续扫码是否显示结果提示(默认true)
success: function(response) {
console.log("扫码结果:" + response)
},
fail: function(err) {
console.log("fail:", err);
}
})
//3、关闭扫码界面
closeScanPage() (单次扫码并isDoneAutoCloseEnable参数设为flase时有效)
//4、重新扫码
reScan("二维码无效") (单次扫码并isDoneAutoCloseEnable参数设为flase时有效)
引用插件2(.uvue)
import {
scan, //持续回调时使用
onScan,
closeScanPage,
reScan,
ScanOptions
} from '@/uni_modules/u-zm-scan'
//1、单次扫码(自动关闭扫码界面)
onScan({
title: "扫一扫",
vibrateEnable: true, //是否震动
animated: true, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
isDoneAutoCloseEnable: false, //单次扫码成功后自动关闭扫码界面(默认true),设false时需要手动调用zmScan.closeScanPage()
success: function(response) {
console.log("扫码结果:" + response)
},
fail: function(err) {
console.log("fail:", err);
}
} as ScanOptions)
//2、单次扫码(手动关闭扫码界面)
scan({
title: "扫一扫",
vibrateEnable: true, //是否震动
isContinuous: false, //是否持续扫码
animated: true, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
photoAlbumTitle: "本地图片", //右上角相册文字(默认相册
isDoneAutoCloseEnable: false, //单次扫码成功后自动关闭扫码界面(默认true),设false时需要手动调用zmScan.closeScanPage()
loadingTip: "处理中", //手动关闭时,菊花弹框文字提示(默认没文字提示,只有菊花转
success: function(response) {
console.log("扫码结果:" + response)
},
fail: function(err) {
console.log("fail:", err);
}
} as ScanOptions)
//3、持续扫码
scan({
title: "持续扫码",
vibrateEnable: true, //是否震动
isContinuous: true, //是否持续扫码
animated: false, //是否动画显示
type: 0, //iOS有效(0使用原生扫码,1使用ZBarSdk扫码;选传 默认值0)
isShowResultTip: false, //持续扫码是否显示结果提示(默认true)
success: function(response) {
console.log("扫码结果:" + response)
},
fail: function(err) {
console.log("fail:", err);
}
} as ScanOptions)
//3、关闭扫码界面
closeScanPage() (单次扫码并isDoneAutoCloseEnable参数设为flase时有效)
//4、重新扫码
reScan("二维码无效") (单次扫码并isDoneAutoCloseEnable参数设为flase时有效)