123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- // pages/android/android.js
- const {
- miniAppPluginId
- } = require('../../constant');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- myPlugin: undefined
- },
- onLoad(option) {
- wx.miniapp.loadNativePlugin({
- pluginId: miniAppPluginId,
- success: (plugin) => {
- console.log('load plugin success', plugin)
- this.setData({
- myPlugin: plugin
- })
- },
- fail: (e) => {
- console.log('load plugin fail', e)
- }
- })
- },
- onLoadPlugin() {
- this.data.myPlugin.initPlugin(({
- 'channelCode': '9999'
- }), (res) => {
- if (res === "success") {
- console.log("初始化plugin成功")
- } else {
- console.log("初始化plugin失败")
- }
- })
- },
- onInitPermission() {
- let permissionArr =
- "android.permission.INTERNET" + "," +
- "android.permission.ACCESS_NETWORK_STATE" + "," +
- "android.permission.ACCESS_WIFI_STATE" + "," +
- "android.permission.RECORD_AUDIO" + "," +
- "android.permission.READ_EXTERNAL_STORAGE" + "," +
- "android.permission.WRITE_EXTERNAL_STORAGE" + "," +
- "android.permission.READ_PHONE_STATE"
- this.data.myPlugin.initPermissions(({
- 'permissionArr': permissionArr
- }), (res) => {
- res = JSON.parse(res);
- console.log("res:" + res)
- console.log("res:" + res.result)
- if (res.result === "success") {
- console.log("初始化权限成功")
- } else {
- console.log("初始化权限失败")
- }
- })
- },
- checkRecordAudioPermission() {
- var test = this.data.myPlugin.checkPermission({
- 'permission': 'android.permission.RECORD_AUDIO'
- })
- console.log("是否有权限:" + test)
- },
- getDeviceUUID() {
- var device_uuid = this.data.myPlugin.getDeviceUuid({})
- console.log("获取的uuid:" + device_uuid)
- },
- getAndroidSN() {
- var sn = this.data.myPlugin.AndroidSN({})
- console.log("获取的SN:" + sn)
- },
- initUmengSDK() {
- this.data.myPlugin.initUmengSDK(({
- 'channelCode': '3016'
- }), (res) => {
- if (res === "success") {
- console.log("初始化成功")
- } else {
- console.log("初始化失败")
- }
- })
- },
- })
|