@10yun/cv-mobile-ui 0.5.51 → 0.5.52

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.
Files changed (110) hide show
  1. package/build/common_func.js +3 -1
  2. package/build/parse-create.js +17 -8
  3. package/build/parse-pages-pkg.js +10 -4
  4. package/empty-devtools.js +3 -0
  5. package/libs/aes.js +50 -0
  6. package/libs/bledefine/bledefine.js +51 -0
  7. package/libs/bledefine/ios-ble-statuscode.js +97 -0
  8. package/libs/nfc/hexiii-nfc.js +236 -0
  9. package/libs/nfc.js +179 -0
  10. package/libs/sdk/html2canvas.js +8 -0
  11. package/libs/sdk/sdk-h5.js +585 -0
  12. package/{plugins → libs}/storage2.js +0 -5
  13. package/{plugins → libs}/storage3.js +0 -4
  14. package/libs/validators/index.js +438 -0
  15. package/libs/weapp-qrcode.js +1108 -0
  16. package/package.json +2 -3
  17. package/ui-cv/components/cv-dialog-share/tui-share.vue +16 -16
  18. package/ui-fireui/components/{fui-actionsheet/fui-actionsheet.vue → u-action-sheet/u-action-sheet.vue} +21 -21
  19. package/ui-fireui/components/{fui-alert/fui-alert.vue → u-alert/u-alert.vue} +13 -13
  20. package/ui-fireui/components/{fui-badge/fui-badge.vue → u-badge/u-badge.vue} +16 -16
  21. package/ui-fireui/components/{fui-bottom-navigation/fui-bottom-navigation.vue → u-bottom-navigation/u-bottom-navigation.vue} +47 -46
  22. package/ui-fireui/components/{fui-bottom-popup/fui-bottom-popup.vue → u-bottom-popup/u-bottom-popup.vue} +9 -8
  23. package/ui-fireui/components/{fui-bubble-popup/fui-bubble-popup.vue → u-bubble-popup/u-bubble-popup.vue} +19 -15
  24. package/ui-fireui/components/{fui-button/fui-button.vue → u-button/u-button.vue} +69 -69
  25. package/ui-fireui/components/u-button/u-button2.vue +553 -0
  26. package/ui-fireui/components/{fui-calendar/fui-calendar.vue → u-calendar/u-calendar.vue} +78 -78
  27. package/ui-fireui/components/u-calendar/u-calendar2.vue +801 -0
  28. package/ui-fireui/components/{fui-card/fui-card.vue → u-card/u-card.vue} +24 -24
  29. package/ui-fireui/components/{fui-cascade-selection/fui-cascade-selection.vue → u-cascade-selection/u-cascade-selection.vue} +32 -32
  30. package/ui-fireui/components/{fui-circular-progress/fui-circular-progress.vue → u-circular-progress/u-circular-progress.vue} +14 -6
  31. package/ui-fireui/components/{fui-collapse/fui-collapse.vue → u-collapse/u-collapse.vue} +19 -19
  32. package/ui-fireui/components/{fui-countdown/fui-countdown.vue → u-countdown/u-countdown.vue} +28 -28
  33. package/ui-fireui/components/{fui-datetime/fui-datetime.vue → u-datetime/u-datetime.vue} +51 -51
  34. package/ui-fireui/components/{fui-divider/fui-divider.vue → u-divider/u-divider.vue} +6 -6
  35. package/ui-fireui/components/{fui-drawer/fui-drawer.vue → u-drawer/u-drawer.vue} +11 -11
  36. package/ui-fireui/components/{fui-dropdown-list/fui-dropdown-list.vue → u-dropdown-list/u-dropdown-list.vue} +11 -6
  37. package/ui-fireui/components/{fui-fab/fui-fab.vue → u-fab/u-fab.vue} +30 -30
  38. package/ui-fireui/components/{fui-footer/fui-footer.vue → u-footer/u-footer.vue} +19 -15
  39. package/ui-fireui/components/{fui-grid/fui-grid.vue → u-grid/u-grid.vue} +13 -5
  40. package/ui-fireui/components/{fui-grid-item/fui-grid-item.vue → u-grid-item/u-grid-item.vue} +19 -19
  41. package/ui-fireui/components/{fui-icon/fui-icon.vue → u-icon/u-icon.vue} +191 -191
  42. package/ui-fireui/components/{fui-image-cropper/fui-image-cropper.vue → u-image-cropper/u-image-cropper.vue} +44 -44
  43. package/ui-fireui/components/{fui-image-group/fui-image-group.vue → u-image-group/u-image-group.vue} +7 -7
  44. package/ui-fireui/components/{fui-keyboard/fui-keyboard.vue → u-keyboard/u-keyboard.vue} +29 -32
  45. package/ui-fireui/components/{fui-keyboard-input/fui-keyboard-input.vue → u-keyboard-input/u-keyboard-input.vue} +9 -9
  46. package/ui-fireui/components/{fui-list-cell/fui-list-cell.vue → u-list-cell/u-list-cell.vue} +23 -23
  47. package/ui-fireui/components/{fui-list-view/fui-list-view.vue → u-list-view/u-list-view.vue} +11 -11
  48. package/ui-fireui/components/{fui-loading/fui-loading.vue → u-loading/u-loading.vue} +6 -6
  49. package/ui-fireui/components/{fui-loadmore/fui-loadmore.vue → u-loadmore/u-loadmore.vue} +15 -15
  50. package/ui-fireui/components/{fui-modal/fui-modal.vue → u-modal/u-modal.vue} +58 -58
  51. package/ui-fireui/components/{fui-navigation-bar/fui-navigation-bar.vue → u-navigation-bar/u-navigation-bar.vue} +11 -10
  52. package/ui-fireui/components/{fui-no-data/fui-no-data.vue → u-no-data/u-no-data.vue} +11 -11
  53. package/ui-fireui/components/{fui-nomore/fui-nomore.vue → u-nomore/u-nomore.vue} +10 -10
  54. package/ui-fireui/components/{fui-numberbox/fui-numberbox.vue → u-numberbox/u-numberbox.vue} +12 -12
  55. package/ui-fireui/components/{fui-numberbox-border/fui-numberbox-border.vue → u-numberbox-border/u-numberbox-border.vue} +10 -10
  56. package/ui-fireui/components/{fui-picture-cropper/fui-picture-cropper.vue → u-picture-cropper/u-picture-cropper.vue} +42 -42
  57. package/ui-fireui/components/u-picture-cropper/u-picture-cropper.wxs +582 -0
  58. package/ui-fireui/components/{fui-round-progress/fui-round-progress.vue → u-round-progress/u-round-progress.vue} +2 -2
  59. package/ui-fireui/components/{fui-scroll-top/fui-scroll-top.vue → u-scroll-top/u-scroll-top.vue} +21 -21
  60. package/ui-fireui/components/{fui-sharemodel/fui-sharemodel.vue → u-share-model/u-share-model.vue} +24 -24
  61. package/ui-fireui/components/{fui-skeleton/fui-skeleton.vue → u-skeleton/u-skeleton.vue} +22 -22
  62. package/ui-fireui/components/{fui-steps/fui-steps.vue → u-steps/u-steps.vue} +27 -27
  63. package/ui-fireui/components/{fui-sticky/fui-sticky.vue → u-sticky/u-sticky.vue} +4 -4
  64. package/ui-fireui/components/{fui-sticky-wxs/fui-sticky-wxs.vue → u-sticky-wxs/u-sticky-wxs.vue} +7 -7
  65. package/ui-fireui/components/u-sticky-wxs/u-sticky.wxs +46 -0
  66. package/ui-fireui/components/{fui-swipe-action/fui-swipe-action.vue → u-swipe-action/u-swipe-action.vue} +11 -11
  67. package/ui-fireui/components/{fui-tabbar/fui-tabbar.vue → u-tabbar/u-tabbar.vue} +26 -30
  68. package/ui-fireui/components/{fui-tabs/fui-tabs.vue → u-tabs/u-tabs.vue} +17 -17
  69. package/ui-fireui/components/{fui-tabs2/fui-tabs2.vue → u-tabs2/u-tabs2.vue} +17 -17
  70. package/ui-fireui/components/{fui-tag/fui-tag.vue → u-tag/u-tag.vue} +362 -374
  71. package/ui-fireui/components/{fui-time-axis/fui-time-axis.vue → u-time-axis/u-time-axis.vue} +3 -3
  72. package/ui-fireui/components/{fui-timeaxis-item/fui-timeaxis-item.vue → u-timeaxis-item/u-timeaxis-item.vue} +4 -4
  73. package/ui-fireui/components/{fui-tips/fui-tips.vue → u-tips/u-tips.vue} +20 -20
  74. package/ui-fireui/components/{fui-toast/fui-toast.vue → u-toast/u-toast.vue} +13 -13
  75. package/ui-fireui/components/{fui-top-dropdown/fui-top-dropdown.vue → u-top-dropdown/u-top-dropdown.vue} +8 -8
  76. package/ui-fireui/components/{fui-upload/fui-upload.vue → u-upload/u-upload.vue} +30 -30
  77. package/ui-fireui/components/u-upload2/u-upload.vue +464 -0
  78. package/ui-fireui/components/{fui-uploadsamll/fui-uploadsamll.vue → u-uploadsamll/u-uploadsamll.vue} +34 -34
  79. package/ui-fireui/css/thorui.css +589 -0
  80. package/ui-fireui/{fireui.css → index.css} +306 -268
  81. package/ui-fireui/nvue/u-circular-progress/gcanvas/bridge/bridge-weex.js +241 -0
  82. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleLinearGradient.js +18 -0
  83. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStylePattern.js +8 -0
  84. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/FillStyleRadialGradient.js +17 -0
  85. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-2d/RenderingContext.js +666 -0
  86. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ActiveInfo.js +11 -0
  87. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Buffer.js +21 -0
  88. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Framebuffer.js +21 -0
  89. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLenum.js +298 -0
  90. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLmethod.js +142 -0
  91. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/GLtype.js +23 -0
  92. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Program.js +21 -0
  93. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Renderbuffer.js +21 -0
  94. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/RenderingContext.js +1191 -0
  95. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Shader.js +22 -0
  96. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/ShaderPrecisionFormat.js +11 -0
  97. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/Texture.js +22 -0
  98. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/UniformLocation.js +22 -0
  99. package/ui-fireui/nvue/u-circular-progress/gcanvas/context-webgl/classUtils.js +3 -0
  100. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/canvas.js +74 -0
  101. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/image.js +96 -0
  102. package/ui-fireui/nvue/u-circular-progress/gcanvas/env/tool.js +24 -0
  103. package/ui-fireui/nvue/u-circular-progress/gcanvas/index.js +47 -0
  104. package/ui-fireui/nvue/u-circular-progress/u-circular-progress.nvue +203 -0
  105. package/ui-fireui/nvue/u-icon/icons.js +188 -0
  106. package/ui-fireui/nvue/u-icon/u-icon.vue +78 -0
  107. package/ui-fireui/components/fui-picture-cropper/fui-picture-cropper.wxs +0 -560
  108. package/ui-fireui/components/fui-rate/fui-rate.vue +0 -167
  109. package/ui-fireui/components/fui-sticky-wxs/fui-sticky.wxs +0 -44
  110. /package/ui-fireui/components/{fui-calendar/fui-calendar.js → u-calendar/u-calendar.js} +0 -0
