wui-components-v2 1.1.18 → 1.1.20

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/api/core/index.ts CHANGED
@@ -19,7 +19,7 @@ interface RequestOptions {
19
19
  function request(options: RequestOptions): Promise<any> {
20
20
  const baseUrl = uni.getStorageSync('BASE_URL') || '/'
21
21
  const hydrocarbonProgramToken = uni.getStorageSync('HYDROCARBON_PROGRAM_TOKEN') || ''
22
- const token = uni.getStorageSync('TOKEN') || ''
22
+ const token = uni.getStorageSync('TOKEN') || uni.getStorageSync('token') ||''
23
23
  const hydrocarbonClient = uni.getStorageSync('HYDROCARBON_CLIENT') || ''
24
24
  console.log('request', baseUrl + options.url, options.data)
25
25
  return new Promise((resolve, reject) => {
package/index.ts CHANGED
@@ -23,7 +23,6 @@ import WuiScanBindingSensor from './components/wui-scan-binding-sensor/wui-scan-
23
23
  import WuiUser from './components/wui-user/wui-user.vue'
24
24
  import WuiAutoUpdateComponent from './components/wui-auto-update-component/wui-auto-update-component.vue'
25
25
  import iData from './utils/idata-scan'
26
- import nfc from './utils/nfc'
27
26
 
28
27
  // 组件列表
29
28
  const coms: Array<{ name: string }> = [
@@ -67,7 +66,7 @@ export {
67
66
  useUser,
68
67
  persistPlugin,
69
68
  iData, // PAD扫描
70
- nfc, // nfc读取
69
+ // nfc, // nfc读取
71
70
  }
72
71
 
73
72
  export default install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wui-components-v2",
3
- "version": "1.1.18",
3
+ "version": "1.1.20",
4
4
  "description": "wui 组件库",
5
5
  "author": "wgxshh",
6
6
  "license": "MIT",
@@ -1,99 +1,99 @@
1
- // 注意:需要在插件市场 安装 安卓原生插件“iData条码扫描插件”,https://ext.dcloud.net.cn/plugin?id=3898#
2
- interface callback {
3
- (scanData: any): void
4
- }
5
- let barcodeModel: { initScan: (arg0: (ret: any) => void) => void, closeScan: (arg0: (ret: any) => void) => void, scanStop: (arg0: (ret: any) => void) => void, scanStart: (arg0: (ret: any) => void) => void } | null = null
6
- let globalEvent: {
7
- addEventListener: (arg0: string, arg1: (e: any) => void) => void
8
- removeEventListener: (arg0: string) => void
9
- } | null = null
10
-
11
- // 初始化手持机扫码模块
12
- function initBarcode(callback: callback) {
13
- // #ifdef APP-PLUS
14
- console.log('initBarcode')
15
-
16
- // 获取手持机扫描module
17
- barcodeModel = uni.requireNativePlugin('iData-BarcodePlugin-BarcodeModule')
18
-
19
- if (!barcodeModel) {
20
- return uni.showToast({
21
- icon: 'none',
22
- title: '请在插件市场安装安卓原生插件“iData条码扫描插件”',
23
- })
24
- }
25
- // 初始化
26
- barcodeModel.initScan(() => {
27
-
28
- })
29
-
30
- // 页面监听event事件,建议在页面onLoad方法里调用
31
- globalEvent = uni.requireNativePlugin('globalEvent')
32
-
33
- if (globalEvent) {
34
- globalEvent.addEventListener('iDataBarcodeEvent', (e: any) => {
35
- console.log(`收到条码:${e.barcode}`)
36
- // 判断是否登录
37
- const token = uni.getStorageSync('token')
38
- if (!token) {
39
- return uni.showModal({
40
- title: '提示',
41
- content: '请登录,才可使用扫码功能',
42
- success(res) {
43
- if (res.confirm) {
44
- console.log('用户点击确定')
45
- uni.reLaunch({
46
- url: '/pages/login/login',
47
- })
48
- }
49
- else if (res.cancel) {
50
- console.log('用户点击取消')
51
- }
52
- },
53
- })
54
- }
55
- callback(e)
56
- })
57
- }
58
-
59
- // #endif
60
- }
61
- function closeBarcode() {
62
- // #ifdef APP-PLUS
63
- // 建议在页面onExit方法里调用
64
- // 接口closeScan(UniJSCallback callback)
65
- // 结束扫描
66
- barcodeModel?.closeScan((ret: any) => {
67
- console.log(ret)
68
- })
69
- // #endif
70
- }
71
-
72
- function stopBarcode() {
73
- // #ifdef APP-PLUS
74
- /// 手动调用
75
- // 停止扫描
76
- // 接口scanStop(UniJSCallback callback)
77
- globalEvent?.removeEventListener('iDataBarcodeEvent')
78
- barcodeModel?.scanStop((ret) => {
79
- console.log(ret)
80
- })
81
-
82
- // #endif
83
- }
84
- function startBarcode() {
85
- // #ifdef APP-PLUS
86
- // 手动调用
87
- // 开始扫描
88
- // 接口scanStop(UniJSCallback callback)
89
- barcodeModel?.scanStart((ret) => {
90
- console.log(ret)
91
- })
92
- // #endif
93
- }
94
- export default {
95
- initBarcode,
96
- closeBarcode,
97
- stopBarcode,
98
- startBarcode,
99
- }
1
+ // 注意:需要在插件市场 安装 安卓原生插件“iData条码扫描插件”,https://ext.dcloud.net.cn/plugin?id=3898#
2
+ interface callback {
3
+ (scanData: any): void
4
+ }
5
+ let barcodeModel: { initScan: (arg0: (ret: any) => void) => void, closeScan: (arg0: (ret: any) => void) => void, scanStop: (arg0: (ret: any) => void) => void, scanStart: (arg0: (ret: any) => void) => void } | null = null
6
+ let globalEvent: {
7
+ addEventListener: (arg0: string, arg1: (e: any) => void) => void
8
+ removeEventListener: (arg0: string) => void
9
+ } | null = null
10
+
11
+ // 初始化手持机扫码模块
12
+ function initBarcode(callback: callback) {
13
+ // #ifdef APP-PLUS
14
+ console.log('initBarcode')
15
+
16
+ // 获取手持机扫描module
17
+ barcodeModel = uni.requireNativePlugin('iData-BarcodePlugin-BarcodeModule')
18
+
19
+ if (!barcodeModel) {
20
+ return uni.showToast({
21
+ icon: 'none',
22
+ title: '请在插件市场安装安卓原生插件“iData条码扫描插件”',
23
+ })
24
+ }
25
+ // 初始化
26
+ barcodeModel.initScan(() => {
27
+
28
+ })
29
+
30
+ // 页面监听event事件,建议在页面onLoad方法里调用
31
+ globalEvent = uni.requireNativePlugin('globalEvent')
32
+
33
+ if (globalEvent) {
34
+ globalEvent.addEventListener('iDataBarcodeEvent', (e: any) => {
35
+ console.log(`收到条码:${e.barcode}`)
36
+ // 判断是否登录
37
+ const token = uni.getStorageSync('token')
38
+ if (!token) {
39
+ return uni.showModal({
40
+ title: '提示',
41
+ content: '请登录,才可使用扫码功能',
42
+ success(res) {
43
+ if (res.confirm) {
44
+ console.log('用户点击确定')
45
+ uni.reLaunch({
46
+ url: '/pages/login/login',
47
+ })
48
+ }
49
+ else if (res.cancel) {
50
+ console.log('用户点击取消')
51
+ }
52
+ },
53
+ })
54
+ }
55
+ callback(e)
56
+ })
57
+ }
58
+
59
+ // #endif
60
+ }
61
+ function closeBarcode() {
62
+ // #ifdef APP-PLUS
63
+ // 建议在页面onExit方法里调用
64
+ // 接口closeScan(UniJSCallback callback)
65
+ // 结束扫描
66
+ barcodeModel?.closeScan((ret: any) => {
67
+ console.log(ret)
68
+ })
69
+ // #endif
70
+ }
71
+
72
+ function stopBarcode() {
73
+ // #ifdef APP-PLUS
74
+ /// 手动调用
75
+ // 停止扫描
76
+ // 接口scanStop(UniJSCallback callback)
77
+ globalEvent?.removeEventListener('iDataBarcodeEvent')
78
+ barcodeModel?.scanStop((ret) => {
79
+ console.log(ret)
80
+ })
81
+
82
+ // #endif
83
+ }
84
+ function startBarcode() {
85
+ // #ifdef APP-PLUS
86
+ // 手动调用
87
+ // 开始扫描
88
+ // 接口scanStop(UniJSCallback callback)
89
+ barcodeModel?.scanStart((ret) => {
90
+ console.log(ret)
91
+ })
92
+ // #endif
93
+ }
94
+ export default {
95
+ initBarcode,
96
+ closeBarcode,
97
+ stopBarcode,
98
+ startBarcode,
99
+ }
package/utils/nfc.js DELETED
@@ -1,285 +0,0 @@
1
- import { changeLanguageConmon } from '../Locale'
2
-
3
- let NfcAdapter
4
- let NdefRecord
5
- let NdefMessage
6
- let _getCardNo
7
-
8
- export default {
9
- initNFC() {
10
- if (uni.getSystemInfoSync().platform == 'android') {
11
- listenNFCStatus()
12
- }
13
- },
14
- readNFC(callback) {
15
- if (uni.getSystemInfoSync().platform == 'android') {
16
- readData(callback)
17
- }
18
- },
19
- closeNFC() {
20
- if (uni.getSystemInfoSync().platform == 'android') {
21
- closeReadAndWrite()
22
- }
23
- },
24
- }
25
-
26
- function listenNFCStatus() {
27
- try {
28
- const main = plus.android.runtimeMainActivity()
29
- const Intent = plus.android.importClass('android.content.Intent')
30
- const Activity = plus.android.importClass('android.app.Activity')
31
- const PendingIntent = plus.android.importClass('android.app.PendingIntent')
32
- const IntentFilter = plus.android.importClass('android.content.IntentFilter')
33
- NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter')
34
- const nfcAdapter = NfcAdapter.getDefaultAdapter(main)
35
-
36
- if (nfcAdapter == null) {
37
- uni.showToast({
38
- title: changeLanguageConmon('设备不支持NFC!'),
39
- icon: 'none',
40
- })
41
- return
42
- }
43
-
44
- if (!nfcAdapter.isEnabled()) {
45
- uni.showToast({
46
- title: changeLanguageConmon('请在系统设置中先启用NFC功能!'),
47
- icon: 'none',
48
- })
49
- return
50
- }
51
-
52
- const intent = new Intent(main, main.getClass())
53
- intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
54
- const pendingIntent = PendingIntent.getActivity(main, 0, intent, 0)
55
- const ndef = new IntentFilter('android.nfc.action.TECH_DISCOVERED')
56
- ndef.addDataType('*/*')
57
- const intentFiltersArray = [ndef]
58
- const techListsArray = [
59
- ['android.nfc.tech.IsoDep'],
60
- ['android.nfc.tech.NfcA'],
61
- ['android.nfc.tech.NfcB'],
62
- ['android.nfc.tech.NfcF'],
63
- ['android.nfc.tech.Nfcf'],
64
- ['android.nfc.tech.NfcV'],
65
- ['android.nfc.tech.NdefFormatable'],
66
- ['android.nfc.tech.MifareClassic'],
67
- ['android.nfc.tech.MifareUltralight'],
68
- ]
69
- plus.globalEvent.addEventListener('newintent', () => {
70
- setTimeout(handle_nfc_data1, 1000)
71
- }, false)
72
- plus.globalEvent.addEventListener('pause', (e) => {
73
- if (nfcAdapter) {
74
- nfcAdapter.disableForegroundDispatch(main)
75
- }
76
- }, false)
77
- plus.globalEvent.addEventListener('resume', (e) => {
78
- if (nfcAdapter) {
79
- // console.log('resume');
80
- nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray)
81
- }
82
- }, false)
83
- nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray)
84
- }
85
- catch (e) {
86
- console.error(e)
87
- }
88
- }
89
-
90
- function handle_nfc_data1() {
91
- NdefRecord = plus.android.importClass('android.nfc.NdefRecord')
92
- NdefMessage = plus.android.importClass('android.nfc.NdefMessage')
93
- const main = plus.android.runtimeMainActivity()
94
- const intent = main.getIntent()
95
- // console.log("action type:" + intent.getAction());
96
- if (intent.getAction() == 'android.nfc.action.TECH_DISCOVERED') {
97
- if (readyWriteData) {
98
- // __write(intent);
99
- readyWriteData = false
100
- }
101
- else if (readyRead) {
102
- __read(intent)
103
- readyRead = false
104
- }
105
- }
106
- }
107
-
108
- function showToast(msg) {
109
- plus.nativeUI.toast(msg)
110
- }
111
-
112
- // function __write(intent) {
113
- // try {
114
- // waiting.setTitle('请勿移开标签\n正在写入...');
115
- // var text = document.getElementById('text').value;
116
- // console.log("text=" + text);
117
- // var textBytes = plus.android.invoke(text, "getBytes");
118
- // var textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
119
- // plus.android.invoke("text/plain", "getBytes"), plus.android.invoke("", "getBytes"), textBytes);
120
- // var message = new NdefMessage([textRecord]);
121
- // var Ndef = plus.android.importClass('android.nfc.tech.Ndef');
122
- // var NdefFormatable = plus.android.importClass('android.nfc.tech.NdefFormatable');
123
- // var tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
124
- // var ndef = Ndef.get(tag);
125
- // if (ndef != null) {
126
- // var size = message.toByteArray().length;
127
- // console.log("size=" + size);
128
- // ndef.connect();
129
- // if (!ndef.isWritable()) {
130
- // showToast("tag不允许写入");
131
- // waiting.close();
132
- // return;
133
- // }
134
- // if (ndef.getMaxSize() < size) {
135
- // showToast("文件大小超出容量");
136
- // waiting.close();
137
- // return;
138
- // }
139
-
140
- // ndef.writeNdefMessage(message);
141
- // waiting.close();
142
- // showToast("写入数据成功.");
143
- // return;
144
- // } else {
145
- // var format = NdefFormatable.get(tag);
146
- // if (format != null) {
147
- // try {
148
- // format.connect();
149
- // format.format(message);
150
- // showToast("格式化tag并且写入message");
151
- // waiting.close();
152
- // return;
153
- // } catch (e) {
154
- // showToast("格式化tag失败.");
155
- // waiting.close();
156
- // return;
157
- // }
158
- // } else {
159
- // showToast("Tag不支持NDEF");
160
- // waiting.close();
161
- // return;
162
- // }
163
- // }
164
- // } catch (e) {
165
- // console.log("error=" + e);
166
- // waiting.close();
167
- // alert('写入失败');
168
- // }
169
-
170
- // }
171
-
172
- function __read(intent) {
173
- try {
174
- const content = ''
175
- waiting.setTitle(`${changeLanguageConmon('请勿移开卡')}\n${changeLanguageConmon('正在读取数据')}...`)
176
- let tag = plus.android.importClass('android.nfc.Tag')
177
- tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG)
178
- const bytesId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID)
179
- waiting.close()
180
- const tagid = bytesToDecimalString(tag.getId())
181
- if (typeof _getCardNo === 'function') {
182
- _getCardNo(tagid)
183
- }
184
- }
185
- catch (e) {
186
- uni.showToast({
187
- title: e,
188
- icon: 'none',
189
- })
190
- }
191
- }
192
-
193
- // function bytesToHexString(inarray) {
194
- // var i, j, x;
195
- // var hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
196
- // "B", "C", "D", "E", "F"
197
- // ];
198
- // var out = "";
199
- // for (j = 0; j < inarray.length; ++j) {
200
- // x = parseInt(inarray[j]) & 0xff;
201
- // i = (x >> 4) & 0x0f;
202
- // out += hex[i];
203
- // i = x & 0x0f;
204
- // out += hex[i];
205
- // }
206
- // return out;
207
- // }
208
- // function bytesToDecimalString(inarray) {
209
- // let result = BigInt(0);
210
- // // 反转数组以适配大端序
211
- // const reversed = [...inarray].reverse();
212
- // for (let j = 0; j < reversed.length; j++) {
213
- // const byte = BigInt(parseInt(reversed[j])) & BigInt(0xff);
214
- // result = (result << BigInt(8)) | byte;
215
- // }
216
- // return result.toString();
217
- // }
218
-
219
- function bytesToDecimalString(inarray) {
220
- let result = BigInt(0)
221
-
222
- // 反转数组以适配大端序
223
- const reversed = [...inarray].reverse()
224
- for (let j = 0; j < reversed.length; j++) {
225
- const byte = BigInt(Number.parseInt(reversed[j])) & BigInt(0xFF)
226
- result = (result << BigInt(8)) | byte
227
- }
228
- return result.toString().padStart(10, '0')
229
- }
230
-
231
- function reverseTwo(str) {
232
- let str1 = ''
233
- for (var i = 1; i <= str.length; i++) {
234
- str1 += str[i - 1]
235
- if (i % 2 == 0) {
236
- if (i == str.length) {
237
- break
238
- }
239
- str1 += ':'
240
- }
241
- }
242
- let str2 = ''
243
- for (var i = str1.split(':').length - 1; i >= 0; i--) {
244
- str2 += str1.split(':')[i]
245
- }
246
- return str2
247
- }
248
-
249
- if (uni.getSystemInfoSync().platform == 'android') {
250
- // plus.globalEvent.addEventListener('plusready', listenNFCStatus, false);
251
- }
252
-
253
- let waiting
254
- var readyWriteData = false
255
- var readyRead = false
256
-
257
- function writeData() {
258
- const textEle = plus.globalEvent.getElementById('text')
259
- if (!textEle.value) {
260
- uni.showToast({
261
- title: '请输入要写入的内容!',
262
- icon: 'none',
263
- })
264
- return
265
- }
266
- readyWriteData = true
267
- waiting = plus.nativeUI.showWaiting(changeLanguageConmon('请将卡靠近!'))
268
- }
269
-
270
- function readData(getCardNo) {
271
- readyRead = true
272
- _getCardNo = getCardNo
273
- waiting = plus.nativeUI.showWaiting(changeLanguageConmon('请将卡靠近!'), {
274
- modal: false,
275
- })
276
- }
277
-
278
- function closeReadAndWrite() {
279
- readyWriteData = false
280
- readyRead = false
281
-
282
- if (waiting) {
283
- waiting.close()
284
- }
285
- }