提交 2c269700 编写于 作者: Q qiang

feat: App 端 uni.scanCode 支持配置 autoDecodeCharSet

上级 13f78be7
......@@ -114,11 +114,12 @@
scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, {
frameColor: '#118CE9',
scanbarColor: '#118CE9'
});
scan.onmarked = function(type, code, file) {
}, webview.__uniapp_auto_decode_char_set);
scan.onmarked = function(type, code, file, charSet) {
var res = {
type: type,
code: code
code: code,
charSet: charSet
};
back()
plus.webview.postMessageToUniNView({
......
......@@ -114,11 +114,12 @@
scan = new plus.barcode.Barcode('scan', webview.__uniapp_scan_type, {
frameColor: '#118CE9',
scanbarColor: '#118CE9'
});
scan.onmarked = function(type, code, file) {
}, webview.__uniapp_auto_decode_char_set);
scan.onmarked = function(type, code, file, charSet) {
var res = {
type: type,
code: code
code: code,
charSet: charSet
};
back()
plus.webview.postMessageToUniNView({
......
export const scanCode = {
onlyFromCamera: {
type: Boolean
},
scanType: {
type: Array
},
autoDecodeCharSet: {
type: Boolean
}
}
......@@ -23,7 +23,8 @@ const MESSAGE_TYPE = 'scanCode'
export function scanCode ({
onlyFromCamera = false,
scanType
scanType,
autoDecodeCharSet
}, callbackId) {
const barcode = plus.barcode
const SCAN_TYPES = {
......@@ -95,18 +96,19 @@ export function scanCode ({
width: '60px',
onclick: function () {
plus.gallery.pick(file => {
barcode.scan(file, (type, code) => {
barcode.scan(file, (type, code, path, charSet) => {
if (isDark) {
plus.navigator.setStatusBarStyle('isDark')
}
result = {
type,
code
code,
charSet
}
webview.close('auto')
}, () => {
plus.nativeUI.toast('识别失败')
}, filters)
}, filters, autoDecodeCharSet)
}, err => {
if (err.code !== 12) {
plus.nativeUI.toast('选择失败')
......@@ -135,6 +137,7 @@ export function scanCode ({
__uniapp_type: 'scan',
__uniapp_dark: isDark,
__uniapp_scan_type: filters,
__uniapp_auto_decode_char_set: autoDecodeCharSet,
'uni-app': 'none'
})
const waiting = plus.nativeUI.showWaiting()
......@@ -148,7 +151,7 @@ export function scanCode ({
invoke(callbackId, {
result: result.code,
scanType: SCAN_MAPS[result.type] || '',
charSet: 'utf8',
charSet: result.charSet || 'utf8',
path: '',
errMsg: 'scanCode:ok'
})
......
......@@ -23,9 +23,7 @@ export function scanCode (options, callbackId) {
let result
const page = showPage({
url: '__uniappscan',
data: {
scanType: options.scanType
},
data: options,
style: {
animationType: options.animationType || 'pop-in',
titleNView: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册