@@ -1,4 +1,5 @@
1
1
  import fs from 'node:fs/promises';
2
+ import path from 'node:path';
2
3
  // ---------------------- 蓝色输出工具函数(封装开始)----------------------
3
4
  /**
4
5
  * 原生蓝色文本输出工具
@@ -98,8 +99,9 @@ export async function fs_mkdir_dir(dirPath) {
98
99
  }
99
100
  }
100
101
 
101
- export async function fs_write_file(fileDir, filePath, content) {
102
+ export async function fs_write_file(filePath, content) {
102
103
  try {
104
+ let fileDir = path.dirname(filePath);
103
105
  await fs_mkdir_dir(fileDir);
104
106
  await fs.writeFile(filePath, content, 'utf-8');
105
107
  } catch (error) {
@@ -44,14 +44,9 @@ export async function parseMenuContent(data) {
44
44
  }
45
45
  export async function parseConfigContent(configs) {
46
46
  // 构建要生成的JS内容
47
- let jsContent = `const lastConfigEnv = import.meta.env;
48
- // 本地测试接口 ,线上接口
49
- const isOnline = lastConfigEnv.NODE_ENV === 'development' ? false : true;
50
- // lastConfigEnv.NODE_ENV === 'production',
47
+ let jsContent = `
51
48
  export default {
52
- ...lastConfigEnv,
53
49
  `;
54
-
55
50
  // 添加CONFIGS中的配置项
56
51
  Object.entries(configs).forEach(([key, value], index) => {
57
52
  // 处理值为对象的情况
@@ -59,14 +54,28 @@ export default {
59
54
  const valueStr = isObject ? JSON.stringify(value, null, 2) : typeof value === 'string' ? `"${value}"` : value;
60
55
 
61
56
  jsContent += ` ${key}: ${valueStr}`;
62
-
63
57
  // 添加逗号(最后一项不添加)
64
58
  if (index < Object.entries(configs).length - 1) {
65
59
  jsContent += ',';
66
60
  }
67
61
  jsContent += '\n';
68
62
  });
69
-
70
63
  jsContent += '};\n';
71
64
  return jsContent;
72
65
  }
66
+ /**
67
+ * 纯解析VITE_ENV为.env格式的键值对字符串(无任何文件读取/写入,外部自行拼接原有数据)
68
+ * @param {Object} viteEnv - 配置中的VITE_ENV节点对象
69
+ * @returns {string} 格式化的.env键值对字符串(无数据返回空)
70
+ */
71
+ export async function parseViteEnv(viteEnv) {
72
+ // 校验VITE_ENV有效性,无数据直接返回空
73
+ if (!viteEnv || typeof viteEnv !== 'object' || Object.keys(viteEnv).length === 0) {
74
+ console.log('\x1b[33m[提示]\x1b[0m VITE_ENV无有效配置,跳过.env处理');
75
+ return '';
76
+ }
77
+ // 直接解析为 KEY=VALUE 格式的字符串,每行一个变量
78
+ return Object.entries(viteEnv)
79
+ .map(([key, value]) => `${key}=${value}`)
80
+ .join('\n');
81
+ }
@@ -5,7 +5,6 @@
5
5
  import fs from 'node:fs/promises';
