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.

168 lines
3.9 KiB

  1. <template>
  2. <div class="content">
  3. <button class="btn" type="primary" @click="gotoNativePage">跳转原生Activity</button>
  4. <button class="btn" type="primary" @click="tcpAsyncFunc">[开启TcpServer]</button>
  5. <text class="tips">
  6. 点击后将开启TcpServer. 本机IP: 192.168.1.64 端口:16666
  7. </text>
  8. <!-- <button type="primary" @click="testFun2">zmt-testFun2</button> -->
  9. <button class="btn" type="primary" @click="faceAsyncFunc">[百度人脸SDK授权]</button>
  10. <text class="tips">
  11. 点击后将进行百度人脸SDK初始化及授权申请,该授权码写死在Android端zmt_module内faceClass,因已使用过,将返回已被占用提示.
  12. </text>
  13. <button class="btn" type="primary" @click="testAsyncFunc2">uniplugin_module_ox testAsyncFunc2</button>
  14. <button class="btn" type="primary" @click="testSyncFunc2">uniplugin_module_ox testSyncFunc2</button>
  15. <button class="btn" type="primary" @click="testAsyncFunc">uniplugin_module testAsyncFunc</button>
  16. <button class="btn" type="primary" @click="testSyncFunc">uniplugin_module testSyncFunc</button>
  17. </div>
  18. </template>
  19. <script>
  20. // #ifdef APP-PLUS
  21. // 获取 module
  22. var zmtModule = uni.requireNativePlugin("Zmt-Module")
  23. var testModule = uni.requireNativePlugin("TestModule") //uniplugin_module
  24. var uniplugin_module_ox = uni.requireNativePlugin("uniplugin_module_ox") //uniplugin_module_ox
  25. var faceModule = uni.requireNativePlugin("Face-Module") //百度人脸SDK, face_module
  26. const modal = uni.requireNativePlugin('modal');
  27. // #endif
  28. export default {
  29. onLoad() {
  30. this.initAPPListener()
  31. },
  32. methods: {
  33. initAPPListener(){
  34. // #ifdef APP-PLUS
  35. // 原生平台事件监听,等待测试
  36. plus.globalEvent.addEventListener('TestEvent', function(e){
  37. modal.toast({
  38. message: "TestEvent收到:"+e.msg,
  39. duration: 1.5
  40. });
  41. });
  42. // #endif
  43. },
  44. //百度人脸SDK,初始化,并申请授权(授权码写死在android端 faceClass)
  45. faceAsyncFunc() {
  46. console.log("测试开始faceAsyncFunc");
  47. // 调用异步方法
  48. faceModule.faceAsyncFunc({
  49. 'name': 'unimp',
  50. 'age': 1
  51. },
  52. (ret) => {
  53. modal.toast({
  54. message: ret,
  55. duration: 1.5
  56. });
  57. })
  58. },
  59. tcpAsyncFunc(){
  60. // 调用异步方法
  61. zmtModule.tcpAsyncFunc({
  62. 'name': 'unimp',
  63. 'age': 1
  64. },
  65. (ret) => {
  66. modal.toast({
  67. message: ret,
  68. duration: 1.5
  69. });
  70. })
  71. },
  72. testFun2(){
  73. // 调用同步方法
  74. var ret = zmtModule.testSyncFunc({
  75. 'name': 'unimp',
  76. 'age': 1
  77. })
  78. modal.toast({
  79. message: ret,
  80. duration: 1.5
  81. });
  82. },
  83. testAsyncFunc() {
  84. // 调用异步方法
  85. testModule.testAsyncFunc({
  86. 'name': 'unimp',
  87. 'age': 1
  88. },
  89. (ret) => {
  90. modal.toast({
  91. message: ret,
  92. duration: 1.5
  93. });
  94. })
  95. },
  96. testSyncFunc() {
  97. // 调用同步方法
  98. var ret = testModule.testSyncFunc({
  99. 'name': 'unimp',
  100. 'age': 1
  101. })
  102. modal.toast({
  103. message: ret,
  104. duration: 1.5
  105. });
  106. },
  107. testAsyncFunc2() {
  108. // 调用异步方法
  109. uniplugin_module_ox.testAsyncFunc2({
  110. 'name': 'unimp',
  111. 'age': 1
  112. },
  113. (ret) => {
  114. modal.toast({
  115. message: ret,
  116. duration: 1.5
  117. });
  118. })
  119. },
  120. testSyncFunc2() {
  121. // 调用同步方法
  122. var ret = uniplugin_module_ox.testSyncFunc2({
  123. 'name': 'unimp',
  124. 'age': 1
  125. })
  126. modal.toast({
  127. message: ret,
  128. duration: 1.5
  129. });
  130. },
  131. gotoNativePage() {
  132. testModule.gotoNativePage();
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. .content{
  139. // width: 750rpx;
  140. // margin-top: 10rpx;
  141. // display: flex;
  142. // flex-wrap: nowrap;
  143. // align-items: flex-start;
  144. // flex-direction: column;
  145. // justify-content: center;
  146. }
  147. // button{
  148. // margin-top: 3px;
  149. // }
  150. .btn{
  151. margin: 3px;
  152. // width: 95%;
  153. }
  154. .tips{
  155. font-size: 11px;
  156. color: gray;
  157. font-weight: 800;
  158. }
  159. </style>