Browse Source

NFC通信示例提交

lxh 3 months ago
parent
commit
82e70d7900
6 changed files with 549 additions and 73 deletions
  1. 240 0
      common/util/hexiii-nfc.js
  2. 59 59
      manifest.json
  3. 204 0
      npminstall-debug.log
  4. 20 5
      pages/gasreport/gasreport.vue
  5. 9 1
      pages/index/index.vue
  6. 17 8
      pages/login/login.vue

+ 240 - 0
common/util/hexiii-nfc.js

@@ -0,0 +1,240 @@
+// 包路径
+const package_NdefRecord = 'android.nfc.NdefRecord';
+const package_NdefMessage = 'android.nfc.NdefMessage';
+const package_TECH_DISCOVERED = 'android.nfc.action.TECH_DISCOVERED';
+const package_Intent = 'android.content.Intent'; 
+const package_Activity = 'android.app.Activity'; 
+const package_PendingIntent = 'android.app.PendingIntent'; 
+const package_IntentFilter = 'android.content.IntentFilter'; 
+const package_NfcAdapter = 'android.nfc.NfcAdapter'; 
+const package_Ndef = 'android.nfc.tech.Ndef'; 
+const package_NdefFormatable = 'android.nfc.tech.NdefFormatable'; 
+const package_Parcelable = 'android.os.Parcelable'; 
+const package_String = 'java.lang.String'; 
+
+let NfcAdapter;
+let NdefRecord;
+let NdefMessage;
+let readyWriteData = false;//开启写
+let readyRead = false;//开启读
+let noNFC = false;
+let techListsArray = [
+	['android.nfc.tech.IsoDep'],
+	['android.nfc.tech.NfcA'],
+	['android.nfc.tech.NfcB'],
+	['android.nfc.tech.NfcF'],
+	['android.nfc.tech.Nfcf'],
+	['android.nfc.tech.NfcV'],
+	['android.nfc.tech.NdefFormatable'],
+	['android.nfc.tech.MifareClassi'],
+	['android.nfc.tech.MifareUltralight']
+];
+// 要写入的数据
+let text = '{id:8888,name:nfc,stie:wangqin.com}';
+let readResult = '';
+
+export default {
+	listenNFCStatus: function () {
+		console.log("---------listenNFCStatus--------------")
+		let that = this;
+		try {
+			let main = plus.android.runtimeMainActivity();
+			let Intent = plus.android.importClass('android.content.Intent');
+			let Activity = plus.android.importClass('android.app.Activity');
+			let PendingIntent = plus.android.importClass('android.app.PendingIntent');
+			let IntentFilter = plus.android.importClass('android.content.IntentFilter');
+			NfcAdapter = plus.android.importClass('android.nfc.NfcAdapter');
+			let nfcAdapter = NfcAdapter.getDefaultAdapter(main);
+			
+			if(nfcAdapter == null){
+				uni.showToast({
+				  title: '设备不支持NFC!',
+				  icon: 'none'
+				})
+				noNFC = true;
+				return;
+			}
+			
+			if (!nfcAdapter.isEnabled()) {
+				uni.showToast({
+				  title: '请在系统设置中先启用NFC功能!',
+				  icon: 'none'
+				});
+				noNFC = true;
+				return;
+			}else{
+				noNFC = false;
+			}
+			
+			let intent = new Intent(main, main.getClass());
+			intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
+			let pendingIntent = PendingIntent.getActivity(main, 0, intent, 0);
+			let ndef = new IntentFilter("android.nfc.action.TECH_DISCOVERED");
+			ndef.addDataType("*/*");
+			let intentFiltersArray = [ndef];
+			
+			plus.globalEvent.addEventListener('newintent',function() {
+				console.log('newintent running');
+				// 轮询调用 NFC
+				setTimeout(that.nfcRuning(), 3000);
+			});
+			plus.globalEvent.addEventListener('pause',function(e) {
+				console.log('pause running');
+				if (nfcAdapter) {
+					//关闭前台调度系统
+					//恢复默认状态
+					nfcAdapter.disableForegroundDispatch(main);
+				}
+			});
+			plus.globalEvent.addEventListener('resume',function(e) {
+				console.log('resume running');
+				if (nfcAdapter) {
+					 //开启前台调度系统
+					// 优于所有其他NFC
+					nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray);
+				}
+			});
+			nfcAdapter.enableForegroundDispatch(main, pendingIntent, intentFiltersArray, techListsArray); 
+		} catch (e) {
+			console.error(e);
+		}
+	},
+	nfcRuning: function () {
+		console.log("--------------nfcRuning---------------")
+		NdefRecord = plus.android.importClass("android.nfc.NdefRecord");
+		NdefMessage = plus.android.importClass("android.nfc.NdefMessage");
+		let main = plus.android.runtimeMainActivity();
+		let intent = main.getIntent();
+		let that = this;
+		
+		console.log("action type:" + intent.getAction());
+		console.log(package_TECH_DISCOVERED == intent.getAction());
+		if (package_TECH_DISCOVERED == intent.getAction()) {
+			if (readyWriteData) {
+				console.log("----------我在写1-------------")
+				that.write(intent);
+				readyWriteData = false;
+			} else if (readyRead) {
+				console.log("----------我在读1-------------")
+				that.read(intent);
+				readyRead = false;
+			}
+		}
+	},
+	write(intent) {
+		console.log("----------我在写-------------")
+		try {
+			toast('请勿移开标签 正在写入...');
+			console.log("text=" + text);
+			
+			let textBytes = plus.android.invoke(text, "getBytes");
+			// image/jpeg text/plain  
+			let textRecord = new NdefRecord(NdefRecord.TNF_MIME_MEDIA,
+											plus.android.invoke("text/plain", "getBytes"),  
+											plus.android.invoke("", "getBytes"), textBytes);
+			let message = new NdefMessage([textRecord]);
+			let Ndef = plus.android.importClass('android.nfc.tech.Ndef');
+			let NdefFormatable = plus.android.importClass('android.nfc.tech.NdefFormatable');
+			let tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
+			let ndef = Ndef.get(tag);
+			if (ndef != null) {
+				// 待写入的数据长度
+				let size = message.toByteArray().length;
+				ndef.connect();
+				if (!ndef.isWritable()) {
+					toast('tag不允许写入!');
+					return;
+				}
+				if (ndef.getMaxSize() < size) {
+					toast('文件大小超出容量!');
+					return;
+				}
+				ndef.writeNdefMessage(message);
+				toast('写入数据成功!');
+				return;
+			} else {
+				let format = NdefFormatable.get(tag);
+				if (format != null) {
+					try {
+						format.connect();
+						format.format(message);
+						toast('格式化tag并且写入message');
+						return;
+					} catch (e) {
+						toast('格式化tag失败.');
+						return;
+					}
+				} else {
+					toast('Tag不支持NDEF');
+					return;
+				}
+			}
+		} catch (e) {
+			toast('写入失败');
+			console.log("error=" + e);
+		}
+	
+	},
+	read(intent) {
+		console.log("----------我在读read-------------")
+		toast('请勿移开标签正在读取数据');
+		let that = this;
+		// NFC id
+		let bytesId = intent.getByteArrayExtra(NfcAdapter.EXTRA_ID);
+		let nfc_id = that.byteArrayToHexString(bytesId);
+		console.log('nfc_id:', nfc_id);
+		let Parcelable = plus.android.importClass("android.os.Parcelable");
+		let rawmsgs = intent.getParcelableArrayExtra("android.nfc.extra.NDEF_MESSAGES");
+		//let rawmsgs = intent.getParcelableArrayExtra();
+		
+		console.log("数据"+rawmsgs)
+		if(rawmsgs != null && rawmsgs.length > 0) {
+			let records = rawmsgs[0].getRecords();
+			let result = records[0].getPayload();
+			let data = plus.android.newObject("java.lang.String", result);
+			toast('NFC 数据:' + data);
+			console.log('NFC 数据:',data);
+			readResult = data;
+		}else{
+			toast('没有读取到数据');
+		}
+	},
+	byteArrayToHexString: function (inarray) { // converts byte arrays to string  
+		let i, j, inn;  
+		let hex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];  
+		let out = "";  
+		
+		for(j = 0; j < inarray.length; ++j) {
+			inn = inarray[j] & 0xff;  
+			i = (inn >>> 4) & 0x0f;  
+			out += hex[i];  
+			i = inn & 0x0f;  
+			out += hex[i];  
+		}  
+		return out;  
+	},
+	writeData: function () {
+		if(noNFC){
+			toast('请检查设备是否支持并开启 NFC 功能!');
+			return;
+		}
+		// 轮询条件
+		readyWriteData = true;
+		toast('请将NFC标签靠近!');
+	},
+	readData: function () {
+		if(noNFC){
+			toast('请检查设备是否支持并开启 NFC 功能!');
+			return;
+		}
+		// 轮询条件
+		readyRead = true;
+		toast('请将NFC标签靠近!');
+	}
+}
+function toast(content){
+	uni.showToast({
+		title: content,
+		icon: 'none'
+	})
+}

