uni_android_plugin_project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
2.3 KiB

  1. <template>
  2. <div>
  3. <button type="primary" @click="testAsyncFunc">testAsyncFunc</button>
  4. <button type="primary" @click="testSyncFunc">testSyncFunc</button>
  5. <button type="primary" @click="gotoNativePage">跳转原生Activity</button>
  6. <button type="primary" @click="testAsyncFunc2">testAsyncFunc2</button>
  7. <button type="primary" @click="testSyncFunc2">testSyncFunc2</button>
  8. <button type="primary" @click="testFun1">zmt-testFun1</button>
  9. <button type="primary" @click="testFun2">zmt-testFun2</button>
  10. </div>
  11. </template>
  12. <script>
  13. // 获取 module
  14. var zmtModule = uni.requireNativePlugin("Zmt-Module")
  15. var testModule = uni.requireNativePlugin("TestModule")
  16. var testModule2 = uni.requireNativePlugin("TestModule2")
  17. const modal = uni.requireNativePlugin('modal');
  18. export default {
  19. onLoad() {
  20. plus.globalEvent.addEventListener('TestEvent', function(e){
  21. modal.toast({
  22. message: "TestEvent收到:"+e.msg,
  23. duration: 1.5
  24. });
  25. });
  26. },
  27. methods: {
  28. testFun1(){
  29. // 调用异步方法
  30. zmtModule.testAsyncFunc({
  31. 'name': 'unimp',
  32. 'age': 1
  33. },
  34. (ret) => {
  35. modal.toast({
  36. message: ret,
  37. duration: 1.5
  38. });
  39. })
  40. },
  41. testFun2(){
  42. // 调用同步方法
  43. var ret = zmtModule.testSyncFunc({
  44. 'name': 'unimp',
  45. 'age': 1
  46. })
  47. modal.toast({
  48. message: ret,
  49. duration: 1.5
  50. });
  51. },
  52. testAsyncFunc() {
  53. // 调用异步方法
  54. testModule.testAsyncFunc({
  55. 'name': 'unimp',
  56. 'age': 1
  57. },
  58. (ret) => {
  59. modal.toast({
  60. message: ret,
  61. duration: 1.5
  62. });
  63. })
  64. },
  65. testSyncFunc() {
  66. // 调用同步方法
  67. var ret = testModule.testSyncFunc({
  68. 'name': 'unimp',
  69. 'age': 1
  70. })
  71. modal.toast({
  72. message: ret,
  73. duration: 1.5
  74. });
  75. },
  76. testAsyncFunc2() {
  77. // 调用异步方法
  78. testModule2.testAsyncFunc2({
  79. 'name': 'unimp',
  80. 'age': 1
  81. },
  82. (ret) => {
  83. modal.toast({
  84. message: ret,
  85. duration: 1.5
  86. });
  87. })
  88. },
  89. testSyncFunc2() {
  90. // 调用同步方法
  91. var ret = testModule2.testSyncFunc2({
  92. 'name': 'unimp',
  93. 'age': 1
  94. })
  95. modal.toast({
  96. message: ret,
  97. duration: 1.5
  98. });
  99. },
  100. gotoNativePage() {
  101. testModule.gotoNativePage();
  102. }
  103. }
  104. }
  105. </script>