index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // index.js
  2. const {
  3. miniAppPluginId
  4. } = require('../../constant');
  5. Page({
  6. data: {
  7. myPlugin: undefined
  8. },
  9. onLoad(option) {
  10. wx.miniapp.loadNativePlugin({
  11. pluginId: miniAppPluginId,
  12. success: (plugin) => {
  13. console.log('load plugin success', plugin)
  14. this.setData({
  15. myPlugin: plugin
  16. })
  17. },
  18. fail: (e) => {
  19. console.log('load plugin fail', e)
  20. }
  21. })
  22. },
  23. onLoadPlugin() {
  24. this.data.myPlugin.initPlugin(({}), (res) => {
  25. if (res === "success") {
  26. console.log("初始化plugin成功")
  27. } else {
  28. console.log("初始化plugin失败")
  29. }
  30. })
  31. },
  32. onInitPermission() {
  33. let permissionArr =
  34. "android.permission.INTERNET" + "," +
  35. "android.permission.ACCESS_NETWORK_STATE" + "," +
  36. "android.permission.ACCESS_WIFI_STATE" + "," +
  37. "android.permission.RECORD_AUDIO" + "," +
  38. "android.permission.READ_EXTERNAL_STORAGE" + "," +
  39. "android.permission.WRITE_EXTERNAL_STORAGE";
  40. this.data.myPlugin.initPermissions(({
  41. 'permissionArr': permissionArr
  42. }), (res) => {
  43. if (res === "success") {
  44. console.log("初始化权限成功")
  45. } else {
  46. console.log("初始化权限失败")
  47. }
  48. })
  49. },
  50. checkRecordAudioPermission() {
  51. var test = this.data.myPlugin.checkPermission({
  52. 'permission': 'android.permission.RECORD_AUDIO'
  53. })
  54. console.log("是否有权限:" + test)
  55. },
  56. getDeviceUUID() {
  57. var device_uuid = this.data.myPlugin.getDeviceUuid({})
  58. console.log("获取的uuid:" + device_uuid)
  59. },
  60. lenovoInitSDK() {
  61. this.data.myPlugin.lenovoInitSDK({}, (res) => {
  62. console.log('res:', res)
  63. if (res === "success") {
  64. console.log("初始化联想sdk成功")
  65. } else {
  66. console.log(res)
  67. }
  68. })
  69. },
  70. lenovoLogin() {
  71. this.data.myPlugin.lenovoLogin({}, (res) => {
  72. console.log('res:', res)
  73. })
  74. },
  75. lenovoPay() {
  76. this.data.myPlugin.lenovoPay({}, (res) => {
  77. console.log('res:', res)
  78. })
  79. },
  80. lenovoLogout() {
  81. this.data.myPlugin.lenovoLogout({}, (res) => {
  82. console.log('res:', res)
  83. })
  84. },
  85. aliPay() {
  86. this.data.myPlugin.aliPay({}, (res) => {
  87. console.log('res:', res)
  88. })
  89. },
  90. huaweiLogin() {
  91. this.data.myPlugin.HuaWeiLogin({}, (res) => {
  92. console.log('res:', res)
  93. })
  94. },
  95. huaweiLogout() {
  96. this.data.myPlugin.HuaWeiSignOut({}, (res) => {
  97. console.log('res:', res)
  98. })
  99. }
  100. })