123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- // index.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(({}), (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";
- this.data.myPlugin.initPermissions(({
- 'permissionArr': permissionArr
- }), (res) => {
- if (res === "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)
- },
- lenovoInitSDK() {
- this.data.myPlugin.lenovoInitSDK({}, (res) => {
- console.log('res:', res)
- if (res === "success") {
- console.log("初始化联想sdk成功")
- } else {
- console.log(res)
- }
- })
- },
- lenovoLogin() {
- this.data.myPlugin.lenovoLogin({}, (res) => {
- console.log('res:', res)
- })
- },
- lenovoPay() {
- this.data.myPlugin.lenovoPay({}, (res) => {
- console.log('res:', res)
- })
- },
- lenovoLogout() {
- this.data.myPlugin.lenovoLogout({}, (res) => {
- console.log('res:', res)
- })
- },
- aliPay() {
- this.data.myPlugin.aliPay({}, (res) => {
- console.log('res:', res)
- })
- },
- huaweiLogin() {
- this.data.myPlugin.HuaWeiLogin({}, (res) => {
- console.log('res:', res)
- })
- },
- huaweiLogout() {
- this.data.myPlugin.HuaWeiSignOut({}, (res) => {
- console.log('res:', res)
- })
- }
- })
|