浏览代码

调试插件

bayi 1 年之前
父节点
当前提交
29e434064e
共有 2 个文件被更改,包括 35 次插入1 次删除
  1. 25 0
      app.js
  2. 10 1
      project.miniapp.json

+ 25 - 0
app.js

@@ -17,6 +17,7 @@ App({
         // #if MP
         this.updateApplet()
         this.checkIsIos()
+        // #elif ANDROID
         // #endif
         this.getNavbarInfo()
         await loginLog()
@@ -50,6 +51,7 @@ App({
             }
             this.login(shareUid, userChannelCode)
         }
+        this.initPlugin()
     },
     async login(shareUid, userChannelCode = '3001') {
         let uid = wx.getStorageSync('uid')
@@ -206,6 +208,29 @@ App({
             })
         }
     },
+    initPlugin() {
+        let miniAppPluginId = 'wxf1a06dafa3350688'
+        //根据模块ID初始化模块
+        console.log("插件ID:" + miniAppPluginId)
+        wx.miniapp.loadNativePlugin({
+            pluginId: miniAppPluginId,
+            success: (plugin) => {
+                console.log('load plugin success', plugin)
+                plugin.initPlugin(({}), (res) => {
+                    if (res === "success") {
+                        console.log("初始化plugin成功")
+                        var device_uuid = plugin.getDeviceUuid({})
+                        console.log("获取的uuid:" + device_uuid)
+                    } else {
+                        console.log("初始化plugin失败")
+                    }
+                })
+            },
+            fail: (e) => {
+                console.log('load plugin fail', e)
+            }
+        })
+    },
     globalData: {
         userInfo: null,
         isIOS: false, // 判断设备是否为苹果

+ 10 - 1
project.miniapp.json

@@ -66,5 +66,14 @@
       "NSPhotoLibraryAddUsageDescription": "用于保存图片"
     }
   },
-  "versionCode": 100
+  "versionCode": 100,
+  "mini-plugin": {
+    "android": [
+      {
+        "open": true,
+        "pluginId": "wxf1a06dafa3350688",
+        "pluginVersion": "1.0.55"
+      }
+    ]
+  }
 }