123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- mui.plusReady(function(){
- //输入密码
- var $ul = $('.bogusInput'),
- $main = $('#main'),
- $li = $ul.find('li');
-
- function changeHover(num){
- $li.removeClass('hover')
- $main.find('li').eq(num).addClass('hover')
- }
- function countAddr(){
- var $this = $main.find('li.hover')
- return $this.closest('.bogusInput').attr('data-id')*6+$this.index()
- }
- function delActive(num){
- $li.eq(num).removeClass('active');
- $li.eq(num).attr('data-val','');
- }
- function AddActive(num,val){
- $li.eq(num).addClass('active');
- $li.eq(num).attr('data-val',val)
- }
- $('.number-pad').on('click','li',function(){
- var $this = $(this);
- var tag = countAddr();
- if(!$this.hasClass('no')){
- if(!$this.hasClass('del')){
- if(tag < 17){
- changeHover(tag+1);
- AddActive(tag,$this.text().trim())
- }else if(tag == 17 && !$li.eq(tag).hasClass('active')){
- changeHover(tag);
- AddActive(tag,$this.text().trim())
- checkPasswords();
- }
- }else{
- for(var i=tag+1;i<18;i++){
- delActive(i)
- }
- if($li.eq(tag).hasClass('active')){
- delActive(tag)
- }else if(tag > 0){
- delActive(tag-1)
- changeHover(tag-1);
- }
- }
- }
- })
-
- $main.on('click','.bogusInput',function(){
- var $this = $(this);
- var num = $this.find('li.active').length;
- if(num>0){
- changeHover($this.attr('data-id')*6+num-1);
- }
- })
-
- //提取密码
- function takePassword(li){
- var str = '';
- li.each(function(){
- str += $(this).attr('data-val');
- })
- return str
- }
- //提交
- function checkPasswords(){
- plus.nativeUI.showWaiting();
- var strOldCalledPasswd = takePassword($ul.eq(0).find('li'));
- var strNewCalledPasswd = takePassword($ul.eq(1).find('li'));
- var strNewCalledPasswd2 = takePassword($ul.eq(2).find('li'));
-
- if(strNewCalledPasswd == strNewCalledPasswd2){
- if(strOldCalledPasswd == strNewCalledPasswd){
- plus.nativeUI.closeWaiting();
- mui.toast('新密码与旧密码不能一样')
- for(var i=6;i<18;i++){
- delActive(i)
- }
- changeHover(6)
- }else{
- var params = {
- strOldCalledPasswd: strOldCalledPasswd,
- strNewCalledPasswd: strNewCalledPasswd
- }
- sendPost('doctor/updateAuthenticationPassword',params,function(){
- plus.nativeUI.closeWaiting();
- mui.toast('请求超时')
- }, function(res){
- if(res.status ==200){
- plus.nativeUI.closeWaiting();
- if(res.data){
- mui.toast("修改成功")
- mui.back()
- }else{
- mui.toast(res.msg)
- }
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast('旧密码有误')
- }
- })
- }
- }else{
- plus.nativeUI.closeWaiting();
- mui.toast('新密码与确认密码不一样')
- for(var i=6;i<18;i++){
- delActive(i)
- }
- changeHover(6)
- }
- }
- })
-
-
-
|