修改绑定功能
diff --git a/www/js/bindcard.js b/www/js/bindcard.js
index 53ac0cf..e9cb86c 100644
--- a/www/js/bindcard.js
+++ b/www/js/bindcard.js
@@ -1,25 +1,58 @@
+var dict;
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
-
+
onDeviceReady: function() {
var uid = window.localStorage.getItem("uid");
- var phone = window.localStorage.getItem("phoneX");
- if(!isEmpty(phone)){
- $("#phone").val(phone)
- }else{
- phone = window.localStorage.getItem("phone");
- $("#phone").val(phone)
- }
+ this.loadData();
+ },
+ loadData: function() {
+ $.showLoading("正在加载");
+ V1Idtypes(function(ok, ret) {
+ if (ok) {
+ $.hideLoading();
+ if (ret.code == 200) {
+ dict = ret.idtypes;
+ let keys = Object.keys(dict);
+ let vals = Object.values(dict);
+ console.log(keys, vals)
+ var items=[];
+ for(var key of keys){
+ var bean = {
+ "title":dict[key],
+ "value":key
+ }
+ items.push(bean)
+ }
+ $("#idtype").val(items[0].title)
+ $("#idtype").attr("data-values",items[0].value)
+ $("#idtype").select({
+ title: "请选择证件类型",
+ items: items
+ });
+ } else {
+ $.alert(ret.msg, "错误");
+ }
+ } else {
+ $.hideLoading();
+ $.alert("请求失败了 " + ret.status + ",请稍后再试", "错误");
+ }
+ })
},
doNext: function() {
- var code = $("#code").val();
- var cardnum = $("#cardnum").val();
- var name = $("#name").val();
- if(isEmpty(name)||isEmpty(code)||isEmpty(cardnum)){
+ var cardnum = $("#cardnum").val();
+ var name = $("#name").val();
+ var idno = $("#idno").val();
+ if (isEmpty(name) || isEmpty(cardnum)||isEmpty(idno)) {
+ return;
+ }
+ var idtype = $("#idtype").attr("data-values")
+ if(isEmpty(idtype)){
+ $.alert("请选择证件类型", "错误");
return;
}
/*var agree = $("input[type=checkbox]:checked").val();
@@ -28,62 +61,37 @@
return;
}*/
$.showLoading("正在处理");
- var param={
- "card":cardnum,
- "code":code,
- "name":name
+ var param = {
+ "cardno": cardnum,
+ "idtype": idtype,
+ "name": name,
+ "idno": idno
}
- V1Bindcard(param,function(ok,ret){
- if(ok){
+ V1Bindcard(param, function(ok, ret) {
+ if (ok) {
$.hideLoading();
console.log(ret)
- if(ret.code==200){
- window.localStorage.setItem("paypwdtype","new");
- window.localStorage.setItem("userid",ret.userid);
- window.localStorage.setItem("signed",ret.signed);
- window.localStorage.setItem("name",name);
- window.localStorage.setItem("paypwdset",ret.paypwdset);
- if(ret.paypwdset){
- if(!isEmpty(ret.signed)&&signed=='yes'){
- window.location='main.html'
- }else{
- window.location='signxy.html'
- }
- }else{
- window.location="paypwdset.html";
- }
- }else{
- if(ret.code==-1){
- $.alert(ret.msg, "提示",function(){
- window.location="main.html"
+ if (ret.code == 200) {
+ window.localStorage.setItem("phoneX",ret.phonex);
+ window.localStorage.setItem("name", name);
+ window.localStorage.setItem("personid", ret.personid);
+ window.localStorage.setItem("signed", ret.signed);
+ window.localStorage.setItem("paypwdset", ret.paypwdset);
+ window.location = "bindcheck.html";
+ } else {
+ if (ret.code == -1) {
+ $.alert(ret.msg, "提示", function() {
+ window.location = "main.html"
});
- }else{
- $.alert(ret.msg, "错误");
+ } else {
+ $.alert(ret.msg, "错误");
}
- }
- }else{
+ }
+ } else {
$.hideLoading();
- $.alert("请求失败了 "+ret.status+",请稍后再试", "错误");
- }
- })
- },
- getCode :function(){
- $.showLoading("请求中");
- V1Code(function(ok,ret){
- if(ok){
- $.hideLoading();
- if(ret.code==200){
- $("#codebtn").attr("disabled","disabled")
- $("#codebtn").addClass("vcodedisabled")
- btnTime('codebtn');
- }else{
- $.alert(ret.msg, "错误");
- }
- }else{
- $.hideLoading();
- $.alert("请求失败了"+ret.status+",请稍后再试", "错误");
+ $.alert("请求失败了 " + ret.status + ",请稍后再试", "错误");
}
})
}
};
-app.initialize();
+app.initialize();
\ No newline at end of file