更新记录

1.1.7(2026-05-22)

Android 端增加额外参数返回

1.1.6(2026-05-21)

增加ios端多语言

1.1.5(2026-02-09)

优化

查看更多

平台兼容性

uni-app(4.07)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - - - 5.0 15 -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 小红书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - - -

uni-app x(4.07)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - 5.0 - - -

其他

多语言 暗黑模式 宽屏模式
× ×

xtf-scanqrcode

二维码扫描

插件测试使用方法

1.选择试用,绑定要试用的项目appid,

2.选择后下载到对应的本地项目,

3.按照文档 -》把插件引入项目(即 import {openScan,ScanConfig} from "@/uni_modules/xtf-scanqrcode" 需要先引入),

4.发布-》云打包-》选择制作基座-》打包等基座制作完成

5.运行 -》 运行到手机或模拟器-》运行到Androidapp基座-》选择使用自定义基座运行-》选择手机-》运行

6.之前若安装过基座 ,请卸载之前的基座

注意

插件使用谷歌扫码库,安卓和iOS功能有一些区别 界面样式和自定义功能,请注意先试用 ios 支持ios15.5版本

uniappx

import {openScan,ScanConfig} from "@/uni_modules/xtf-scanqrcode"
openScan({
    scanHintText:"一维码/二维码",
    fullScreenScan:false,
    isShowBeep:true,
    isShowLightController:true,
    isShowPhotoAlbum:true,
    success: (type:number,data:string,exterData:string) => {
        if(type==0){
            that.title=data;
        }
    }

}  as ScanConfig)

uniapp

import {openScan} from "@/uni_modules/xtf-scanqrcode"
openScan({
    scanHintText:"一维码/二维码",
    fullScreenScan:false,
    isShowBeep:true,
    isShowLightController:true,
    isShowPhotoAlbum:true,
    success: (type,data,exterData) => {
        if(type==0){
            that.title=data;
        }
    }
} )

ScanConfig 参数介绍

export type ScanConfig={
    continueScan?:boolean, 默认false  是否继续扫码
    continueScanDelayTime?:number, 默认3000  继续扫码下次扫码间隔
    isShowVibrate?:boolean,//设置完成震动
    isShowBeep?:boolean,//扫描完成声音
    isShowPhotoAlbum?:boolean,//显示相册功能
    isShowLightController?:boolean,//显示闪光灯
    scanHintText?:string,// 扫描提示文字
    scanHintTextColor?:string,// 扫码提示文字颜色
    scanHintTextSize?:number,// 扫码提示文字大小
    scanColor?:string,//扫码颜色
    supportZoom?:boolean// 是否支持缩放
    laserStyle?:boolean,

    bgColor?:string,// 背景颜色
    // gridScanLineColumn:number,
    fullScreenScan?:boolean,// 是否全屏,
    statusBarColor?:string// 状态栏背景颜色
    statusBarDark?:boolean,// 状态栏文字颜色
    scanFrameSizeScale?:number,// 框大小 0-1
    zhezhao?:boolean,// 是否有遮罩
    localizedText?:{
        scanHint?:string,// iOS扫码提示文案
        recognizing?:string,// iOS识别中提示
        zoomPrefix?:string,// iOS缩放前缀
        cameraPermissionTitle?:string,
        cameraPermissionMessage?:string,
        cameraPermissionCancel?:string,
        cameraPermissionSettings?:string,
        photoPermissionTitle?:string,
        photoPermissionMessage?:string,
        photoPermissionCancel?:string,
        photoPermissionSettings?:string,
        cancel?:string,
        scanning?:string,
        recognizingImageQrCode?:string,
        recognitionTimeout?:string,
        noQrCodeDetected?:string,
        multipleQrCodeTitle?:string,
        multipleQrCodeMessagePrefix?:string,
        viewAll?:string,
        useThis?:string,
        reselect?:string,
        selectQrCode?:string,
        scanSuccessTitle?:string,
        errorTitle?:string,
        confirm?:string,
        imageLoadFailed?:string,
        unableToLoadImage?:string,
        unableToReadImage?:string,
        unableToAccessCamera?:string,
        unableToCreateVideoInput?:string,
        unableToAddVideoInput?:string,
        torchControlFailed?:string,
        recognitionFailedPrefix?:string
    },// iOS界面多语言覆盖文案;默认会从插件 app-ios/Resources 下的英文/繁体/简体/日语 JSON 按系统语言读取
    success:(type:number,data:string,exterData:string)=>void// 成功回调
    imageCallback?:(data:string)=>void// 扫描时相片地址回到  需要就写 可为空
}

iOS 内置语言包

  • 默认语言包位于 uni_modules/xtf-scanqrcode/utssdk/app-ios/Resources/
  • 当前内置:xtf_scanqrcode_i18n_en.jsonxtf_scanqrcode_i18n_zh-Hans.jsonxtf_scanqrcode_i18n_zh-Hant.jsonxtf_scanqrcode_i18n_ja.json
  • Swift 会按系统语言自动选择,未知语言回退到简体中文
  • localizedText 用于在默认 JSON 语言包之上做局部覆盖

iOS 指定完整语言包方式

  • 插件当前不会通过单独的 locale 参数切换 iOS 语言,而是优先按 iOS 系统首选语言自动匹配完整语言包
  • 语言选择逻辑位于 utssdk/app-ios/ScannerViewController.swiftselectedLanguageCode()
  • 当前支持的语言标识为:enzh-Hanszh-Hantja
  • 对应语言文件必须放在 uni_modules/xtf-scanqrcode/utssdk/app-ios/Resources/ 目录下,并命名为 xtf_scanqrcode_i18n_{语言标识}.json
  • 当系统语言命中内置映射时,插件会自动读取对应 JSON 作为整套界面文案
  • 当系统语言没有命中内置映射时,会回退到 xtf_scanqrcode_i18n_zh-Hans.json

完整语言包命名示例:

xtf_scanqrcode_i18n_en.json
xtf_scanqrcode_i18n_zh-Hans.json
xtf_scanqrcode_i18n_zh-Hant.json
xtf_scanqrcode_i18n_ja.json

如果需要新增一种完整语言包,例如韩语,需要同时处理两部分:

    1. utssdk/app-ios/Resources/ 新增 xtf_scanqrcode_i18n_ko.json
    1. utssdk/app-ios/ScannerViewController.swiftselectedLanguageCode() 中补充 ko 的映射逻辑

说明:

  • 如果只是临时改某几个按钮或提示语,推荐继续使用 localizedText
  • 如果希望整套扫码页面跟随 iOS 系统语言自动切换,推荐使用完整语言包方式

iOS 多语言示例

openScan({
    scanHintText:"Place the code inside the frame",
    localizedText:{
        scanning:"Scanning...",
        cameraPermissionTitle:"Camera Access Required",
        cameraPermissionMessage:"Enable camera access in Settings to scan codes",
        cameraPermissionCancel:"Cancel",
        cameraPermissionSettings:"Settings",
        confirm:"OK"
    },
    success: (type:number,data:string) => {
        if(type==0){
            that.title=data;
        }
    }
} as ScanConfig)

开发文档

UTS 语法 UTS API插件 UTS uni-app兼容模式组件 UTS 标准模式组件 Hello UTS

隐私、权限声明

1. 本插件需要申请的系统权限列表:

<uses-permission android:name="android.permission.CAMERA" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.FLASHLIGHT" />

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率: