Drew 7 лет назад
Родитель
Сommit
968eec05a4
60 измененных файлов с 945 добавлено и 16 удалено
  1. 1 0
      config.xml
  2. 3 0
      package-lock.json
  3. 3 1
      package.json
  4. 3 0
      platforms/android/AndroidManifest.xml
  5. 39 9
      platforms/android/android.json
  6. 10 1
      platforms/android/assets/www/cordova_plugins.js
  7. 1 1
      platforms/android/assets/www/index.html
  8. 21 0
      platforms/android/assets/www/plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js
  9. 0 0
      platforms/android/assets/www/static/js/manifest.19f4740cc77c168ee709.js.map
  10. 3 0
      platforms/android/build.gradle
  11. 10 1
      platforms/android/platform_www/cordova_plugins.js
  12. 21 0
      platforms/android/platform_www/plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js
  13. 4 1
      platforms/android/project.properties
  14. BIN
      platforms/android/res/drawable-xhdpi/ic_shortcut_flash_off.png
  15. BIN
      platforms/android/res/drawable-xhdpi/ic_shortcut_flash_on.png
  16. BIN
      platforms/android/res/drawable-xhdpi/prev.png
  17. BIN
      platforms/android/res/drawable-xxhdpi/ic_shortcut_flash_off.png
  18. BIN
      platforms/android/res/drawable-xxhdpi/ic_shortcut_flash_on.png
  19. BIN
      platforms/android/res/drawable-xxhdpi/prev.png
  20. BIN
      platforms/android/res/drawable-xxxhdpi/ic_shortcut_flash_off.png
  21. BIN
      platforms/android/res/drawable-xxxhdpi/ic_shortcut_flash_on.png
  22. 5 0
      platforms/android/res/drawable/ic_flash.xml
  23. 61 0
      platforms/android/res/layout/activity_scan.xml
  24. 3 0
      platforms/android/res/xml/config.xml
  25. 67 0
      platforms/android/src/cn/x1ongzhu/qrCodeScanner/ScanActivity.java
  26. 44 0
      platforms/android/src/cn/x1ongzhu/qrCodeScanner/qrCodeScanner.java
  27. 3 0
      plugins/android.json
  28. 21 0
      plugins/cordova-plugin-qrcode-scanner/package.json
  29. 52 0
      plugins/cordova-plugin-qrcode-scanner/plugin.xml
  30. 67 0
      plugins/cordova-plugin-qrcode-scanner/src/android/ScanActivity.java
  31. 44 0
      plugins/cordova-plugin-qrcode-scanner/src/android/qrCodeScanner.java
  32. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/ic_shortcut_flash_off.png
  33. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/ic_shortcut_flash_on.png
  34. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/prev.png
  35. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/ic_shortcut_flash_off.png
  36. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/ic_shortcut_flash_on.png
  37. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/prev.png
  38. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxxhdpi/ic_shortcut_flash_off.png
  39. BIN
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxxhdpi/ic_shortcut_flash_on.png
  40. 5 0
      plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable/ic_flash.xml
  41. 61 0
      plugins/cordova-plugin-qrcode-scanner/src/android/res/layout/activity_scan.xml
  42. 20 0
      plugins/cordova-plugin-qrcode-scanner/src/ios/ScanViewController.h
  43. 298 0
      plugins/cordova-plugin-qrcode-scanner/src/ios/ScanViewController.m
  44. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_off@2x.png
  45. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_off@3x.png
  46. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_on@2x.png
  47. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_on@3x.png
  48. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/line.png
  49. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/line@2x.png
  50. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/pick_bg.png
  51. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/pick_bg@2x.png
  52. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev.png
  53. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev@2x.png
  54. BIN
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev@3x.png
  55. 46 0
      plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.m
  56. 18 0
      plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js
  57. 8 0
      plugins/fetch.json
  58. 2 1
      vue/index.html
  59. 1 1
      www/index.html
  60. 0 0
      www/static/js/manifest.19f4740cc77c168ee709.js.map

+ 1 - 0
config.xml

@@ -59,5 +59,6 @@
         <variable name="XWALK_MODE" value="embedded" />
         <variable name="XWALK_MULTIPLEAPK" value="true" />
     </plugin>
+    <plugin name="cordova-plugin-qrcode-scanner" spec="../qrCodeScanner" />
     <engine name="android" spec="^6.3.0" />
 </widget>

+ 3 - 0
package-lock.json

@@ -241,6 +241,9 @@
             "resolved": "http://registry.npm.taobao.org/cordova-plugin-inappbrowser/download/cordova-plugin-inappbrowser-3.0.0.tgz",
             "integrity": "sha1-1K4A02Z2IQdRBXrSWK5K1KkWGto="
         },
+        "cordova-plugin-qrcode-scanner": {
+            "version": "file:../qrCodeScanner"
+        },
         "cordova-plugin-remote-injection": {
             "version": "0.5.2",
             "resolved": "http://registry.npm.taobao.org/cordova-plugin-remote-injection/download/cordova-plugin-remote-injection-0.5.2.tgz",

+ 3 - 1
package.json

@@ -15,6 +15,7 @@
         "cordova-plugin-crosswalk-webview": "git+https://github.com/x1ongzhu/cordova-plugin-crosswalk-webview.git",
         "cordova-plugin-device": "^2.0.2",
         "cordova-plugin-inappbrowser": "^3.0.0",
+        "cordova-plugin-qrcode-scanner": "file:../qrCodeScanner",
         "cordova-plugin-remote-injection": "^0.5.2",
         "cordova-plugin-whitelist": "^1.3.3",
         "cordova-plugin-wkwebview-engine": "^1.1.4",
@@ -35,7 +36,8 @@
                 "XWALK_COMMANDLINE": "--disable-pull-to-refresh-effect",
                 "XWALK_MODE": "embedded",
                 "XWALK_MULTIPLEAPK": "true"
-            }
+            },
+            "cordova-plugin-qrcode-scanner": {}
         },
         "platforms": [
             "android"

+ 3 - 0
platforms/android/AndroidManifest.xml

@@ -12,6 +12,7 @@
         <provider android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true" android:name="org.apache.cordova.camera.FileProvider">
             <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/camera_provider_paths" />
         </provider>
+        <activity android:name="cn.x1ongzhu.qrCodeScanner.ScanActivity" />
     </application>
     <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="26" />
     <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
@@ -22,4 +23,6 @@
     <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
     <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
     <uses-permission android:name="android.permission.READ_PHONE_STATE" />
+    <uses-permission android:name="android.permission.CAMERA" />
+    <uses-permission android:name="android.permission.FLASHLIGHT" />
 </manifest>

+ 39 - 9
platforms/android/android.json

@@ -55,6 +55,10 @@
             {
               "xml": "<preference name=\"android-minSdkVersion\" value=\"16\" />",
               "count": 1
+            },
+            {
+              "xml": "<feature name=\"qrCodeScanner\"><param name=\"android-package\" value=\"cn.x1ongzhu.qrCodeScanner.qrCodeScanner\" /></feature>",
+              "count": 1
             }
           ]
         }