6
6
  import { fileURLToPath } from 'node:url';
7
7
  import { dirname, join as path_join } from 'node:path';
8
- import path from 'node:path';
9
8
  // import { glob } from 'glob';
10
9
  import pkg from 'glob';
11
10
  const { glob } = pkg;
@@ -27,12 +26,14 @@ const MENU_JS_PATH = path_join(PROJECT_SRC, 'router/menu.js');
27
26
  const APP_CONFIG_PATH = path_join(PROJECT_SRC, 'app-config.js');
28
27
  const RBAC_JSON_PATH = path_join(PROJECT_PATH, 'public/rbac.json');
29
28
 
29
+ const ENV_FILE_PATH = path_join(PROJECT_PATH, '.env');
30
+
30
31
  /**
31
32
  * 工具函数
32
33
  */
33
34
  import { fs_read_file, fs_read_json_file, fs_mkdir_dir, fs_write_file, fs_file_exists, getCurrDate } from './common_func.js';
34
35
 
35
- import { parseMenuContent, parseConfigContent } from './parse-create.js';
36
+ import { parseMenuContent, parseConfigContent, parseViteEnv } from './parse-create.js';
36
37
  /**
37
38
  * 初始化模板
38
39
  */
@@ -102,7 +103,7 @@ async function info_parse_data(pages) {
102
103
  }