+ 59 - 59
manifest.json

@@ -1,17 +1,17 @@
 {
-    "name" : "智能通风",
-    "appid" : "__UNI__8193760",
-    "description" : "",
-    "versionName" : "2.2.22",
-    "versionCode" : 1,
-    "transformPx" : false,
-    "app-plus" : {
-        "compatible" : {
-            "ignoreVersion" : false,
-            "runtimeVersion" : "4.23,4.29",
-            "compilerVersion" : "4.29"
+    "name": "智能通风",
+    "appid": "__UNI__8193760",
+    "description": "",
+    "versionName": "2.2.22",
+    "versionCode": 1,
+    "transformPx": false,
+    "app-plus": {
+        "compatible": {
+            "ignoreVersion": false,
+            "runtimeVersion": "4.23,4.29",
+            "compilerVersion": "4.29"
         },
-        "orientation" : [
+        "orientation": [
             //竖屏正方向
             "portrait-primary",
             //竖屏反方向
@@ -24,16 +24,16 @@
             "default"
         ],
         /* 5+App特有相关 */
-        "modules" : {
-            "Push" : {},
-            "VideoPlayer" : {}
+        "modules": {
+            "Push": {},
+            "VideoPlayer": {}
         },
         /* 模块配置 */
-        "distribute" : {
+        "distribute": {
             /* 应用发布信息 */
-            "android" : {
+            "android": {
                 /* android打包配置 */
-                "permissions" : [
+                "permissions": [
                     "<uses-feature android:name=\"android.hardware.camera\"/>",
                     "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
                     "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
@@ -58,65 +58,65 @@
                     "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
                 ]
             },
-            "ios" : {
-                "dSYMs" : false
+            "ios": {
+                "dSYMs": false
             },
             /* ios打包配置 */
-            "sdkConfigs" : {
-                "ad" : {},
-                "maps" : {
-                    "amap" : {
-                        "name" : "",
-                        "appkey_ios" : "87f4d2a4a0c42e0c86cf312c8b8154e8",
-                        "appkey_android" : "87f4d2a4a0c42e0c86cf312c8b8154e8"
+            "sdkConfigs": {
+                "ad": {},
+                "maps": {
+                    "amap": {
+                        "name": "",
+                        "appkey_ios": "87f4d2a4a0c42e0c86cf312c8b8154e8",
+                        "appkey_android": "87f4d2a4a0c42e0c86cf312c8b8154e8"
                     }
                 },
-                "push" : {}
+                "push": {}
             },
-            "splashscreen" : {
-                "iosStyle" : "default"
+            "splashscreen": {
+                "iosStyle": "default"
             },
-            "icons" : {
-                "android" : {
-                    "hdpi" : "static/desk-img/72 – 1.png",
-                    "xhdpi" : "static/desk-img/96.png",
-                    "xxhdpi" : "static/desk-img/144.png",
-                    "xxxhdpi" : "static/desk-img/192.png"
+            "icons": {
+                "android": {
+                    "hdpi": "static/desk-img/72 – 1.png",
+                    "xhdpi": "static/desk-img/96.png",
+                    "xxhdpi": "static/desk-img/144.png",
+                    "xxxhdpi": "static/desk-img/192.png"
                 }
             }
         }
     },
     /* SDK配置 */
-    "quickapp" : {},
+    "quickapp": {},
     /* 快应用特有相关 */
-    "mp-weixin" : {
-        "appid" : "wx2ba5c5690b35d173",
-        "setting" : {
-            "urlCheck" : false,
-            "es6" : true
+    "mp-weixin": {
+        "appid": "wx2ba5c5690b35d173",
+        "setting": {
+            "urlCheck": false,
+            "es6": true
         },
-        "permission" : {
-            "scope.userLocation" : {
-                "desc" : "有定位功能需要导航定位"
+        "permission": {
+            "scope.userLocation": {
+                "desc": "有定位功能需要导航定位"
             }
         }
     },
-    "h5" : {
-        "title" : "智能通风",
-        "domain" : "myhjdc.cn",
-        "router" : {
-            "mode" : "history"
+    "h5": {
+        "title": "智能通风",
+        "domain": "myhjdc.cn",
+        "router": {
+            "mode": "history"
         }
     },
-    "android" : {
-        "theme" : {
-            "primaryColor" : "#000000",
-            "window" : {
-                "fullscreen" : true,
-                "navigationBarColor" : "#000000"
+    "android": {
+        "theme": {
+            "primaryColor": "#000000",
+            "window": {
+                "fullscreen": true,
+                "navigationBarColor": "#000000"
             }
         },
-        "notch" : true
+        "notch": true
     },
-    "fallbackLocale" : "zh-Hans"
-}
+    "fallbackLocale": "zh-Hans"
+}

+ 204 - 0
npminstall-debug.log

@@ -0,0 +1,204 @@
+{
+  root: 'D:\\project\\app\\Vent-App',
+  registry: 'https://registry.npmmirror.com',
+  pkgs: [
+    {
+      name: 'uni-nfc',
+      version: 'latest',
+      type: 'tag',
+      alias: undefined,
+      arg: [Result]
+    }
+  ],
+  production: false,
+  cacheStrict: false,
+  cacheDir: 'C:\\Users\\86175\\.npminstall_tarball',
+  env: {
+    npm_config_registry: 'https://registry.npmmirror.com',
+    npm_config_argv: '{"remain":[],"cooked":["--fix-bug-versions","--china","--userconfig=C:\\\\Users\\\\86175\\\\.cnpmrc","--disturl=https://cdn.npmmirror.com/binaries/node","--registry=https://registry.npmmirror.com","uni-nfc"],"original":["--fix-bug-versions","--china","--userconfig=C:\\\\Users\\\\86175\\\\.cnpmrc","--disturl=https://cdn.npmmirror.com/binaries/node","--registry=https://registry.npmmirror.com","uni-nfc"]}',
+    npm_config_user_agent: 'npminstall/7.8.0 npm/? node/v18.14.0 win32 x64',
+    npm_config_cache: 'C:\\Users\\86175\\.npminstall_tarball',
+    NODE: 'C:\\Program Files\\nodejs\\node.exe',
+    npm_node_execpath: 'C:\\Program Files\\nodejs\\node.exe',
+    npm_execpath: 'C:\\Users\\86175\\AppData\\Roaming\\npm\\node_modules\\cnpm\\node_modules\\npminstall\\bin\\install.js',
+    npm_config_userconfig: 'C:\\Users\\86175\\.cnpmrc',
+    npm_config_disturl: 'https://cdn.npmmirror.com/binaries/node',
+    npm_config_r: 'https://registry.npmmirror.com',
+    COREPACK_NPM_REGISTRY: 'https://registry.npmmirror.com',
+    EDGEDRIVER_CDNURL: 'https://npmmirror.com/mirrors/edgedriver',
+    NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
+    NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
+    PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs',
+    CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver',
+    OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver',
+    CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip',
+    ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/',
+    ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/',
+    SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass',
+    SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc',
+    NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v',
+    PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/chrome-for-testing',
+    PUPPETEER_DOWNLOAD_BASE_URL: 'https://cdn.npmmirror.com/binaries/chrome-for-testing',
+    PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright',
+    SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli',
+    SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl',
+    RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2',
+    RE2_DOWNLOAD_SKIP_PATH: 'true',
+    PRISMA_ENGINES_MIRROR: 'https://cdn.npmmirror.com/binaries/prisma',
+    npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3',
+    npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar',
+    npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp',
+    npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips',
+    npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs',
+    npm_rootpath: 'D:\\project\\app\\Vent-App',
+    INIT_CWD: 'D:\\project\\app\\Vent-App'
+  },
+  binaryMirrors: {
+    ENVS: {
+      COREPACK_NPM_REGISTRY: 'https://registry.npmmirror.com',
+      EDGEDRIVER_CDNURL: 'https://npmmirror.com/mirrors/edgedriver',
+      NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
+      NVM_NODEJS_ORG_MIRROR: 'https://cdn.npmmirror.com/binaries/node',
+      PHANTOMJS_CDNURL: 'https://cdn.npmmirror.com/binaries/phantomjs',
+      CHROMEDRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/chromedriver',
+      OPERADRIVER_CDNURL: 'https://cdn.npmmirror.com/binaries/operadriver',
+      CYPRESS_DOWNLOAD_PATH_TEMPLATE: 'https://cdn.npmmirror.com/binaries/cypress/${version}/${platform}-${arch}/cypress.zip',
+      ELECTRON_MIRROR: 'https://cdn.npmmirror.com/binaries/electron/',
+      ELECTRON_BUILDER_BINARIES_MIRROR: 'https://cdn.npmmirror.com/binaries/electron-builder-binaries/',
+      SASS_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-sass',
+      SWC_BINARY_SITE: 'https://cdn.npmmirror.com/binaries/node-swc',
+      NWJS_URLBASE: 'https://cdn.npmmirror.com/binaries/nwjs/v',
+      PUPPETEER_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/chrome-for-testing',
+      PUPPETEER_DOWNLOAD_BASE_URL: 'https://cdn.npmmirror.com/binaries/chrome-for-testing',
+      PLAYWRIGHT_DOWNLOAD_HOST: 'https://cdn.npmmirror.com/binaries/playwright',
+      SENTRYCLI_CDNURL: 'https://cdn.npmmirror.com/binaries/sentry-cli',
+      SAUCECTL_INSTALL_BINARY_MIRROR: 'https://cdn.npmmirror.com/binaries/saucectl',
+      RE2_DOWNLOAD_MIRROR: 'https://cdn.npmmirror.com/binaries/node-re2',
+      RE2_DOWNLOAD_SKIP_PATH: 'true',
+      PRISMA_ENGINES_MIRROR: 'https://cdn.npmmirror.com/binaries/prisma',
+      npm_config_better_sqlite3_binary_host: 'https://cdn.npmmirror.com/binaries/better-sqlite3',
+      npm_config_keytar_binary_host: 'https://cdn.npmmirror.com/binaries/keytar',
+      npm_config_sharp_binary_host: 'https://cdn.npmmirror.com/binaries/sharp',
+      npm_config_sharp_libvips_binary_host: 'https://cdn.npmmirror.com/binaries/sharp-libvips',
+      npm_config_robotjs_binary_host: 'https://cdn.npmmirror.com/binaries/robotjs'
+    },
+    '@ali/s2': { host: 'https://cdn.npmmirror.com/binaries/looksgood-s2' },
+    sharp: { replaceHostFiles: [Array], replaceHostMap: [Object] },
+    '@tensorflow/tfjs-node': {
+      replaceHostFiles: [Array],
+      replaceHostRegExpMap: [Object],
+      replaceHostMap: [Object]
+    },
+    cypress: {
+      host: 'https://cdn.npmmirror.com/binaries/cypress',
+      newPlatforms: [Object]
+    },
+    'utf-8-validate': {
+      host: 'https://cdn.npmmirror.com/binaries/utf-8-validate/v{version}'
+    },
+    xprofiler: {
+      remote_path: './xprofiler/v{version}/',
+      host: 'https://cdn.npmmirror.com/binaries'
+    },
+    leveldown: { host: 'https://cdn.npmmirror.com/binaries/leveldown/v{version}' },
+    couchbase: { host: 'https://cdn.npmmirror.com/binaries/couchbase/v{version}' },
+    gl: { host: 'https://cdn.npmmirror.com/binaries/gl/v{version}' },
+    sqlite3: {
+      host: 'https://cdn.npmmirror.com/binaries/sqlite3',
+      remote_path: 'v{version}'
+    },
+    '@journeyapps/sqlcipher': { host: 'https://cdn.npmmirror.com/binaries' },
+    grpc: {
+      host: 'https://cdn.npmmirror.com/binaries',
+      remote_path: '{name}/v{version}'
+    },
+    'grpc-tools': { host: 'https://cdn.npmmirror.com/binaries' },
+    wrtc: {
+      host: 'https://cdn.npmmirror.com/binaries',
+      remote_path: '{name}/v{version}'
+    },
+    fsevents: { host: 'https://cdn.npmmirror.com/binaries/fsevents' },
+    nodejieba: { host: 'https://cdn.npmmirror.com/binaries/nodejieba' },
+    canvas: { host: 'https://cdn.npmmirror.com/binaries/canvas' },
+    'skia-canvas': { host: 'https://cdn.npmmirror.com/binaries/skia-canvas' },
+    'flow-bin': {
+      replaceHost: 'https://github.com/facebook/flow/releases/download/v',
+      host: 'https://cdn.npmmirror.com/binaries/flow/v'
+    },
+    'jpegtran-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/jpegtran-bin'
+    },
+    'cwebp-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/cwebp-bin'
+    },
+    'zopflipng-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/zopflipng-bin'
+    },
+    'optipng-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/optipng-bin'
+    },
+    mozjpeg: {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/mozjpeg-bin'
+    },
+    gifsicle: {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/gifsicle-bin'
+    },
+    'pngquant-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/pngquant-bin',
+      replaceHostMap: [Object]
+    },
+    'pngcrush-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/pngcrush-bin'
+    },
+    'jpeg-recompress-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/jpeg-recompress-bin'
+    },
+    'advpng-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/advpng-bin'
+    },
+    'pngout-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/pngout-bin'
+    },
+    'jpegoptim-bin': {
+      replaceHost: [Array],
+      host: 'https://cdn.npmmirror.com/binaries/jpegoptim-bin'
+    },
+    argon2: { host: 'https://cdn.npmmirror.com/binaries/argon2' },
+    'ali-zeromq': { host: 'https://cdn.npmmirror.com/binaries/ali-zeromq' },
+    'ali-usb_ctl': { host: 'https://cdn.npmmirror.com/binaries/ali-usb_ctl' },
+    'gdal-async': { host: 'https://cdn.npmmirror.com/binaries/node-gdal-async' },
+    'libpg-query': { host: 'https://cdn.npmmirror.com/binaries' }
+  },
+  forbiddenLicenses: null,
+  flatten: false,
+  proxy: undefined,
+  prune: false,
+  disableFallbackStore: false,
+  workspacesMap: Map(0) {},
+  enableWorkspace: false,
+  workspaceRoot: 'D:\\project\\app\\Vent-App',
+  isWorkspaceRoot: true,
+  isWorkspacePackage: false,
+  offline: false,
+  strictSSL: true,
+  ignoreScripts: false,
+  ignoreOptionalDependencies: false,
+  detail: false,
+  forceLinkLatest: false,
+  trace: false,
+  engineStrict: false,
+  registryOnly: false,
+  client: false,
+  autoFixVersion: [Function: autoFixVersion]
+}

+ 20 - 5
pages/gasreport/gasreport.vue

@@ -13,7 +13,10 @@
                             @confirm="confirmTb" @cancel="showCalendarTb = false" @change="changeTb"
                             @close="showCalendarTb = false"></u-datetime-picker>
                     </view>
-                    <u-button v-if="hasPermission('gasReport:add')" type="primary" size="small" style="margin: 2px 0px;"  @click="getAdd">新增</u-button>
+                    <u-button v-if="hasPermission('gasReport:add')" type="primary" size="small" style="margin: 2px 0px;"
+                        @click="getAdd">新增</u-button>
+                    <u-button type="primary" size="small" style="margin: 2px 0px;" @click="getWrites">写入</u-button>
+                    <u-button type="primary" size="small" style="margin: 2px 0px;" @click="getReads">读取</u-button>
                 </view>
                 <view class="bot-gas-list">
                     <view class="top-title">
@@ -184,7 +187,7 @@
 <script>
 import api from "@/api/api";
 import moment from 'moment'
-import { mapGetters } from "vuex";
+import testNfc from "@/common/util/hexiii-nfc.js"
 export default {
     name: 'gasreport',
     props: {},
@@ -250,9 +253,9 @@ export default {
         this.getMcList()
     },
     methods: {
-        hasPermission(param){
-            let permission= uni.getStorageSync('btnPermission')
-            return permission.filter(v=>v.action==param).length!=0 ? true : false
+        hasPermission(param) {
+            let permission = uni.getStorageSync('btnPermission')
+            return permission.filter(v => v.action == param).length != 0 ? true : false
         },
         //班次下拉选项切换
         changeBc(e) {
@@ -2194,6 +2197,18 @@ export default {
                     });
             });
         },
+        //nfc写入数据
+        getWrites() {
+            testNfc.listenNFCStatus()
+            testNfc.writeData()
+        },
+        //nfc读取数据
+        getReads(){
+            testNfc.listenNFCStatus()
+            testNfc.readData()
+            let abc=testNfc.listenNFCStatus()
+            console.log(abc,'abc------------------')
+        }
     },
 
 };

+ 9 - 1
pages/index/index.vue

@@ -61,7 +61,7 @@ export default {
   data() {
     return {
       isLandScape: "",
-      PageCur: "device",
+      PageCur: "",
       tun3DPage: null,
       wvHeight: getApp().globalData.windowHeight,
       wvWidth: getApp().globalData.windowWidth,
@@ -74,6 +74,14 @@ export default {
       return uni.getStorageSync('menuPermission')
     }
   },
+  watch: {
+    permission: {
+      handler(newV, oldV) {
+        this.PageCur=newV[0].component
+      },
+      immediate: true,
+    }
+  },
   onLoad() {
     this.changeWV();
   },

+ 17 - 8
pages/login/login.vue

@@ -26,7 +26,7 @@
             <view class="padding text-center margin-top">
               <button class="cu-btn bg-blue lg margin-right shadow" :loading="loading"
                 :class="[shape == 'round' ? 'round' : '']" @tap="onLogin"><text space="emsp">{{ loading ? "登录中..." :
-                  "登录"}}</text>
+                  "登录" }}</text>
               </button>
             </view>
           </block>
@@ -103,6 +103,13 @@ export default {
   },
   methods: {
     ...mapActions(["mLogin", "PhoneLogin", "ThirdLogin"]),
+
+
+    // 判断是否在APP环境中
+    isApp() {
+      return typeof plus !== 'undefined';
+    },
+
     onLogin: function () {
       if (!this.userName || this.userName.length == 0) {
         this.$tip.toast("请填写用户名");
@@ -121,12 +128,16 @@ export default {
         .then((res) => {
           this.loading = false;
           if (res.data.success) {
+            if (this.isApp()) {
+              // console.log('当前是APP环境');
+              this.saveClientId();
+            } else {
+              this.getPermissionList()
+            }
             // #ifdef APP-PLUS
-            this.saveClientId();
+            
             // #endif
             // #ifndef APP-PLUS
-            //获取权限菜单
-            this.getPermissionList()
             // #endif
           } else {
             this.$tip.alert(res.data.message);
@@ -174,10 +185,8 @@ export default {
         .get("/sys/user/saveClientId", { params: { clientId: cid } })
         .then((res) => {
           console.log("res::saveClientId>", res);
-          this.$tip.success("登录成功!");
-          uni.navigateTo({
-            url: "/pages/index/index",
-          });
+          //获取权限菜单
+          this.getPermissionList()
         });
     },
     changePassword() {