@@ -68,35 +72,43 @@
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />",
-              "count": 8
+              "count": 16
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />",
-              "count": 8
+              "count": 16
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.INTERNET\" />",
-              "count": 14
+              "count": 30
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" />",
-              "count": 7
+              "count": 15
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\" />",
-              "count": 7
+              "count": 15
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\" />",
-              "count": 7
+              "count": 15
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\" />",
-              "count": 7
+              "count": 15
             },
             {
               "xml": "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />",
-              "count": 7
+              "count": 15
+            },
+            {
+              "xml": "<uses-permission android:name=\"android.permission.CAMERA\" />",
+              "count": 1
+            },
+            {
+              "xml": "<uses-permission android:name=\"android.permission.FLASHLIGHT\" />",
+              "count": 1
             }
           ],
           "application": [
@@ -104,6 +116,12 @@
               "xml": "<provider android:authorities=\"${applicationId}.provider\" android:exported=\"false\" android:grantUriPermissions=\"true\" android:name=\"org.apache.cordova.camera.FileProvider\"><meta-data android:name=\"android.support.FILE_PROVIDER_PATHS\" android:resource=\"@xml/camera_provider_paths\" /></provider>",
               "count": 1
             }
+          ],
+          "/manifest/application": [
+            {
+              "xml": "<activity android:name=\"cn.x1ongzhu.qrCodeScanner.ScanActivity\" />",
+              "count": 1
+            }
           ]
         }
       },
@@ -148,6 +166,9 @@
       "XWALK_MODE": "embedded",
       "XWALK_MULTIPLEAPK": "true",
       "PACKAGE_NAME": "com.izouma.pumpApp"
+    },
+    "cordova-plugin-qrcode-scanner": {
+      "PACKAGE_NAME": "com.izouma.pumpApp"
     }
   },
   "dependent_plugins": {},
@@ -208,6 +229,14 @@
       "clobbers": [
         "window.plugins.toast"
       ]
+    },
+    {
+      "id": "cordova-plugin-qrcode-scanner.qrCodeScanner",
+      "file": "plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js",
+      "pluginId": "cordova-plugin-qrcode-scanner",
+      "clobbers": [
+        "qrCodeScanner"
+      ]
     }
   ],
   "plugin_metadata": {
@@ -218,6 +247,7 @@
     "cordova-plugin-x-toast": "2.6.2",
     "cordova-plugin-wkwebview-engine": "1.1.4",
     "cordova-plugin-remote-injection": "0.5.2",
-    "cordova-plugin-crosswalk-webview": "2.4.0"
+    "cordova-plugin-crosswalk-webview": "2.4.0",
+    "cordova-plugin-qrcode-scanner": "1.0.0"
   }
 }

+ 10 - 1
platforms/android/assets/www/cordova_plugins.js

@@ -56,6 +56,14 @@ module.exports = [
     "clobbers": [
       "window.plugins.toast"
     ]
+  },
+  {
+    "id": "cordova-plugin-qrcode-scanner.qrCodeScanner",
+    "file": "plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js",
+    "pluginId": "cordova-plugin-qrcode-scanner",
+    "clobbers": [
+      "qrCodeScanner"
+    ]
   }
 ];
 module.exports.metadata = 
@@ -68,7 +76,8 @@ module.exports.metadata =
   "cordova-plugin-x-toast": "2.6.2",
   "cordova-plugin-wkwebview-engine": "1.1.4",
   "cordova-plugin-remote-injection": "0.5.2",
-  "cordova-plugin-crosswalk-webview": "2.4.0"
+  "cordova-plugin-crosswalk-webview": "2.4.0",
+  "cordova-plugin-qrcode-scanner": "1.0.0"
 };
 // BOTTOM OF METADATA
 });

+ 1 - 1
platforms/android/assets/www/index.html

@@ -1,3 +1,3 @@
-<!DOCTYPE html><html><head><meta charset=utf-8><title>水泵</title><meta name=viewport content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><link href=./static/css/app.bdbbf849a8c5db37ad3631afef2ca6c2.css rel=stylesheet></head><style>a {
+<!DOCTYPE html><html><head><meta charset=utf-8><title>水泵</title><meta name=viewport content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><script src=cordova.js></script><link href=./static/css/app.bdbbf849a8c5db37ad3631afef2ca6c2.css rel=stylesheet></head><style>a {
         text-decoration: none;
     }</style><body><div id=app></div><script type=text/javascript src=./static/js/manifest.19f4740cc77c168ee709.js></script><script type=text/javascript src=./static/js/vendor.83bc9862f9225e9f11f1.js></script><script type=text/javascript src=./static/js/app.4ab066ba21cd7bc5d906.js></script></body></html>

+ 21 - 0
platforms/android/assets/www/plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js

@@ -0,0 +1,21 @@
+cordova.define("cordova-plugin-qrcode-scanner.qrCodeScanner", function(require, exports, module) {
+var exec = require("cordova/exec");
+
+exports.start = function(success, options) {
+    exec(
+        function(message) {
+            if (typeof success === "function") {
+                success(message);
+            }
+            console.log(message);
+        },
+        function(message) {
+            console.log(message);
+        },
+        "qrCodeScanner",
+        "start",
+        [options]
+    );
+};
+
+});

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
platforms/android/assets/www/static/js/manifest.19f4740cc77c168ee709.js.map


+ 3 - 0
platforms/android/build.gradle

@@ -255,6 +255,9 @@ dependencies {
     debugCompile(project(path: "CordovaLib", configuration: "debug"))
     releaseCompile(project(path: "CordovaLib", configuration: "release"))
     compile "com.android.support:support-v4:24.1.1+"
+    compile "com.google.zxing:core:3.3.0"
+    compile "cn.bingoogolapple:bga-qrcodecore:1.1.9@aar"
+    compile "cn.bingoogolapple:bga-zxing:1.1.9@aar"
     // SUB-PROJECT DEPENDENCIES END
 }
 

+ 10 - 1
platforms/android/platform_www/cordova_plugins.js

@@ -56,6 +56,14 @@ module.exports = [
     "clobbers": [
       "window.plugins.toast"
     ]
+  },
+  {
+    "id": "cordova-plugin-qrcode-scanner.qrCodeScanner",
+    "file": "plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js",
+    "pluginId": "cordova-plugin-qrcode-scanner",
+    "clobbers": [
+      "qrCodeScanner"
+    ]
   }
 ];
 module.exports.metadata = 
