keydown-SN.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var isManage;
  2. mui.init();
  3. mui.plusReady(function(){
  4. var self = plus.webview.currentWebview();
  5. isManage = self.isManage;
  6. bindEvents();
  7. })
  8. mui.back = function(){
  9. var self = plus.webview.currentWebview(),
  10. opener = self.opener();
  11. mui.fire(opener, "reload");
  12. mui.later(function(){
  13. self.close();
  14. }, 300);
  15. }
  16. function bindEvents(){
  17. $(".radius-input").on("input", function(){
  18. if($(this).prop('comstart')){
  19. return;
  20. }
  21. var text = $.trim($(this).val());
  22. if(text.length > 0){
  23. $(".fa-times-circle").show();
  24. }
  25. }).on('compositionstart', function(){
  26. $(this).prop('comstart', true);
  27. //console.log('中文输入:开始');
  28. }).on('compositionend', function(){
  29. $(this).prop('comstart', false);
  30. // console.log('中文输入:结束');
  31. })
  32. $(".fa-times-circle").on('click', function(){
  33. $(".radius-input").val("");
  34. $(this).hide();
  35. })
  36. $("#nBtn").on('click', function(){
  37. var text = $.trim($(".radius-input").val());
  38. if(text.length == 0){
  39. mui.toast("请输入SN码");
  40. return false;
  41. }
  42. //判断设备是否已经绑定了用户
  43. var b = /^[0-9a-zA-Z]*$/g;
  44. if(!b.test(text)){
  45. mui.toast("对不起,您输入的SN有误,请重新输入");
  46. return false;
  47. }
  48. checkSnBind(text);
  49. })
  50. }
  51. function checkSnBind(code){
  52. plus.nativeUI.showWaiting();
  53. var url = "doctor/device/getDeviceInfoByDeviceSn",
  54. params = {
  55. deviceSn: code,
  56. };
  57. sendGet(url+"?deviceSn="+code, {}, null, function(res){
  58. plus.nativeUI.closeWaiting();
  59. if(res.status == 200){
  60. var isMultiUser = res.data.isMultiUser, //0-只有一个键,1-多个键
  61. bindLength = res.data.bindingInfo.length; //获取绑定信息的长度
  62. if((!isMultiUser && bindLength == 1) || (isMultiUser && bindLength > 1)){
  63. //默认最多只有两个键
  64. dialog({
  65. title: "识别提示",
  66. content: "设备已被绑定,是否更换绑定居民?",
  67. okValue: "是",
  68. ok: function(){
  69. openWebview("device-bind-info.html", {info: res.data, sn: code, isManage: isManage});
  70. },
  71. cancelValue: "否",
  72. cancel: function(){
  73. }
  74. }).showModal();
  75. }else{
  76. openWebview("device-bind-info.html", {info: res.data, sn: code, isManage: isManage});
  77. }
  78. }else{
  79. mui.toast(res.msg);
  80. }
  81. }, true);
  82. }