更新记录
1.0.0(2025-11-05)
uts+kt原生混编的方式实现;不是市场上核心文件打包arr文件uts调用;想怎么改就怎么改
平台兼容性
<template>
<view>
<button @tap="startScan">默认</button>
<button @tap="startCustomScan">多码</button>
<view class="">
扫码结果:{{data}}
</view>
</view>
</template>
<script>
// 在UNIAPP页面中使用
import {
HMSScanUTS
} from '@/uni_modules/huawei-scan';
export default {
data() {
return {
data: ""
}
},
onLoad() {
console.log('HMS Scan初始化')
// 初始化扫描器
const initResult = HMSScanUTS.initScan()
console.log('HMS Scan初始化:', initResult)
},
methods: {
startScan() {
try {
uni.showLoading({
title: '准备扫码...'
})
HMSScanUTS.startScan({
success: (res) => {
this.data = JSON.stringify(res);
console.log(res)
},
fail: (res) => {
console.log('fail', res);
}
})
} catch (error) {
console.error('扫码错误:', error)
uni.showToast({
title: '扫码出错',
icon: 'none'
})
} finally {
uni.hideLoading()
}
},
startCustomScan() {
try {
uni.showLoading({
title: '准备扫码...'
})
HMSScanUTS.startCustomScan({
success: (res) => {
this.data = JSON.stringify(res);
console.log(res)
},
fail: (res) => {
console.log('fail', res);
}
})
} catch (error) {
console.error('扫码错误:', error)
uni.showToast({
title: '扫码出错',
icon: 'none'
})
} finally {
uni.hideLoading()
}
},
}
}
</script>

收藏人数:
购买源码授权版(
试用
赞赏(0)
下载 1
赞赏 0
下载 10720860
赞赏 1797
赞赏
京公网安备:11010802035340号