@@ -68,7 +76,8 @@ module.exports.metadata =
   "cordova-plugin-x-toast": "2.6.2",
   "cordova-plugin-wkwebview-engine": "1.1.4",
   "cordova-plugin-remote-injection": "0.5.2",
-  "cordova-plugin-crosswalk-webview": "2.4.0"
+  "cordova-plugin-crosswalk-webview": "2.4.0",
+  "cordova-plugin-qrcode-scanner": "1.0.0"
 };
 // BOTTOM OF METADATA
 });

+ 21 - 0
platforms/android/platform_www/plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js

@@ -0,0 +1,21 @@
+cordova.define("cordova-plugin-qrcode-scanner.qrCodeScanner", function(require, exports, module) {
+var exec = require("cordova/exec");
+
+exports.start = function(success, options) {
+    exec(
+        function(message) {
+            if (typeof success === "function") {
+                success(message);
+            }
+            console.log(message);
+        },
+        function(message) {
+            console.log(message);
+        },
+        "qrCodeScanner",
+        "start",
+        [options]
+    );
+};
+
+});

+ 4 - 1
platforms/android/project.properties

@@ -13,4 +13,7 @@
 target=android-26
 android.library.reference.1=CordovaLib
 cordova.system.library.1=com.android.support:support-v4:24.1.1+
-cordova.gradle.include.1=cordova-plugin-crosswalk-webview/pumpApp-xwalk.gradle
+cordova.gradle.include.1=cordova-plugin-crosswalk-webview/pumpApp-xwalk.gradle
+cordova.system.library.2=com.google.zxing:core:3.3.0
+cordova.system.library.3=cn.bingoogolapple:bga-qrcodecore:1.1.9@aar
+cordova.system.library.4=cn.bingoogolapple:bga-zxing:1.1.9@aar

BIN
platforms/android/res/drawable-xhdpi/ic_shortcut_flash_off.png


BIN
platforms/android/res/drawable-xhdpi/ic_shortcut_flash_on.png


BIN
platforms/android/res/drawable-xhdpi/prev.png


BIN
platforms/android/res/drawable-xxhdpi/ic_shortcut_flash_off.png


BIN
platforms/android/res/drawable-xxhdpi/ic_shortcut_flash_on.png


BIN
platforms/android/res/drawable-xxhdpi/prev.png


BIN
platforms/android/res/drawable-xxxhdpi/ic_shortcut_flash_off.png


BIN
platforms/android/res/drawable-xxxhdpi/ic_shortcut_flash_on.png


+ 5 - 0
platforms/android/res/drawable/ic_flash.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/ic_shortcut_flash_on" android:state_activated="true" />
+    <item android:drawable="@drawable/ic_shortcut_flash_off" />
+</selector>

+ 61 - 0
platforms/android/res/layout/activity_scan.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="cn.x1ongzhu.qrCodeScanner.ScanActivity">
+
+
+    <cn.bingoogolapple.qrcode.zxing.ZXingView
+        android:id="@+id/zxingview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:qrcv_animTime="1000"
+        app:qrcv_barCodeTipText="将条码放入框内,即可自动扫描"
+        app:qrcv_barcodeRectHeight="140dp"
+        app:qrcv_borderColor="@android:color/white"
+        app:qrcv_borderSize="1dp"
+        app:qrcv_cornerColor="#2face9"
+        app:qrcv_cornerLength="10dp"
+        app:qrcv_cornerSize="3dp"
+        app:qrcv_isBarcode="false"
+        app:qrcv_isCenterVertical="false"
+        app:qrcv_isOnlyDecodeScanBoxArea="true"
+        app:qrcv_isScanLineReverse="true"
+        app:qrcv_isShowDefaultGridScanLineDrawable="false"
+        app:qrcv_isShowDefaultScanLineDrawable="true"
+        app:qrcv_isShowTipBackground="true"
+        app:qrcv_isShowTipTextAsSingleLine="false"
+        app:qrcv_isTipTextBelowRect="false"
+        app:qrcv_maskColor="#66000000"
+        app:qrcv_qrCodeTipText="将二维码放入框内\n即可自动扫描"
+        app:qrcv_rectWidth="170dp"
+        app:qrcv_scanLineColor="#2face9"
+        app:qrcv_scanLineMargin="0dp"
+        app:qrcv_scanLineSize="0.5dp"
+        app:qrcv_tipTextColor="@android:color/white"
+        app:qrcv_tipTextSize="12sp"
+        app:qrcv_toolbarHeight="160dp"
+        app:qrcv_topOffset="0dp" />
+
+    <ImageButton
+        android:id="@+id/btn_flash"
+        android:layout_width="64dp"
+        android:layout_height="64dp"
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        android:layout_marginBottom="60dp"
+        android:background="@null"
+        android:scaleType="fitXY"
+        android:src="@drawable/ic_flash" />
+
+    <ImageButton
+        android:id="@+id/btn_back"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="15dp"
+        android:layout_marginTop="15dp"
+        android:background="@null"
+        android:src="@drawable/prev" />
+</RelativeLayout>

+ 3 - 0
platforms/android/res/xml/config.xml

@@ -16,6 +16,9 @@
     <feature name="Toast">
         <param name="android-package" value="nl.xservices.plugins.Toast" />
     </feature>
