w-ui-v1 1.0.67 → 1.0.69
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +3 -1
- package/package.json +1 -1
- package/utils/idata-scan.ts +92 -0
package/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ import WFormControlVue from './w-form-control/w-form-control.vue'
|
|
|
18
18
|
import {menu} from './utils/apis/menu'
|
|
19
19
|
import request from './utils/http'
|
|
20
20
|
import nfc from './utils/nfc'
|
|
21
|
+
import iData from './utils/idata-scan'
|
|
21
22
|
const coms: any[] = [
|
|
22
23
|
wTest,
|
|
23
24
|
wLogin,
|
|
@@ -45,6 +46,7 @@ function install(Vue: App) {
|
|
|
45
46
|
export const api={
|
|
46
47
|
request,
|
|
47
48
|
menu,
|
|
48
|
-
nfc
|
|
49
|
+
nfc,
|
|
50
|
+
iData
|
|
49
51
|
}
|
|
50
52
|
export default install // 这个方法以后再使用的时候可以被vue.use调用
|
package/package.json
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//注意:需要在插件市场 安装 安卓原生插件“iData条码扫描插件”,https://ext.dcloud.net.cn/plugin?id=3898#
|
|
2
|
+
interface callback {
|
|
3
|
+
(scanData:any): void;
|
|
4
|
+
}
|
|
5
|
+
let barcodeModel=null
|
|
6
|
+
let globalEvent=null
|
|
7
|
+
|
|
8
|
+
//初始化手持机扫码模块
|
|
9
|
+
const initBarcode = (callback:callback) => {
|
|
10
|
+
// #ifdef APP-PLUS
|
|
11
|
+
console.log("initBarcode")
|
|
12
|
+
|
|
13
|
+
//获取手持机扫描module
|
|
14
|
+
barcodeModel = uni.requireNativePlugin("iData-BarcodePlugin-BarcodeModule")
|
|
15
|
+
|
|
16
|
+
if(!barcodeModel){
|
|
17
|
+
return uni.showToast({
|
|
18
|
+
icon:"none",
|
|
19
|
+
title:"请在插件市场安装安卓原生插件“iData条码扫描插件”"
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
//初始化
|
|
23
|
+
barcodeModel.initScan((ret) => {
|
|
24
|
+
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
//页面监听event事件,建议在页面onLoad方法里调用
|
|
28
|
+
globalEvent = uni.requireNativePlugin('globalEvent');
|
|
29
|
+
|
|
30
|
+
globalEvent.addEventListener('iDataBarcodeEvent', function(e:any) {
|
|
31
|
+
console.log("收到条码:" + e.barcode)
|
|
32
|
+
//判断是否登录
|
|
33
|
+
let token=uni.getStorageSync('token')
|
|
34
|
+
if (!token) {
|
|
35
|
+
|
|
36
|
+
return uni.showModal({
|
|
37
|
+
title: '提示',
|
|
38
|
+
content: '请登录,才可使用扫码功能',
|
|
39
|
+
success: function (res) {
|
|
40
|
+
if (res.confirm) {
|
|
41
|
+
console.log('用户点击确定');
|
|
42
|
+
uni.reLaunch({
|
|
43
|
+
url: '/pages/login/login'
|
|
44
|
+
})
|
|
45
|
+
} else if (res.cancel) {
|
|
46
|
+
console.log('用户点击取消');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
}
|
|
52
|
+
callback(e)
|
|
53
|
+
});
|
|
54
|
+
// #endif
|
|
55
|
+
}
|
|
56
|
+
const closeBarcode=()=>{
|
|
57
|
+
// #ifdef APP-PLUS
|
|
58
|
+
//建议在页面onExit方法里调用
|
|
59
|
+
//接口closeScan(UniJSCallback callback)
|
|
60
|
+
//结束扫描
|
|
61
|
+
barcodeModel.closeScan((ret:any) => {
|
|
62
|
+
console.log(ret)
|
|
63
|
+
});
|
|
64
|
+
// #endif
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const stopBarcode=()=>{
|
|
68
|
+
// #ifdef APP-PLUS
|
|
69
|
+
//建议在页面onHide方法里调用
|
|
70
|
+
//停止扫描
|
|
71
|
+
//接口scanStop(UniJSCallback callback)
|
|
72
|
+
barcodeModel.scanStop((ret) => {
|
|
73
|
+
console.log(ret)
|
|
74
|
+
});
|
|
75
|
+
// #endif
|
|
76
|
+
}
|
|
77
|
+
const startBarcode=()=>{
|
|
78
|
+
// #ifdef APP-PLUS
|
|
79
|
+
//建议在页面onShow方法里调用
|
|
80
|
+
//开始扫描
|
|
81
|
+
//接口scanStop(UniJSCallback callback)
|
|
82
|
+
barcodeModel.scanStart((ret) => {
|
|
83
|
+
console.log(ret)
|
|
84
|
+
});
|
|
85
|
+
// #endif
|
|
86
|
+
}
|
|
87
|
+
export default {
|
|
88
|
+
initBarcode,
|
|
89
|
+
closeBarcode,
|
|
90
|
+
stopBarcode,
|
|
91
|
+
startBarcode
|
|
92
|
+
}
|