103
104
  // 生成 menu.js
104
105
  const menuContent = await parseMenuContent(diyPlus);
105
- await fs_write_file(path.dirname(MENU_JS_PATH), MENU_JS_PATH, menuContent);
106
+ await fs_write_file(MENU_JS_PATH, menuContent);
106
107
  console_need_log('【更新文件】', MENU_JS_PATH);
107
108
 
108
109
  // 生成 rbac.json
@@ -159,8 +160,13 @@ async function main() {
159
160
  throw new Error(' json下的 config 内容不存在');
160
161
  }
161
162
  const configContent = await parseConfigContent(config.CONFIGS);
162
- await fs_write_file(path.dirname(APP_CONFIG_PATH), APP_CONFIG_PATH, configContent);
163
+ await fs_write_file(APP_CONFIG_PATH, configContent);
163
164
  console_need_log('【更新文件】', APP_CONFIG_PATH);
165
+
166
+ const envNewContent = await parseViteEnv(config.VITE_ENV);
167
+ const envOldContent = await fs_read_file(ENV_FILE_PATH, false);
168
+ await fs_write_file(ENV_FILE_PATH, envOldContent + '\n\n' + envNewContent + '\n\n');
169
+ console_need_log('【更新文件】', ENV_FILE_PATH);
164
170
  }