+    <feature name="qrCodeScanner">
+        <param name="android-package" value="cn.x1ongzhu.qrCodeScanner.qrCodeScanner" />
+    </feature>
     <feature name="RemoteInjection">
         <param name="android-package" value="com.truckmovers.cordova.RemoteInjectionPlugin" />
         <param name="onload" value="true" />

+ 67 - 0
platforms/android/src/cn/x1ongzhu/qrCodeScanner/ScanActivity.java

@@ -0,0 +1,67 @@
+package cn.x1ongzhu.qrCodeScanner;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import cn.bingoogolapple.qrcode.core.QRCodeView;
+import cn.bingoogolapple.qrcode.zxing.ZXingView;
+
+public class ScanActivity extends Activity implements QRCodeView.Delegate, View.OnClickListener {
+
+    private QRCodeView mQRCodeView;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        setContentView(getResources().getIdentifier("activity_scan", "layout", getPackageName()));
+        findViewById(getResources().getIdentifier("btn_flash", "id", getPackageName())).setOnClickListener(this);
+        findViewById(getResources().getIdentifier("btn_back", "id", getPackageName())).setOnClickListener(this);
+        mQRCodeView = (ZXingView) findViewById(getResources().getIdentifier("zxingview", "id", getPackageName()));
+        mQRCodeView.setDelegate(this);
+        mQRCodeView.startSpotAndShowRect();
+    }
+
+    @Override
+    public void onScanQRCodeSuccess(String s) {
+        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
+        Intent intent = new Intent();
+        intent.putExtra("result", s);
+        setResult(RESULT_OK, intent);
+        finish();
+    }
+
+    @Override
+    public void onScanQRCodeOpenCameraError() {
+        new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT).setMessage("无法打开摄像头").create().show();
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v.getId() == getResources().getIdentifier("btn_flash", "id", getPackageName())) {
+            if (v.isActivated()) {
+                mQRCodeView.closeFlashlight();
+                v.setActivated(false);
+            } else {
+                mQRCodeView.openFlashlight();
+                v.setActivated(true);
+            }
+        } else if (v.getId() == getResources().getIdentifier("btn_back", "id", getPackageName())) {
+            finish();
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mQRCodeView.stopCamera();
+        mQRCodeView.closeFlashlight();
+    }
+}

+ 44 - 0
platforms/android/src/cn/x1ongzhu/qrCodeScanner/qrCodeScanner.java

@@ -0,0 +1,44 @@
+package cn.x1ongzhu.qrCodeScanner;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Intent;
+import android.text.TextUtils;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaArgs;
+import org.apache.cordova.CordovaPlugin;
+import org.json.JSONException;
+
+/**
+ * Created by xiongzhu on 2017/12/14.
+ */
+
+public class qrCodeScanner extends CordovaPlugin {
+    private static final int REQUEST_SCAN = 1;
+    private CallbackContext callbackContext;
+
+    @Override
+    public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
+        this.callbackContext = callbackContext;
+        if (action.equals("start")) {
+            if (cordova.hasPermission(Manifest.permission.CAMERA)) {
+                this.cordova.startActivityForResult(this, new Intent(this.cordova.getActivity(), ScanActivity.class), REQUEST_SCAN);
+            } else {
+                cordova.requestPermission(this, 1, Manifest.permission.CAMERA);
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+        super.onActivityResult(requestCode, resultCode, intent);
+        if (resultCode == Activity.RESULT_OK) {
+            String result = intent.getStringExtra("result");
+            if (!TextUtils.isEmpty(result)) {
+                callbackContext.success(result);
+            }
+        }
+    }
+}

+ 3 - 0
plugins/android.json

@@ -35,6 +35,9 @@
       "XWALK_MODE": "embedded",
       "XWALK_MULTIPLEAPK": "true",
       "PACKAGE_NAME": "com.izouma.pumpApp"
+    },
+    "cordova-plugin-qrcode-scanner": {
+      "PACKAGE_NAME": "com.izouma.pumpApp"
     }
   },
   "dependent_plugins": {}

+ 21 - 0
plugins/cordova-plugin-qrcode-scanner/package.json

@@ -0,0 +1,21 @@
+{
+    "name": "cordova-plugin-qrcode-scanner",
+    "version": "1.0.0",
+    "description": "",
+    "scripts": {},
+    "repository": {
+        "type": "git",
+        "url": "git+https://github.com/x1ongzhu/cordova-plugin-qrcode-scanner.git"
+    },
+    "keywords": ["cordova"],
+    "author": "x1ongzhu",
+    "license": "ISC",
+    "bugs": {
+        "url": "https://github.com/x1ongzhu/cordova-plugin-qrcode-scanner/issues"
+    },
+    "homepage": "https://github.com/x1ongzhu/cordova-plugin-qrcode-scanner#readme",
+    "cordova": {
+        "id": "cordova-plugin-wechat",
+        "platforms": ["android", "ios"]
+    }
+}

+ 52 - 0
plugins/cordova-plugin-qrcode-scanner/plugin.xml

