shenfangmima.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. mui.plusReady(function(){
  2. //输入密码
  3. var $ul = $('.bogusInput'),
  4. $main = $('#main'),
  5. $li = $ul.find('li');
  6. function changeHover(num){
  7. $li.removeClass('hover')
  8. $main.find('li').eq(num).addClass('hover')
  9. }
  10. function countAddr(){
  11. var $this = $main.find('li.hover')
  12. return $this.closest('.bogusInput').attr('data-id')*6+$this.index()
  13. }
  14. function delActive(num){
  15. $li.eq(num).removeClass('active');
  16. $li.eq(num).attr('data-val','');
  17. }
  18. function AddActive(num,val){
  19. $li.eq(num).addClass('active');
  20. $li.eq(num).attr('data-val',val)
  21. }
  22. $('.number-pad').on('click','li',function(){
  23. var $this = $(this);
  24. var tag = countAddr();
  25. if(!$this.hasClass('no')){
  26. if(!$this.hasClass('del')){
  27. if(tag < 11){
  28. changeHover(tag+1);
  29. AddActive(tag,$this.text().trim())
  30. }else if(tag == 11 && !$li.eq(tag).hasClass('active')){
  31. changeHover(tag);
  32. AddActive(tag,$this.text().trim())
  33. checkPasswords();
  34. }
  35. }else{
  36. for(var i=tag+1;i<12;i++){
  37. delActive(i)
  38. }
  39. if($li.eq(tag).hasClass('active')){
  40. delActive(tag)
  41. }else if(tag > 0){
  42. delActive(tag-1)
  43. changeHover(tag-1);
  44. }
  45. }
  46. }
  47. })
  48. $main.on('click','.bogusInput',function(){
  49. var $this = $(this);
  50. var num = $this.find('li.active').length;
  51. if(num>0){
  52. changeHover($this.attr('data-id')*6+num-1);
  53. }
  54. })
  55. //提取密码
  56. function takePassword(li){
  57. var str = '';
  58. li.each(function(){
  59. str += $(this).attr('data-val');
  60. })
  61. return str
  62. }
  63. //提交
  64. function checkPasswords(){
  65. plus.nativeUI.showWaiting();
  66. var strNewCalledPasswd = takePassword($ul.eq(0).find('li'));
  67. var strNewCalledPasswd2 = takePassword($ul.eq(1).find('li'));
  68. if(strNewCalledPasswd == strNewCalledPasswd2){
  69. var params = {
  70. strNewCalledPasswd: strNewCalledPasswd
  71. }
  72. sendPost('doctor/installAuthenticationPassword',params,function(){
  73. plus.nativeUI.closeWaiting();
  74. mui.toast('请求超时')
  75. }, function(res){
  76. if(res.status ==200){
  77. plus.nativeUI.closeWaiting();
  78. if(res.data){
  79. mui.toast("设置成功")
  80. closePage()
  81. }else{
  82. mui.toast(res.msg)
  83. }
  84. }else{
  85. plus.nativeUI.closeWaiting();
  86. mui.toast('用户不存在或实名软证书调用保护密码错误')
  87. for(var i=0;i<12;i++){
  88. delActive(i)
  89. }
  90. changeHover(0)
  91. }
  92. })
  93. }else{
  94. plus.nativeUI.closeWaiting();
  95. mui.toast('两次输入不一致')
  96. for(var i=0;i<12;i++){
  97. delActive(i)
  98. }
  99. changeHover(0)
  100. }
  101. }
  102. function closePage(){
  103. var page = plus.webview.getWebviewById("shenfenrenzheng");
  104. if(page){
  105. page.close()
  106. }
  107. var page2 = plus.webview.getWebviewById("cazhengshu");
  108. if(page2){
  109. page2.close()
  110. }
  111. mui.back();
  112. }
  113. })