AndroidJSTest.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. 
  2. (function ($) {
  3. "use strict";
  4. var __name__ = 'AndroidHost',
  5. __version__ = '1.0',
  6. __object__ = function () {
  7. this.Data = {
  8. };
  9. };
  10. __object__.prototype = {
  11. setEvents: function (events) {
  12. this.events = $.extend({
  13. onEvent: function (name, value) {
  14. console.log(name + ':' + value);
  15. }
  16. },
  17. events);
  18. },
  19. setDeviceSerialNumber: function (value) {
  20. this.events.onEvent('onDeviceSerialNumberChanged', value);
  21. },
  22. getDeviceSerialNumber: function () {
  23. if (typeof AndroidHost != 'undefined' && typeof AndroidHost.getDeviceSerialNumber == 'function') {
  24. return AndroidHost.getDeviceSerialNumber();
  25. }
  26. return '';
  27. },
  28. showSysSetting: function () {
  29. if (typeof AndroidHost != 'undefined' && typeof AndroidHost.showSysSetting == 'function') {
  30. AndroidHost.showSysSetting();
  31. }
  32. },
  33. startReadIDCard: function () {
  34. if (typeof AndroidHost != 'undefined' && typeof AndroidHost.startReadIDCard == 'function') {
  35. AndroidHost.startReadIDCard();
  36. }
  37. },
  38. onReceiveIDCard: function (value) {
  39. this.events.onEvent('onReceiveIDCard', value);
  40. },
  41. UpdateAPK: function () {
  42. if (typeof AndroidHost != 'undefined' && typeof AndroidHost.updateAPK == 'function') {
  43. AndroidHost.updateAPK();
  44. }
  45. },
  46. toast: function (msg) {
  47. if (typeof AndroidHost != 'undefined' && typeof AndroidHost.toast == 'function' &&
  48. typeof (msg) == 'string') {
  49. AndroidHost.toast(String(msg));
  50. }
  51. },
  52. };
  53. $[__name__] = new __object__();
  54. })(jQuery);