@@ -0,0 +1,52 @@
+<?xml version='1.0' encoding='utf-8'?>
+<plugin id="cordova-plugin-qrcode-scanner" version="1.0.0" 
+    xmlns="http://apache.org/cordova/ns/plugins/1.0" 
+    xmlns:android="http://schemas.android.com/apk/res/android">
+    <name>qrCodeScanner</name>
+    <js-module name="qrCodeScanner" src="www/qrCodeScanner.js">
+        <clobbers target="qrCodeScanner" />
+    </js-module>
+    <platform name="android">
+        <config-file parent="/*" target="res/xml/config.xml">
+            <feature name="qrCodeScanner">
+                <param name="android-package" value="cn.x1ongzhu.qrCodeScanner.qrCodeScanner" />
+            </feature>
+        </config-file>
+        <config-file parent="/*" target="AndroidManifest.xml">
+            <uses-permission android:name="android.permission.CAMERA" />
+            <uses-permission android:name="android.permission.FLASHLIGHT" />
+        </config-file>
+        <config-file parent="/manifest/application" target="AndroidManifest.xml">
+            <activity android:name="cn.x1ongzhu.qrCodeScanner.ScanActivity" />
+        </config-file>
+        <source-file src="src/android/qrCodeScanner.java" target-dir="src/cn/x1ongzhu/qrCodeScanner" />
+        <source-file src="src/android/ScanActivity.java" target-dir="src/cn/x1ongzhu/qrCodeScanner" />
+        <source-file src="src/android/res/layout/activity_scan.xml" target-dir="res/layout" />
+        <source-file src="src/android/res/drawable/ic_flash.xml" target-dir="res/drawable" />
+        <source-file src="src/android/res/drawable-xhdpi/ic_shortcut_flash_off.png" target-dir="res/drawable-xhdpi" />
+        <source-file src="src/android/res/drawable-xhdpi/ic_shortcut_flash_on.png" target-dir="res/drawable-xhdpi" />
+        <source-file src="src/android/res/drawable-xhdpi/prev.png" target-dir="res/drawable-xhdpi" />
+        <source-file src="src/android/res/drawable-xxhdpi/ic_shortcut_flash_off.png" target-dir="res/drawable-xxhdpi" />
+        <source-file src="src/android/res/drawable-xxhdpi/ic_shortcut_flash_on.png" target-dir="res/drawable-xxhdpi" />
+        <source-file src="src/android/res/drawable-xxhdpi/prev.png" target-dir="res/drawable-xxhdpi" />
+        <source-file src="src/android/res/drawable-xxxhdpi/ic_shortcut_flash_off.png" target-dir="res/drawable-xxxhdpi" />
+        <source-file src="src/android/res/drawable-xxxhdpi/ic_shortcut_flash_on.png" target-dir="res/drawable-xxxhdpi" />
+        <framework src="com.google.zxing:core:3.3.0" />
+        <framework src="cn.bingoogolapple:bga-qrcodecore:1.1.9@aar" />
+        <framework src="cn.bingoogolapple:bga-zxing:1.1.9@aar" />
+    </platform>
+    <platform name="ios">
+        <config-file parent="/*" target="config.xml">
+            <feature name="qrCodeScanner">
+                <param name="ios-package" value="qrCodeScanner" />
+            </feature>
+        </config-file>
+        <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
+            <string>需要相机权限</string>
+        </config-file>
+        <source-file src="src/ios/qrCodeScanner.m" />
+        <source-file src="src/ios/ScanViewController.h" />
+        <source-file src="src/ios/ScanViewController.m" />
+        <resource-file src="src/ios/qrCodeScanner.bundle"/>
+    </platform>
+</plugin>

+ 67 - 0
plugins/cordova-plugin-qrcode-scanner/src/android/ScanActivity.java

@@ -0,0 +1,67 @@
+package cn.x1ongzhu.qrCodeScanner;
+
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.Intent;
+import android.os.Bundle;
+import android.view.View;
+import android.view.Window;
+import android.view.WindowManager;
+import android.widget.Toast;
+
+import cn.bingoogolapple.qrcode.core.QRCodeView;
+import cn.bingoogolapple.qrcode.zxing.ZXingView;
+
+public class ScanActivity extends Activity implements QRCodeView.Delegate, View.OnClickListener {
+
+    private QRCodeView mQRCodeView;
+
+    @Override
+    protected void onCreate(Bundle savedInstanceState) {
+        super.onCreate(savedInstanceState);
+        requestWindowFeature(Window.FEATURE_NO_TITLE);
+        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
+        setContentView(getResources().getIdentifier("activity_scan", "layout", getPackageName()));
+        findViewById(getResources().getIdentifier("btn_flash", "id", getPackageName())).setOnClickListener(this);
+        findViewById(getResources().getIdentifier("btn_back", "id", getPackageName())).setOnClickListener(this);
+        mQRCodeView = (ZXingView) findViewById(getResources().getIdentifier("zxingview", "id", getPackageName()));
+        mQRCodeView.setDelegate(this);
+        mQRCodeView.startSpotAndShowRect();
+    }
+
+    @Override
+    public void onScanQRCodeSuccess(String s) {
+        Toast.makeText(this, s, Toast.LENGTH_SHORT).show();
+        Intent intent = new Intent();
+        intent.putExtra("result", s);
+        setResult(RESULT_OK, intent);
+        finish();
+    }
+
+    @Override
+    public void onScanQRCodeOpenCameraError() {
+        new AlertDialog.Builder(this, AlertDialog.THEME_DEVICE_DEFAULT_LIGHT).setMessage("无法打开摄像头").create().show();
+    }
+
+    @Override
+    public void onClick(View v) {
+        if (v.getId() == getResources().getIdentifier("btn_flash", "id", getPackageName())) {
+            if (v.isActivated()) {
+                mQRCodeView.closeFlashlight();
+                v.setActivated(false);
+            } else {
+                mQRCodeView.openFlashlight();
+                v.setActivated(true);
+            }
+        } else if (v.getId() == getResources().getIdentifier("btn_back", "id", getPackageName())) {
+            finish();
+        }
+    }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mQRCodeView.stopCamera();
+        mQRCodeView.closeFlashlight();
+    }
+}

+ 44 - 0
plugins/cordova-plugin-qrcode-scanner/src/android/qrCodeScanner.java

