零售收银终端CheckoutPad_ox_as
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.

51 lines
1.1 KiB

1 year ago
  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. </div>
  7. </template>
  8. <script>
  9. // 获取 module
  10. var testModule = uni.requireNativePlugin("TestModule")
  11. const modal = uni.requireNativePlugin('modal');
  12. export default {
  13. onLoad() {
  14. plus.globalEvent.addEventListener('TestEvent', function(e){
  15. modal.toast({
  16. message: "TestEvent收到:"+e.msg,
  17. duration: 1.5
  18. });
  19. });
  20. },
  21. methods: {
  22. testAsyncFunc() {
  23. // 调用异步方法
  24. testModule.testAsyncFunc({
  25. 'name': 'unimp',
  26. 'age': 1
  27. },
  28. (ret) => {
  29. modal.toast({
  30. message: ret,
  31. duration: 1.5
  32. });
  33. })
  34. },
  35. testSyncFunc() {
  36. // 调用同步方法
  37. var ret = testModule.testSyncFunc({
  38. 'name': 'unimp',
  39. 'age': 1
  40. })
  41. modal.toast({
  42. message: ret,
  43. duration: 1.5
  44. });
  45. },
  46. gotoNativePage() {
  47. testModule.gotoNativePage();
  48. }
  49. }
  50. }
  51. </script>