xiugaisfmima.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 < 17){
  28. changeHover(tag+1);
  29. AddActive(tag,$this.text().trim())
  30. }else if(tag == 17 && !$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<18;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 strOldCalledPasswd = takePassword($ul.eq(0).find('li'));
  67. var strNewCalledPasswd = takePassword($ul.eq(1).find('li'));
  68. var strNewCalledPasswd2 = takePassword($ul.eq(2).find('li'));
  69. if(strNewCalledPasswd == strNewCalledPasswd2){
  70. if(strOldCalledPasswd == strNewCalledPasswd){
  71. plus.nativeUI.closeWaiting();
  72. mui.toast('新密码与旧密码不能一样')
  73. for(var i=6;i<18;i++){
  74. delActive(i)
  75. }
  76. changeHover(6)
  77. }else{
  78. var params = {
  79. strOldCalledPasswd: strOldCalledPasswd,
  80. strNewCalledPasswd: strNewCalledPasswd
  81. }
  82. sendPost('doctor/updateAuthenticationPassword',params,function(){
  83. plus.nativeUI.closeWaiting();
  84. mui.toast('请求超时')
  85. }, function(res){
  86. if(res.status ==200){
  87. plus.nativeUI.closeWaiting();
  88. if(res.data){
  89. mui.toast("修改成功")
  90. mui.back()
  91. }else{
  92. mui.toast(res.msg)
  93. }
  94. }else{
  95. plus.nativeUI.closeWaiting();
  96. mui.toast('旧密码有误')
  97. }
  98. })
  99. }
  100. }else{
  101. plus.nativeUI.closeWaiting();
  102. mui.toast('新密码与确认密码不一样')
  103. for(var i=6;i<18;i++){
  104. delActive(i)
  105. }
  106. changeHover(6)
  107. }
  108. }
  109. })