@@ -0,0 +1,44 @@
+package cn.x1ongzhu.qrCodeScanner;
+
+import android.Manifest;
+import android.app.Activity;
+import android.content.Intent;
+import android.text.TextUtils;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaArgs;
+import org.apache.cordova.CordovaPlugin;
+import org.json.JSONException;
+
+/**
+ * Created by xiongzhu on 2017/12/14.
+ */
+
+public class qrCodeScanner extends CordovaPlugin {
+    private static final int REQUEST_SCAN = 1;
+    private CallbackContext callbackContext;
+
+    @Override
+    public boolean execute(String action, CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
+        this.callbackContext = callbackContext;
+        if (action.equals("start")) {
+            if (cordova.hasPermission(Manifest.permission.CAMERA)) {
+                this.cordova.startActivityForResult(this, new Intent(this.cordova.getActivity(), ScanActivity.class), REQUEST_SCAN);
+            } else {
+                cordova.requestPermission(this, 1, Manifest.permission.CAMERA);
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
+        super.onActivityResult(requestCode, resultCode, intent);
+        if (resultCode == Activity.RESULT_OK) {
+            String result = intent.getStringExtra("result");
+            if (!TextUtils.isEmpty(result)) {
+                callbackContext.success(result);
+            }
+        }
+    }
+}

BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/ic_shortcut_flash_off.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/ic_shortcut_flash_on.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xhdpi/prev.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/ic_shortcut_flash_off.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/ic_shortcut_flash_on.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxhdpi/prev.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxxhdpi/ic_shortcut_flash_off.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable-xxxhdpi/ic_shortcut_flash_on.png


+ 5 - 0
plugins/cordova-plugin-qrcode-scanner/src/android/res/drawable/ic_flash.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/ic_shortcut_flash_on" android:state_activated="true" />
+    <item android:drawable="@drawable/ic_shortcut_flash_off" />
+</selector>

+ 61 - 0
plugins/cordova-plugin-qrcode-scanner/src/android/res/layout/activity_scan.xml

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    tools:context="cn.x1ongzhu.qrCodeScanner.ScanActivity">
+
+
+    <cn.bingoogolapple.qrcode.zxing.ZXingView
+        android:id="@+id/zxingview"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        app:qrcv_animTime="1000"
+        app:qrcv_barCodeTipText="将条码放入框内,即可自动扫描"
+        app:qrcv_barcodeRectHeight="140dp"
+        app:qrcv_borderColor="@android:color/white"
+        app:qrcv_borderSize="1dp"
+        app:qrcv_cornerColor="#2face9"
+        app:qrcv_cornerLength="10dp"
+        app:qrcv_cornerSize="3dp"
+        app:qrcv_isBarcode="false"
+        app:qrcv_isCenterVertical="false"
+        app:qrcv_isOnlyDecodeScanBoxArea="true"
+        app:qrcv_isScanLineReverse="true"
+        app:qrcv_isShowDefaultGridScanLineDrawable="false"
+        app:qrcv_isShowDefaultScanLineDrawable="true"
+        app:qrcv_isShowTipBackground="true"
+        app:qrcv_isShowTipTextAsSingleLine="false"
+        app:qrcv_isTipTextBelowRect="false"
+        app:qrcv_maskColor="#66000000"
+        app:qrcv_qrCodeTipText="将二维码放入框内\n即可自动扫描"
+        app:qrcv_rectWidth="170dp"
+        app:qrcv_scanLineColor="#2face9"
+        app:qrcv_scanLineMargin="0dp"
+        app:qrcv_scanLineSize="0.5dp"
+        app:qrcv_tipTextColor="@android:color/white"
+        app:qrcv_tipTextSize="12sp"
+        app:qrcv_toolbarHeight="160dp"
+        app:qrcv_topOffset="0dp" />
+
+    <ImageButton
+        android:id="@+id/btn_flash"
+        android:layout_width="64dp"
+        android:layout_height="64dp"
+        android:layout_alignParentBottom="true"
+        android:layout_centerHorizontal="true"
+        android:layout_marginBottom="60dp"
+        android:background="@null"
+        android:scaleType="fitXY"
+        android:src="@drawable/ic_flash" />
+
+    <ImageButton
+        android:id="@+id/btn_back"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:layout_marginLeft="15dp"
+        android:layout_marginTop="15dp"
+        android:background="@null"
+        android:src="@drawable/prev" />
+</RelativeLayout>

+ 20 - 0
plugins/cordova-plugin-qrcode-scanner/src/ios/ScanViewController.h

@@ -0,0 +1,20 @@
+//
+//  ScanViewController.h
+//  qrCodeScanner
+//
+//  Created by 熊竹 on 18/1/23.
+//  Copyright © 2016年 熊竹. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol ScanDelegate <NSObject>
+- (void)onResult:(NSString *)result;
+@end
+
+@interface ScanViewController : UIViewController
+
+@property (nonatomic, weak) id <ScanDelegate> delegate;
+
+@end
+

+ 298 - 0
plugins/cordova-plugin-qrcode-scanner/src/ios/ScanViewController.m

@@ -0,0 +1,298 @@
+//
+//  ScanViewController.m
+//  qrCodeScanner
+//
+//  Created by 熊竹 on 18/1/23.
+//  Copyright © 2016年 熊竹. All rights reserved.
+//
+
+#import "ScanViewController.h"
+#import <AVFoundation/AVFoundation.h>
+
+/**
+ *  屏幕 高 宽 边界
+ */
+#define SCREEN_HEIGHT [UIScreen mainScreen].bounds.size.height
+#define SCREEN_WIDTH  [UIScreen mainScreen].bounds.size.width
+#define SCREEN_BOUNDS  [UIScreen mainScreen].bounds
+
+#define TOP (SCREEN_HEIGHT-220)/2
+#define LEFT (SCREEN_WIDTH-220)/2
+
+#define kScanRect CGRectMake(LEFT, TOP, 220, 220)
+
+@interface ScanViewController ()<AVCaptureMetadataOutputObjectsDelegate>{
+    int num;
+    BOOL upOrdown;
+    NSTimer * timer;
+    CAShapeLayer *cropLayer;
+}
+@property (strong,nonatomic)AVCaptureDevice * device;
+@property (strong,nonatomic)AVCaptureDeviceInput * input;
+@property (strong,nonatomic)AVCaptureMetadataOutput * output;
+@property (strong,nonatomic)AVCaptureSession * session;
+@property (strong,nonatomic)AVCaptureVideoPreviewLayer * preview;
+
+@property (nonatomic, strong) UIImageView * line;
+@property (nonatomic, strong) UIButton * btnFlash;
+
+@end
+
+@implementation ScanViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view, typically from a nib.
+    
+    [self configView];
+}
+
+-(void)configView{
+    [self.view setBackgroundColor:[UIColor blackColor]];
+    UIImageView * imageView = [[UIImageView alloc]initWithFrame:kScanRect];
+    NSString * bundlePath = [[ NSBundle mainBundle] pathForResource: @ "qrCodeScanner" ofType :@ "bundle"];
+    NSBundle *resourceBundle = [NSBundle bundleWithPath:bundlePath];
+    imageView.image = [UIImage imageNamed:@"pick_bg"
+                                 inBundle:resourceBundle
+            compatibleWithTraitCollection:nil];
+    imageView.image = [imageView.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+    [_line setTintColor:[self getColor:@"#2face9"]];
+    [self.view addSubview:imageView];
+    
+    upOrdown = NO;
+    num =0;
+    _line = [[UIImageView alloc] initWithFrame:CGRectMake(LEFT, TOP+10, 220, 2)];
+    _line.image = [UIImage imageNamed:@"line.png"
+                             inBundle:resourceBundle
+        compatibleWithTraitCollection:nil];
+    _line.image = [_line.image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
+    [_line setTintColor:[self getColor:@"#2face9"]];
+    [self.view addSubview:_line];
+    
+    timer = [NSTimer scheduledTimerWithTimeInterval:.02 target:self selector:@selector(animation1) userInfo:nil repeats:YES];
+    
+}
+
+-(void) toggleFlash:(UIButton*)button{
+    if (self.btnFlash.isSelected) {
+        if ([_device hasTorch]) {
+            [_device lockForConfiguration:nil];
+            [_device setTorchMode: AVCaptureTorchModeOff];
+            [_device unlockForConfiguration];
+            [_btnFlash setSelected:NO];
+        }
+    }else{
+        NSError *error = nil;
+        if ([_device hasTorch]) {
+            BOOL locked = [_device lockForConfiguration:&error];
+            if (locked) {
+                _device.torchMode = AVCaptureTorchModeOn;
+                [_device unlockForConfiguration];
+                [_btnFlash setSelected:YES];
+            }
+        }
+    }
+}
+
+-(void)viewWillAppear:(BOOL)animated{
+    
+    [self setCropRect:kScanRect];
+    
+    NSString * bundlePath = [[ NSBundle mainBundle] pathForResource: @ "qrCodeScanner" ofType :@ "bundle"];
+    NSBundle *resourceBundle = [NSBundle bundleWithPath:bundlePath];
+    _btnFlash = [[UIButton alloc] initWithFrame:CGRectMake(([UIScreen mainScreen].bounds.size.width - 72) / 2,
+                                                           ([UIScreen mainScreen].bounds.size.height + 220) / 2 + 50,
+                                                           72, 72)];
+    [_btnFlash setImage:[UIImage imageNamed:@"ic_shortcut_flash_off"
+                                   inBundle:resourceBundle
+              compatibleWithTraitCollection:nil]
+               forState:UIControlStateNormal];
+    [_btnFlash setImage:[UIImage imageNamed:@"ic_shortcut_flash_on"
+                                   inBundle:resourceBundle
+              compatibleWithTraitCollection:nil]
+               forState:UIControlStateSelected];
+    
+    [_btnFlash addTarget:self action:@selector(toggleFlash:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:_btnFlash];
+    
+    UIButton* btnBack = [[UIButton alloc] initWithFrame:CGRectMake(10, 30, 42, 42)];
+    [btnBack setImage:[UIImage imageNamed:@"prev" inBundle:resourceBundle compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
+    [btnBack addTarget:self action:@selector(close:) forControlEvents:UIControlEventTouchUpInside];
+    [self.view addSubview:btnBack];
+    
+    [self performSelector:@selector(setupCamera) withObject:nil afterDelay:0];
+    
+}
+
+-(void) close:(UIButton*)button{
+    [self dismissViewControllerAnimated:YES completion:nil];
+}
+
+-(void)animation1
+{
+    if (upOrdown == NO) {
+        num ++;
+        _line.frame = CGRectMake(LEFT, TOP+10+2*num, 220, 2);
+        if (2*num == 200) {
+            upOrdown = YES;
+        }
+    }
+    else {
+        num --;
+        _line.frame = CGRectMake(LEFT, TOP+10+2*num, 220, 2);
+        if (num == 0) {
+            upOrdown = NO;
+        }
+    }
+    
+}
+
+
+- (void)setCropRect:(CGRect)cropRect{
+    cropLayer = [[CAShapeLayer alloc] init];
+    CGMutablePathRef path = CGPathCreateMutable();
+    CGPathAddRect(path, nil, cropRect);
+    CGPathAddRect(path, nil, self.view.bounds);
+    
+    [cropLayer setFillRule:kCAFillRuleEvenOdd];
+    [cropLayer setPath:path];
+    [cropLayer setFillColor:[UIColor blackColor].CGColor];
+    [cropLayer setOpacity:0.6];
+    
+    
+    [cropLayer setNeedsDisplay];
+    
+    [self.view.layer addSublayer:cropLayer];
+}
+
+- (void)setupCamera
+{
+    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
+    if (device==nil) {
+        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"设备没有摄像头" preferredStyle:UIAlertControllerStyleAlert];
+        [alert addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            
+        }]];
+        [self presentViewController:alert animated:YES completion:nil];
+        return;
+    }
+    // Device
+    _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
+    
+    // Input
+    _input = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];
+    
+    // Output
+    _output = [[AVCaptureMetadataOutput alloc]init];
+    [_output setMetadataObjectsDelegate:self queue:dispatch_get_main_queue()];
+    
+    //设置扫描区域
+    CGFloat top = TOP/SCREEN_HEIGHT;
+    CGFloat left = LEFT/SCREEN_WIDTH;
+    CGFloat width = 220/SCREEN_WIDTH;
+    CGFloat height = 220/SCREEN_HEIGHT;
+    ///top 与 left 互换  width 与 height 互换
+    [_output setRectOfInterest:CGRectMake(top,left, height, width)];
+    
+    
+    // Session
+    _session = [[AVCaptureSession alloc]init];
+    [_session setSessionPreset:AVCaptureSessionPresetHigh];
+    if ([_session canAddInput:self.input])
+    {
+        [_session addInput:self.input];
+    }
+    
+    if ([_session canAddOutput:self.output])
+    {
+        [_session addOutput:self.output];
+    }
+    
+    // 条码类型 AVMetadataObjectTypeQRCode
+    [_output setMetadataObjectTypes:[NSArray arrayWithObjects:AVMetadataObjectTypeQRCode, nil]];
+    
+    // Preview
+    _preview =[AVCaptureVideoPreviewLayer layerWithSession:_session];
+    _preview.videoGravity = AVLayerVideoGravityResizeAspectFill;
+    _preview.frame =self.view.layer.bounds;
+    [self.view.layer insertSublayer:_preview atIndex:0];
+    
+    // Start
+    [_session startRunning];
+}
+
+#pragma mark AVCaptureMetadataOutputObjectsDelegate
+- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection
+{
+    NSString *stringValue;
+    
+    if ([metadataObjects count] >0)
+    {
+        //停止扫描
+        [_session stopRunning];
+        [timer setFireDate:[NSDate distantFuture]];
+        
+        AVMetadataMachineReadableCodeObject * metadataObject = [metadataObjects objectAtIndex:0];
+        stringValue = metadataObject.stringValue;
+        NSLog(@"扫描结果:%@",stringValue);
+        
+        //        NSArray *arry = metadataObject.corners;
+        //        for (id temp in arry) {
+        //            NSLog(@"%@",temp);
+        //        }
+        //
+        //
+        //        UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"扫描结果" message:stringValue preferredStyle:UIAlertControllerStyleAlert];
+        //        [alert addAction:[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        //            if (_session != nil && timer != nil) {
+        //                [_session startRunning];
+        //                [timer setFireDate:[NSDate date]];
+        //            }
+        //
+        //        }]];
+        //        [self presentViewController:alert animated:YES completion:nil];
+        if(self.delegate){
+            [self.delegate onResult:stringValue];
+        }
+        [self dismissViewControllerAnimated:YES completion:nil];
+        
+    } else {
+        NSLog(@"无扫描信息");
+        return;
+    }
+    
+}
+
+
+- (void)didReceiveMemoryWarning {
+    [super didReceiveMemoryWarning];
+    // Dispose of any resources that can be recreated.
+}
+
+- (UIColor *)getColor:(NSString *)hexColor
+{
+    if ([hexColor hasPrefix:@"#"]) {
+        hexColor = [hexColor substringFromIndex:1];
+    }
+    unsigned int red,green,blue;
+    NSRange range;
+    range.length = 2;
+    range.location = 0;
+    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&red];
+    range.location = 2;
+    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&green];
+    range.location = 4;
+    [[NSScanner scannerWithString:[hexColor substringWithRange:range]] scanHexInt:&blue];
+    return [UIColor colorWithRed:(float)(red/255.0f) green:(float)(green / 255.0f) blue:(float)(blue / 255.0f) alpha:1.0f];
+}
+
+-(UIStatusBarStyle)preferredStatusBarStyle{
+    return UIStatusBarStyleLightContent;
+}
+
+-(BOOL)prefersStatusBarHidden{
+    return YES;
+}
+
+@end
+

BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_off@2x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_off@3x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_on@2x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/ic_shortcut_flash_on@3x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/line.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/line@2x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/pick_bg.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/pick_bg@2x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev@2x.png


BIN
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.bundle/prev@3x.png


+ 46 - 0
plugins/cordova-plugin-qrcode-scanner/src/ios/qrCodeScanner.m

@@ -0,0 +1,46 @@
+/********* qrCodeScanner.m Cordova Plugin Implementation *******/
+
+#import <Cordova/CDV.h>
+#import "ScanViewController.h"
+
+@interface qrCodeScanner : CDVPlugin<ScanDelegate> {
+  // Member variables go here.
+}
+@property (nonatomic, strong) CDVInvokedUrlCommand* command;
+- (void)coolMethod:(CDVInvokedUrlCommand*)command;
+- (void)start:(CDVInvokedUrlCommand*)command;
+@end
+
+@implementation qrCodeScanner
+
+- (void)start:(CDVInvokedUrlCommand*)command{
+    ScanViewController* scanVC = [[ScanViewController alloc] init];
+    scanVC.delegate = self;
+    self.command = command;
+    [self.viewController presentViewController:scanVC animated:YES completion:nil];
+}
+
+- (void)coolMethod:(CDVInvokedUrlCommand*)command
+{
+    
+    CDVPluginResult* pluginResult = nil;
+    NSString* echo = [command.arguments objectAtIndex:0];
+
+    if (echo != nil && [echo length] > 0) {
+        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo];
+    } else {
+        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
+    }
+
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
+
+- (void)onResult:(NSString *)result {
+    NSLog(@"scan result:%@", result);
+    if (self.command) {
+        CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:result];
+        [self.commandDelegate sendPluginResult:pluginResult callbackId:self.command.callbackId];
+    }
+}
+
+@end