165
171
  /**
166
172
  * 生成 app-config.js 内容
@@ -0,0 +1,3 @@
1
+ export function setupDevtoolsPlugin() {}
2
+ export function addTimelineEvent() {}
3
+ export function addInspector() {}
package/libs/aes.js ADDED
@@ -0,0 +1,50 @@
1
+ import CryptoJS from 'crypto-js/crypto-js';
2
+
3
+ // 默认的 KEY 与 iv 如果没有给
4
+ const KEY = CryptoJS.enc.Utf8.parse('trans67890123456');
5
+ const IV = CryptoJS.enc.Utf8.parse('trans67890123456');
6
+ /**
7
+ * AES加密 :字符串 key iv 返回base64
8
+ */
9
+ export function Encrypt(word, keyStr, ivStr) {
10
+ let key = KEY;
11
+ let iv = IV;
12
+
13
+ if (keyStr) {
14
+ key = CryptoJS.enc.Utf8.parse(keyStr);
15
+ iv = CryptoJS.enc.Utf8.parse(ivStr);
16
+ }
17
+
18
+ let srcs = CryptoJS.enc.Utf8.parse(word);
19
+ var encrypted = CryptoJS.AES.encrypt(srcs, key, {
20
+ iv: iv,
21
+ mode: CryptoJS.mode.CBC,
22
+ padding: CryptoJS.pad.ZeroPadding
23
+ });
24
+ return CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
25
+ }
26
+ /**
27
+ * AES 解密 :字符串 key iv 返回base64
28
+ *
29
+ */
30
+ export function Decrypt(word, keyStr, ivStr) {
31
+ let key = KEY;
32
+ let iv = IV;
33
+
34
+ if (keyStr) {
35
+ key = CryptoJS.enc.Utf8.parse(keyStr);
36
+ iv = CryptoJS.enc.Utf8.parse(ivStr);
37
+ }
38
+
39
+ let base64 = CryptoJS.enc.Base64.parse(word);
40
+ let src = CryptoJS.enc.Base64.stringify(base64);
41
+
42
+ var decrypt = CryptoJS.AES.decrypt(src, key, {
43
+ iv: iv,
44
+ mode: CryptoJS.mode.CBC,
45
+ padding: CryptoJS.pad.ZeroPadding
46
+ });
47
+
48
+ var decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
49
+ return decryptedStr.toString().trim();
50
+ }
@@ -0,0 +1,51 @@
1
+ /** 蓝牙锁特性 */
2
+ const kHXLockFunctionType = {
3
+ /** 支持指纹开锁 */
4
+ supportFingerprint: 1 << 0, //第 0 bit
5
+
6
+ /** 支持在门锁中录入密码开锁 */
7
+ supportPassword: 1 << 1, //第 1 bit
8
+
9
+ /** 支持卡片开锁 */
10
+ supportCard: 1 << 2, //第 2 bit
11
+
12
+ /** 支持遥控开锁 */
13
+ supportRemoteControl: 1 << 3, //第 3 bit
14
+
15
+ /** 支持语音 */
16
+ supportVoice: 1 << 9, //第 9 bit
17
+
18
+ /** 支持算法生成的密码开锁 */
19
+ supportOfflinePassword: 1 << 11 //第 11 bit
20
+ };
21
+
22
+ /** 钥匙类型 */
23
+ const KSHKeyType = {
24
+ /** 指纹 */
25
+ Fingerprint: 1 << 0, //1
26
+
27
+ /** 密码 */
28
+ Password: 1 << 1, //2
29
+
30
+ /** 卡 */
31
+ Card: 1 << 2, //4
32
+
33
+ /** 遥控 */
34
+ RemoteControl: 1 << 3, //8
35
+
36
+ /** App开锁 */
37
+ App: 1 << 7 //128
38
+ };
39
+
40
+ /** 星期 */
41
+ const kSHWeek = {
42
+ monday: 1 << 0,
43
+ tuesday: 1 << 1,
44
+ wednesday: 1 << 2,
45
+ thursday: 1 << 3,
46
+ friday: 1 << 4,
47
+ saturday: 1 << 5,
48
+ sunday: 1 << 6
49
+ };
50
+
51
+ export { kHXLockFunctionType, KSHKeyType, kSHWeek };
@@ -0,0 +1,97 @@
1
+ /**
2
+ 结果状态码
3
+ */
4
+ const KSHStatusCode = {
5
+ /** 返回成功 */
6
+ Success: 0,
7
+ /** 操作失败 */
8
+ Failed: -100003,
9
+ /** 无效参数 */
10
+ invalidParam: -100004,
11
+ /** 请求超时 */
12
+ Timeout: -100005,
13
+ /** 蓝牙外设中不存在该服务 */
14
+ ServiceNotExist: -800001,
15
+ /** 蓝牙外设中还没有发现该服务,可能是因为还未读取外设的服务 */
16
+ ServiceNotFound: -800002,
17
+ /** 当前服务中不存在任何特征 */
18
+ CharacteristicNotExist: -800003,
19
+ /** 蓝牙不可用 */
20
+ BluetoothStateUnavailable: -800004,
21
+ /** 与外设断开连接 */
22
+ DidDisconnectPeripheral: -800005,
23
+ /** 连接外设失败 */
24
+ BluetoothConnectionFailed: -800006,
25
+ /** DNA密钥错误,设备可能被重置过,请重新添加设备 */
26
+ DNAKeyWrong: -800007,
27
+ /** 未找到特征值 */
28
+ CharacteristicNotFound: -800008,
29
+ /** 未发现蓝牙外设 */
30
+ BluetoothNotFound: -800009,
31
+ /** 用户不允许App访问蓝牙 */
32
+ BluetoothStateDenied: -800010,
33
+ /**密码错误*/
34
+ PasswordError: 2,
35
+ /**远程开锁未开启(锁本地拨码开关未打上)*/
36
+ NoAppUnlockFunction: 3,
37
+ /**参数错误*/
38
+ ParameterError: 4,
39
+ /**禁止此项操作,请先添加管理员*/
40
+ NeedAddAdminFirst: 5,
41
+ /**门锁不支持此命令或操作*/
42
+ DoorlockNotSupported: 6,
43
+ /**重复添加(卡片/密码等)*/
44
+ KeysAlreadyExist: 7,
45
+ /**编号错误*/
46
+ ErrorNo: 8,
47
+ /**不允许开反锁*/
48
+ AntiLockNotAllowed: 9,
49
+ /**系统已锁定*/
50
+ SystemLocked: 0xa, //10
51
+ /**禁止删除管理员*/
52
+ AdmCannotBeDeleted: 0xb, //11
53
+ /**门锁存储数量已满,不允许再设置*/
54
+ LockedMemorySpaceFull: 0xe, //14
55
+ /**还有后续数据包*/
56
+ WaitForOtherPackets: 0xf, //15
57
+ /**门已反锁,不允许开反锁*/
58
+ DoorIsLockedAndAntilockNotAllowed: 0x10, //16
59
+ /**退出添加钥匙*/
60
+ ExitAddKey: 0x11,
61
+ /**鉴权失败*/
62
+ AuthError: 0xe1, //225
63
+ /**命令发送过去频繁*/
64
+ Busy: 0xe2, //226
65
+ /**加密类型错误,可尝试初始化设备后重新添加*/
66
+ TypeError: 0xe4, //228
67
+ /**SessionId错误*/
68
+ SessionIdError: 0xe5, //229
69
+ /**设备未进入配对状态*/
70
+ NotPairing: 0xe6, //230
71
+ /**命令不允许*/
72
+ CmdNotAllowed: 0xe7, //231
73
+ /**请先添加设备*/
74
+ NeedToAddDeviceFirst: 0xe8, //232
75
+ /**您已拥有该设备的使用权限,不需要再重复添加*/
76
+ DeviceHasBeenAdded: 0xea, //234
77
+ /**无权限*/
78
+ Forbidden: 0xeb, //235
79
+ /**命令版本不支持*/
80
+ notSupportedCmdVer: 0xec, //236
81
+ /**失败*/
82
+ Failed: -100003,
83
+ /**NB模组正忙*/
84
+ NBBusy: 0x23,
85
+ /**NB模组未进入AT模式*/
86
+ NBNotOpenATMode: 0x24,
87
+ /**NB模组处于AT模式,暂不响应其它命令*/
88
+ NBATMode: 0x25,
89
+ /**无线模组信号差*/
90
+ rfModuleWeakSignal: 0x26,
91
+ /**无线模组处于飞行模式*/
92
+ rfModuleInAirplaneMode: 0x27,
93
+ /**钥匙已被顶替*/
94
+ keyReplaced: 0xef
95
+ };
96
+
97
+ export { KSHStatusCode };
@@ -0,0 +1,236 @@
1
+ // 包路径
2
+ const package_NdefRecord = 'android.nfc.NdefRecord';
3
+ const package_NdefMessage = 'android.nfc.NdefMessage';
4
+ const package_TECH_DISCOVERED = 'android.nfc.action.TECH_DISCOVERED';
5
+ const package_Intent = 'android.content.Intent';
6
+ const package_Activity = 'android.app.Activity';
7
+ const package_PendingIntent = 'android.app.PendingIntent';
8
+ const package_IntentFilter = 'android.content.IntentFilter';
9
+ const package_NfcAdapter = 'android.nfc.NfcAdapter';
10
+ const package_Ndef = 'android.nfc.tech.Ndef';
11
+ const package_NdefFormatable = 'android.nfc.tech.NdefFormatable';
12
+ const package_Parcelable = 'android.os.Parcelable';
13
+ const package_String = 'java.lang.String';
14
+
15
+ let NfcAdapter;
16
+ let NdefRecord;
17
+ let NdefMessage;
18
+ let readyWriteData = false;
19
+ let readyRead = false;
20
+ let noNFC = false;
21
+ let techListsArray = [
22
+ ['android.nfc.tech.IsoDep'],
23
+ ['android.nfc.tech.NfcA'],
24
+ ['android.nfc.tech.NfcB'],
25
+ ['android.nfc.tech.NfcF'],
26
+ ['android.nfc.tech.Nfcf'],
27
+ ['android.nfc.tech.NfcV'],
28
+ ['android.nfc.tech.NdefFormatable'],
29
+ ['android.nfc.tech.MifareClassi'],
30
+ ['android.nfc.tech.MifareUltralight']
31
+ ];
32
+ // 要写入的数据
33
+ let text = '{id:123,name:nfc,stie:cssmini.com}';
34
+ let readResult = '';
35
+
36
+ export default {
37
+ listenNFCStatus: function () {
38
+ let that = this;
39
+ try {
40
+ let main = plus.android.runtimeMainActivity();
41
+ let Intent = plus.android.importClass('android.content.Intent');
42
+ let Activity = plus.android.importClass('android.app.Activity');
43
+ let PendingIntent = plus.android.importClass('android.app.PendingIntent');
44
+ let IntentFilter = plus.android.importClass('android.content.IntentFilter');
45
+ NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
46
+ let nfcAdapter = NfcAdapter.getDefaultAdapter(main);
47
+
48
+ if (nfcAdapter == null) {
49
+ uni.showToast({
50
+ title: '设备不支持NFC!',
51
+ icon: 'none'
52
+ });
53
+ noNFC = true;
54
+ return;
55
+ }
56
+
57
+ if (!nfcAdapter.isEnabled()) {
58
+ uni.showToast({
59
+ title: '请在系统设置中先启用NFC功能!',
60
+ icon: 'none'
61
+ });
62
+ noNFC = true;
63
+ return;
64
+ } else {
65
+ noNFC = false;
66
+ }
67
+
68
+ let intent = new Intent(main, main.getClass());
69
+ intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
70
+ let pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
71
+ let ndef = new IntentFilter('android.nfc.action.TECH_DISCOVERED');
72
+ ndef.addDataType('*/*');
73
+ let intentFiltersArray = [ndef];
74
+
75
+ plus.globalEvent.addEventListener('newintent', function () {
76
+ console.log('newintent running');
77
+ // 轮询调用 NFC
78
+ setTimeout(that.nfcRuning(), 1000);
79
+ });
80
+ plus.globalEvent.addEventListener('pause', function (e) {
81
+ console.log('pause running');
82
+ if (nfcAdapter) {
83
+ //关闭前台调度系统
84
+ //恢复默认状态
85
+ nfcAdapter.disableForegroundDispatch(main);
86
+ }
87
+ });
88
+ plus.globalEvent.addEventListener('resume', function (e) {
89
+ console.log('resume running');
90
+ if (nfcAdapter) {
91
+ //开启前台调度系统
92
+ // 优于所有其他NFC
93
+ nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
94
+ }
95
+ });
96
+ nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
97
+ } catch (e) {
98
+ console.error(e);
99
+ }
100
+ },
101
+ nfcRuning: function () {
102
+ NdefRecord = plus.android.importClass('android.nfc.NdefRecord');
103
+ NdefMessage = plus.android.importClass('android.nfc.NdefMessage');
104
+ let main = plus.android.runtimeMainActivity();
105
+ let intent = main.getIntent();
106
+ let that = this;
107
+
108
+ console.log('action type:' + intent.getAction());
109
+
110
+ if (package_TECH_DISCOVERED == intent.getAction()) {
111
+ if (readyWriteData) {
112
+ that.write(intent);
113
+ readyWriteData = false;
114
+ } else if (readyRead) {
115
+ that.read(intent);
116
+ readyRead = false;
117
+ }
118
+ }
119
+ },
120
+ write(intent) {
121
+ try {
122
+ toast('请勿移开标签 正在写入...');
123
+ console.log('text=' + text);
124
+
125
+ let textBytes = plus.android.invoke(text, 'getBytes');
126
+ // image/jpeg text/plain
127
+ let textRecord = new NdefRecord(
128
+ NdefRecord.TNF_MIME_MEDIA,
129
+ plus.android.invoke('text/plain', 'getBytes'),
130
+ plus.android.invoke('', 'getBytes'),
131
+ textBytes
132
+ );
133
+ let message = new NdefMessage([textRecord]);
134
+ let Ndef = plus.android.importClass('android.nfc.tech.Ndef');
135
+ let NdefFormatable = plus.android.importClass('android.nfc.tech.NdefFormatable');
136
+ let tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
137
+ let ndef = Ndef.get(tag);
138
+ if (ndef != null) {
139
+ // 待写入的数据长度
140
+ let size = message.toByteArray().length;
141
+ ndef.connect();
142
+ if (!ndef.isWritable()) {
143
+ toast('tag不允许写入!');
144
+ return;
145
+ }
146
+ if (ndef.getMaxSize() < size) {
147
+ toast('文件大小超出容量!');
148
+ return;
149
+ }
150
+ ndef.writeNdefMessage(message);
151
+ toast('写入数据成功!');
152
+ return;
153
+ } else {
154
+ let format = NdefFormatable.get(tag);
155
+ if (format != null) {
156
+ try {
157
+ format.connect();
158
+ format.format(message);
159
+ toast('格式化tag并且写入message');
160
+ return;
161
+ } catch (e) {
162
+ toast('格式化tag失败.');
163
+ return;
164
+ }
165
+ } else {
166
+ toast('Tag不支持NDEF');
167
+ return;
168
+ }
169
+ }
170
+ } catch (e) {
171
+ toast('写入失败');
172
+ console.log('error=' + e);
173
+ }
174
+ },
175
+ read(intent) {
176
+ toast('请勿移开标签正在读取数据');
177
+ let that = this;
178
+ // NFC id
179
+ let bytesId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
180
+ let nfc_id = that.byteArrayToHexString(bytesId);
181
+ console.log('nfc_id:', nfc_id);
182
+ let Parcelable = plus.android.importClass('android.os.Parcelable');
183
+ let rawmsgs = intent.getParcelableArrayExtra('android.nfc.extra.NDEF_MESSAGES');
184
+ // let rawmsgs = intent.getParcelableArrayExtra();
185
+ console.log('nfc读取的内容', rawmsgs);
186
+ if (rawmsgs != null && rawmsgs.length > 0) {
187
+ let records = rawmsgs[0].getRecords();
188
+ let result = records[0].getPayload();
189
+ let data = plus.android.newObject('java.lang.String', result);
190
+ toast('NFC 数据:' + data);
191
+ console.log('NFC 数据:', data);
192
+ readResult = data;
193
+ } else {
194
+ toast('没有读取到数据');
195
+ }
196
+ },
197
+ byteArrayToHexString: function (inarray) {
198
+ // converts byte arrays to string
199
+ let i, j, inn;
200
+ let hex = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'];
201
+ let out = '';
202
+
203
+ for (j = 0; j < inarray.length; ++j) {
204
+ inn = inarray[j] & 0xff;
205
+ i = (inn >>> 4) & 0x0f;
206
+ out += hex[i];
207
+ i = inn & 0x0f;
208
+ out += hex[i];
209
+ }
210
+ return out;
211
+ },
212
+ writeData: function () {
213
+ if (noNFC) {
214
+ toast('请检查设备是否支持并开启 NFC 功能!');
215
+ return;
216
+ }
217
+ // 轮询条件
218
+ readyWriteData = true;
219
+ toast('请将NFC标签靠近!');
220
+ },
221
+ readData: function () {
222
+ if (noNFC) {
223
+ toast('请检查设备是否支持并开启 NFC 功能!');
224
+ return;
225
+ }
226
+ // 轮询条件
227
+ readyRead = true;
228
+ toast('请将NFC标签靠近!');
229
+ }
230
+ };
231
+ function toast(content) {
232
+ uni.showToast({
233
+ title: content,
234
+ icon: 'none'
235
+ });
236
+ }