基础版本
diff --git a/www/js/index.js b/www/js/index.js
new file mode 100644
index 0000000..ba4ea86
--- /dev/null
+++ b/www/js/index.js
@@ -0,0 +1,63 @@
+var app = {
+ /*
+ thirdapp:
+ closeBrowser(){
+ if(history.length==1){
+ window.open('mobile/close');
+ }else{
+ history.back();
+ }
+ }
+ <a href="javascript:;" onclick="closeBrowser()">Close</a>
+
+
+ client:
+ var ref = window.open(encodeURI(url), '_blank','location=no');
+ ref.addEventListener('loadstart', function(event) {
+ if (event.url.match("mobile/close")) {
+ ref.close();
+ }
+ });
+ */
+ // Application Constructor
+ initialize: function() {
+ document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
+ },
+
+ onDeviceReady: function() {
+ var uid = window.localStorage.getItem("token");
+ if (isEmpty(uid)) {
+ window.location = "login.html";
+ } else {
+ //尝试登陆
+ V1Infor(function(ok, ret) {
+ console.log(ret)
+ if (ok) {
+ if(ret.code==200){
+ var exp = window.localStorage.getItem("tokenexpire");
+ var t = parseInt(exp);
+ //token 小于10分钟了,需要刷新
+ console.log((ret.now-t))
+ if(ret.now-t>1000*60*10){
+ window.location = "login.html";
+ }else{
+
+ window.location = "main.html";
+ }
+ }
+ } else {
+ //alert('无法请求到服务器,请检查网络并稍后再试');
+ if (ret.status == 401) {
+ //need login
+ window.location = "login.html";
+ } else {
+ //TODO ,没有网络
+
+ window.location = "main.html";
+ }
+ }
+ })
+ }
+ }
+};
+app.initialize();
\ No newline at end of file