+ 18 - 0
plugins/cordova-plugin-qrcode-scanner/www/qrCodeScanner.js

@@ -0,0 +1,18 @@
+var exec = require("cordova/exec");
+
+exports.start = function(success, options) {
+    exec(
+        function(message) {
+            if (typeof success === "function") {
+                success(message);
+            }
+            console.log(message);
+        },
+        function(message) {
+            console.log(message);
+        },
+        "qrCodeScanner",
+        "start",
+        [options]
+    );
+};

+ 8 - 0
plugins/fetch.json

@@ -62,5 +62,13 @@
     },
     "is_top_level": true,
     "variables": {}
+  },
+  "cordova-plugin-qrcode-scanner": {
+    "source": {
+      "type": "local",
+      "path": "/Users/drew/Projects/Cordova/pumpApp/node_modules/cordova-plugin-qrcode-scanner"
+    },
+    "is_top_level": true,
+    "variables": {}
   }
 }

+ 2 - 1
vue/index.html

@@ -5,6 +5,7 @@
     <meta charset="utf-8">
     <title>水泵</title>
     <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">
+    <script src="cordova.js"></script>
 </head>
 <style>
     a {
@@ -17,4 +18,4 @@
     <!-- built files will be auto injected -->
 </body>
 
-</html>
+</html>

+ 1 - 1
www/index.html

@@ -1,3 +1,3 @@
-<!DOCTYPE html><html><head><meta charset=utf-8><title>水泵</title><meta name=viewport content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><link href=./static/css/app.bdbbf849a8c5db37ad3631afef2ca6c2.css rel=stylesheet></head><style>a {
+<!DOCTYPE html><html><head><meta charset=utf-8><title>水泵</title><meta name=viewport content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"><script src=cordova.js></script><link href=./static/css/app.bdbbf849a8c5db37ad3631afef2ca6c2.css rel=stylesheet></head><style>a {
         text-decoration: none;
     }</style><body><div id=app></div><script type=text/javascript src=./static/js/manifest.19f4740cc77c168ee709.js></script><script type=text/javascript src=./static/js/vendor.83bc9862f9225e9f11f1.js></script><script type=text/javascript src=./static/js/app.4ab066ba21cd7bc5d906.js></script></body></html>

Разница между файлами не показана из-за своего большого размера
+ 0 - 0
www/static/js/manifest.19f4740cc77c168ee709.js.map


Некоторые файлы не были показаны из-за большого количества измененных файлов