qiaowei | f044a74 | 2019-07-10 16:04:20 +0800 | [diff] [blame^] | 1 | var app = { |
| 2 | |
| 3 | // Application Constructor |
| 4 | initialize: function() { |
| 5 | document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); |
| 6 | }, |
| 7 | |
| 8 | onDeviceReady: function() { |
| 9 | var uid = window.localStorage.getItem("uid"); |
| 10 | |
| 11 | }, |
| 12 | doRegister: function() { |
| 13 | var pwd = $("#pwd").val(); |
| 14 | var repwd = $("#repwd").val(); |
| 15 | if(isEmpty(pwd)||isEmpty(repwd)){ |
| 16 | return; |
| 17 | } |
| 18 | if(pwd.length<6){ |
| 19 | $.alert("密码至少6位以上字符", "提示"); |
| 20 | return; |
| 21 | } |
| 22 | if(pwd!=repwd){ |
| 23 | $.alert("两次密码不一致,请确认", "提示"); |
| 24 | return; |
| 25 | } |
| 26 | var uid = window.localStorage.getItem("uid"); |
| 27 | var code = window.localStorage.getItem("code"); |
| 28 | $.showLoading("正在保存"); |
| 29 | var param={ |
| 30 | "pwd":pwd, |
| 31 | "repwd":repwd, |
| 32 | "id":uid, |
| 33 | "random":code |
| 34 | } |
| 35 | console.log(param) |
| 36 | IRegister(param,function(ok,ret){ |
| 37 | if(ok){ |
| 38 | $.hideLoading(); |
| 39 | if(ret.code==200){ |
| 40 | window.localStorage.removeItem("code"); |
| 41 | window.localStorage.setItem("phoneX",ret.phone); |
| 42 | window.localStorage.setItem("token",ret.token); |
| 43 | window.localStorage.setItem("userid",ret.userid); |
| 44 | window.localStorage.setItem("tenantid",ret.tenantid); |
| 45 | window.localStorage.setItem("tokenexpire",ret.expire); |
| 46 | window.localStorage.setItem("tokentime",ret.now); |
| 47 | window.localStorage.setItem("signed",ret.signed); |
| 48 | window.localStorage.setItem("paypwdset",ret.paypwdset); |
| 49 | $.alert("密码设置成功,您可以登录系统了", "提示", function() { |
| 50 | window.location = "main.html"; |
| 51 | }); |
| 52 | }else{ |
| 53 | $.alert(ret.msg, "错误"); |
| 54 | } |
| 55 | }else{ |
| 56 | $.hideLoading(); |
| 57 | $.alert("请求失败了"+ret.status+",请稍后再试", "错误"); |
| 58 | } |
| 59 | }) |
| 60 | } |
| 61 | }; |
| 62 | app.initialize(); |