签约流程,指纹登录
diff --git a/www/js/bindcard.js b/www/js/bindcard.js
index f7e91a2..7af7d38 100644
--- a/www/js/bindcard.js
+++ b/www/js/bindcard.js
@@ -81,9 +81,15 @@
                     window.localStorage.setItem("idno", idno);
                     window.localStorage.setItem("phoneX",ret.phonex);
                     window.localStorage.setItem("personid", ret.personid);
+                    window.localStorage.setItem("userid", ret.personid);
                     window.localStorage.setItem("signed", ret.signed);
                     window.localStorage.setItem("paypwdset", ret.paypwdset);
-                    window.location = "bindcheck.html";
+                    if(ret.signed=='yes'){
+                        window.location = "main.html"
+                    }else{
+                        window.location = "bindcheck.html";
+                    }
+                    
                 } else {
                     if (ret.code == -1) {
                         $.alert(ret.msg, "提示", function() {
diff --git a/www/js/bindcheck.js b/www/js/bindcheck.js
index 32dba4c..8862e73 100644
--- a/www/js/bindcheck.js
+++ b/www/js/bindcheck.js
@@ -18,19 +18,10 @@
         btnTime('codebtn');
     },
     getCode: function() {
-        var name = window.localStorage.getItem("name");
-        var cardno = window.localStorage.getItem("cardno");
-        var idtype = window.localStorage.getItem("idtype");
-        var idno = window.localStorage.getItem("idno");
-
         $.showLoading("正在请求");
         var param = {
-            "cardno": cardno,
-            "idtype": idtype,
-            "name": name,
-            "idno": idno
         }
-        V1Bindcard(param, function(ok, ret) {
+        V1Bindcardcode(param, function(ok, ret) {
             if (ok) {
                 $.hideLoading();
                 if (ret.code == 200) {
@@ -57,37 +48,27 @@
         if(isEmpty(code)){
             return;
         }
-        var personid = window.localStorage.getItem("personid");
+        var agree = $("input[type=checkbox]:checked").val();
+        if(isEmpty(agree)){
+            $.alert("请同意市民卡免密代扣签约协议", "提示");
+            return;
+        }
         $.showLoading("正在处理");
         var param={
-            "personid":personid,
-            "code":code,
+            "agree":code
         }
-        V1Checkcode(param,function(ok,ret){
-            if(ok){
-                $.hideLoading();
-                console.log(ret)
+        V1Signbxy(param,function(ok, ret, err) {
+            if (ok) {
+                $.hideLoading(); 
                 if(ret.code==200){
-                    window.localStorage.setItem("paypwdtype", "new");
-                    window.localStorage.setItem("userid", personid);
-                    var signed =  window.localStorage.getItem("signed");
-                    var paypwdset =  window.localStorage.getItem("paypwdset");
-                    console.log(paypwdset)
-                    if (!paypwdset||'false'==paypwdset) {
-                        window.location = "paypwdset.html";
-                    } else {
-                        if (!isEmpty(signed) && signed == 'yes') {
-                            window.location = 'main.html'
-                        } else {
-                            window.location = 'signxy.html'
-                        }
-                    }
+                    window.localStorage.setItem("signed",ret.signed); 
+                    window.location="main.html";
                 }else{
-                     $.alert(ret.msg, "错误");
-                } 
-            }else{
+                    $.alert(ret.msg, "错误");
+                }
+            } else {
                 $.hideLoading();
-                $.alert("请求失败了"+ret.status+",请稍后再试", "错误");
+                $.alert("请求失败了:" + ret.status+"请稍后再试", "错误");
             }
         })
     }
diff --git a/www/js/login.js b/www/js/login.js
index 7931a48..88950f3 100644
--- a/www/js/login.js
+++ b/www/js/login.js
@@ -7,6 +7,29 @@
   
     onDeviceReady: function() {
         this.receivedEvent('deviceready');
+        this.loginWithFinger();
+    },
+    loginWithFinger:function(){
+        let loginfinger =  window.localStorage.getItem("loginfinger");
+        let phone =  window.localStorage.getItem("phone");
+        let pwd =  window.localStorage.getItem("localpwd");
+        let _this = this;
+        if(phone&&pwd&&loginfinger&&loginfinger=='1'){
+              Fingerprint.isAvailable(function(result){
+                 Fingerprint.show({
+                       title:"正在使用指纹或人脸登录",
+                       description: "请验证您的指纹或人脸"
+                     }, function(success){
+                        _this.loginIt(phone,pwd);
+                     }, function(error){
+                       $.alert("验证失败,指纹或人脸错误,请使用密码登录", "提示");
+                       //$("#login").removeAttr("checked");
+                     });
+
+             }, function(message){
+                  $.alert("设备不支持指纹或人脸,请使用密码登录", "提示");
+             });
+        }
     },
 
     // Update DOM on a Received Event
@@ -29,7 +52,9 @@
         if(isEmpty(phone)||isEmpty(pwd)){
             return;
         }
-        //loadingElement('loginBtn', '登录中...')
+        this.loginIt(phone,pwd);
+    },
+    loginIt: function(phone,pwd){
         $.showLoading("登录中");
         var param={
             "username":phone,
@@ -56,6 +81,7 @@
                  window.localStorage.setItem("signed",ret.signed); 
                  window.localStorage.setItem("paypwdset",ret.paypwdset); 
                  window.localStorage.setItem("name",ret.name);  
+                 window.localStorage.setItem("localpwd",pwd);  
                  window.location = "main.html";  
                }     
             }else{
diff --git a/www/js/main.js b/www/js/main.js
index bc93d91..78b896f 100644
--- a/www/js/main.js
+++ b/www/js/main.js
@@ -111,6 +111,25 @@
                 })
             })
         });
+        $('#accsignbtn').click(function() {
+            app.checkBefore(function() {
+                var signed = window.localStorage.getItem("signed");
+                var cum = new auiDialog({});
+                 if (isEmpty(signed) || signed != 'yes') {
+                    var confirm = cum.alert({
+                        title: "提示",
+                        msg: '您尚未签约市民卡免密代扣签约协议,无法使用该功能',
+                        buttons: ['取消', '去签约']
+                    }, function(ret) {
+                        if (ret.buttonIndex == 2) {
+                           app.toSignCode();
+                        }
+                    })
+                }else{
+                    window.location = 'signxycheck.html'
+                }
+            })
+        });
         this.initData();
         this.backBtn();
     },
@@ -153,13 +172,15 @@
         $("#loaddata").show()
         $("#nodata").hide();
         var param = {
-            "pageno": 1
+            "pageno": 1,
+            "platform":device.platform
         }
         V1Bills(param, function(ok, ret) {
             if (ok) {
-                //console.log(ret)
+                console.log(ret)
                 if (ret.code == 200) {
-                    app.checkVersion(ret.version,ret.minversion,ret.versionmsg);
+                    app.checkVersion(ret.version,ret.minversion,ret.versionmsg,ret.versionurl);
+                    //app.checkVersion("1.3.9","1","new func","https://shouji.baidu.com/software/26706357.html");
                     $("#maingt").text(ret.t + "!")
                     $("#user-amount").text(ret.amount)
                     $("#user-point").text(ret.point)
@@ -196,14 +217,21 @@
             }
         })
     },
-    checkVersion:function(ver,minver,msg){
+    checkVersion:function(ver,minver,m,url){
         cordova.getAppVersion.getVersionNumber(function (version) {
             //alert(version);
-            if(version<minver){
-                //TODO 强制升级
-                alert("当前版本过低,为了不影响您的使用,请先升级");
-            }else if(ver>version){
-                alert("有新的版本");    
+            //alert(version);
+            if(ver>version){
+                var cum = new auiDialog({});
+                var confirm = cum.alert({
+                    title: "有新的版本",
+                    msg: m,
+                    buttons: ['取消', '去更新']
+                }, function(ret) {
+                    if (ret.buttonIndex == 2) {
+                       cordova.InAppBrowser.open(url, '_system', 'location=no,toolbar=yes,toolbarposition=top,closebuttoncaption=关闭');
+                    }
+                })  
             }
         });
     },
@@ -282,38 +310,40 @@
         }
     },
     checkOther: function(callback) {
-        var payseted = window.localStorage.getItem("paypwdset");
         var signed = window.localStorage.getItem("signed");
         var cum = new auiDialog({});
-        console.log(payseted, signed)
-        if (isEmpty(payseted) || !payseted || payseted != 'true') {
+
+        if (isEmpty(signed) || signed != 'yes') {
             var confirm = cum.alert({
                 title: "提示",
-                msg: '您还没有设置支付密码,无法使用该功能',
-                buttons: ['取消', '去设置']
+                msg: '您尚未签约市民卡免密代扣签约协议,无法使用该功能',
+                buttons: ['取消', '去签约']
             }, function(ret) {
                 if (ret.buttonIndex == 2) {
-                    window.location = 'paypwdset.html'
+                   app.toSignCode();
                 }
             })
         } else {
-            if (isEmpty(signed) || signed != 'yes') {
-                var confirm = cum.alert({
-                    title: "提示",
-                    msg: '您尚未签约代扣免密付协议,无法使用该功能',
-                    buttons: ['取消', '去签约']
-                }, function(ret) {
-                    if (ret.buttonIndex == 2) {
-                        window.location = 'signxy.html'
-                    }
-                })
-            } else {
-                if (callback) {
-                    callback()
-                }
+            if (callback) {
+                callback()
             }
         }
     },
+    toSignCode: function(){
+        var param = {
+        }
+        V1Bindcardcode(param, function(ok, ret) {
+            if (ok) {
+                if (ret.code == 200) {
+                    window.location = 'bindcheck.html'
+                } else {
+                    $.alert(ret.msg, "错误");
+                }
+            } else {
+                $.alert("请求失败了 " + ret.status + ",请稍后再试", "错误");
+            }
+        })
+    },
     toSign: function() {
         window.location = 'signxycheck.html'
     },
diff --git a/www/js/qrcode.js b/www/js/qrcode.js
index b9d81b9..51b2aa1 100644
--- a/www/js/qrcode.js
+++ b/www/js/qrcode.js
@@ -22,6 +22,10 @@
             console.log(err);
           });
         }
+        document.addEventListener("backbutton", function(e){
+               e.preventDefault();
+               app.backTo();
+            }, false);
     },
     loadQrcode: function() {
         $.showLoading("加载中");
@@ -62,6 +66,7 @@
             if (ok) {
                 if (ret.code == 200) {
                     $.hideLoading();
+                    $("#qrcode").html('');
                     var qrcode = new QRCode(document.getElementById("qrcode"), {
                       text: ret.qrcode,
                       width: 200,
diff --git a/www/js/security.js b/www/js/security.js
index dd5475d..d159a40 100644
--- a/www/js/security.js
+++ b/www/js/security.js
@@ -5,23 +5,68 @@
         document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
     },
     onDeviceReady: function() {
+      let loginfinger =  window.localStorage.getItem("loginfinger");
+       if(loginfinger&&loginfinger=='1'){
+        $("#login").prop("checked","checked");
+       }
     },
     editPwd: function() {
        window.location = "editpwd.html";
     },
     toPayPwd: function() {
-       window.location = "paypwdmng.html";
+      var payseted = window.localStorage.getItem("paypwdset");
+      if (isEmpty(payseted) || !payseted || payseted != 'true') {
+          window.location = 'paypwdset.html'
+      } else{
+        window.location = "paypwdmng.html";
+      }
     },
     logout:function(){
         window.localStorage.removeItem("token");
         window.location = "login.html";
     },
     loginByTouchId: function() {
-       Fingerprint.isAvailable(function(result){
-            $.alert("设备不支持指纹", "提示");
-       }, function(message){
-            alert(message);
-       });
+       let loginfinger =  window.localStorage.getItem("loginfinger");
+       if(loginfinger&&loginfinger=='1'){
+          var confirm = new auiDialog({}).alert({
+                title: "提示",
+                msg: '确定关闭指纹或人脸登录吗?',
+                buttons: ['取消', '确定']
+            }, function(ret) {
+                if (ret.buttonIndex == 2) {
+                    window.localStorage.setItem("loginfinger","0");
+                    $("#login").removeAttr("checked");
+                }else{
+                  //$("#login").attr("checked","checked");
+                }
+               });
+       }else{
+        let pwd =  window.localStorage.getItem("localpwd");
+        if(!pwd){
+          $.alert("长时间未登录,需要先登录后再使用该功能", "提示",function(){
+             window.localStorage.removeItem("token");
+             window.location = "login.html";
+          });
+          return;
+        }
+         $("#login").removeAttr("checked");
+         Fingerprint.isAvailable(function(result){
+             Fingerprint.show({
+                   title:"大理市民卡开启指纹或人脸登录",
+                   description: "请验证您的指纹或人脸"
+                 }, function(success){
+                    window.localStorage.setItem("loginfinger","1");
+                    $.alert("验证成功,您已开启指纹或人脸登录", "提示");
+                    $("#login").prop("checked","checked");
+                 }, function(error){
+                   $.alert("验证失败,指纹或人脸错误次数过多,请稍后再试", "提示");
+                   //$("#login").removeAttr("checked");
+                 });
+
+         }, function(message){
+              $.alert("设备不支持指纹或人脸", "提示");
+         });
+       }
     }
 };
 app.initialize();
diff --git a/www/js/server.js b/www/js/server.js
index 3e8ae05..426bf2d 100644
--- a/www/js/server.js
+++ b/www/js/server.js
@@ -1,4 +1,4 @@
-var dev = true;
+var dev = false;
 var SERVER = "https://yy.dlsmk.cn/payapi/mobileapi";
 var DOOR_URl = "https://yy.dlsmk.cn/door/app/appMintUIindex";//门禁服务地址
 var GLOBAL_TODAY="";
@@ -7,6 +7,10 @@
 if (dev) {
     SERVER = "http://172.28.43.7:8099/payapi/mobileapi";
 }
+function V1Bindcardcode(param,callback) {
+    ajaxPost("/v1/bindcardcode", param, callback)
+}
+
 function V1Unbindcard(param,callback){
     ajaxPost("/v1/unbindcard", param, callback)
 }
diff --git a/www/js/signxy.js b/www/js/signxy.js
index f97f3d4..4ee8598 100644
--- a/www/js/signxy.js
+++ b/www/js/signxy.js
@@ -14,10 +14,10 @@
                 if(ret.code==200){
                     $("#content").html(ret.page);
                     if(isEmpty(ret.signed)||ret.signed!='yes'){
-                        $("#btn").show();   
-                        $("#content").css("bottom","135px");
+                        //$("#btn").show();   
+                        //$("#content").css("bottom","135px");
                     }else{
-                        $("#content").css("bottom","10px");
+                        //$("#content").css("bottom","10px");
                     }
                 }else{
                     $.alert(ret.msg, "错误");
diff --git a/www/js/unsignedcheck.js b/www/js/unsignedcheck.js
new file mode 100644
index 0000000..ce72038
--- /dev/null
+++ b/www/js/unsignedcheck.js
@@ -0,0 +1,71 @@
+var dict;
+var app = {
+
+    // Application Constructor
+    initialize: function() {
+        document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
+    },
+    onDeviceReady: function() {
+        var phone = window.localStorage.getItem("phoneX");
+        if(!isEmpty(phone)){
+            $("#phone").text(phone)
+        }else{
+            phone =  window.localStorage.getItem("phone");
+            $("#phone").text(phone)
+        }
+        app.getCode();
+    },
+    getCode: function() {
+        $.showLoading("正在请求");
+        var param = {
+        }
+        V1Bindcardcode(param, function(ok, ret) {
+            if (ok) {
+                $.hideLoading();
+                if (ret.code == 200) {
+                   $("#codebtn").attr("disabled","disabled")
+                   $("#codebtn").addClass("vcodedisabled")
+                   btnTime('codebtn');
+                } else {
+                    if (ret.code == -1) {
+                        $.alert(ret.msg, "提示", function() {
+                            window.location = "main.html"
+                        });
+                    } else {
+                        $.alert(ret.msg, "错误");
+                    }
+                }
+            } else {
+                $.hideLoading();
+                $.alert("请求失败了 " + ret.status + ",请稍后再试", "错误");
+            }
+        })
+    },
+    doNext: function() {
+        var code =  $("#code").val();
+        if(isEmpty(code)){
+            return;
+        }
+        $.showLoading("正在处理");
+        var param={
+            "code":code
+        }
+        V1UnSignbxy(param, function(ok, ret, err) {
+            if (ok) {
+                $.hideLoading();
+                if (ret.code == 200) {
+                    window.localStorage.setItem("signed", ret.signed);
+                    $.alert('解除成功', "提示", function() {
+                        window.location = 'main.html'
+                    });
+                } else {
+                    $.alert(ret.msg, "错误");
+                }
+            } else {
+                $.hideLoading();
+                $.alert("请求失败了:" + ret.status + "请稍后再试", "错误");
+            }
+        })
+    }
+};
+app.initialize();
\ No newline at end of file