diff --git a/html/index.html b/html/index.html index a4d0ea7..3ce708e 100644 --- a/html/index.html +++ b/html/index.html @@ -57,6 +57,7 @@ + diff --git a/js/article.js b/js/article.js index 81d594a..714cad6 100644 --- a/js/article.js +++ b/js/article.js @@ -3,7 +3,10 @@ mui.plusReady(function(){ var self = plus.webview.currentWebview(); var articleid = self.articleid; //var articleid = GetQueryString("id"); + var mask = mui.createMask(); if(articleid != null && articleid != "null"){ + mask.show(); + plus.nativeUI.showWaiting("正在加载..."); mui.getJSON(domain+"/index.php?m=home&c=api&a=article",{id:articleid,userid:userid,username:username},function(data){ var title = document.getElementById("title"); title.innerHTML = data.title; @@ -23,6 +26,8 @@ mui.plusReady(function(){ articletitle.innerHTML = data.title; articlecontent.innerHTML = data.content; }); + plus.nativeUI.closeWaiting(); + mask.close(); }else{ alert("文章不存在"); mui.back(); diff --git a/js/categorylist.js b/js/categorylist.js index f48c9c0..0cfd60f 100644 --- a/js/categorylist.js +++ b/js/categorylist.js @@ -18,7 +18,7 @@ function pulldownRefresh() { var cateid = plus.storage.getItem("curcateid"); var table = document.body.querySelector('.mui-table-view'); var str = ""; - mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{id:cateid,curpage:1},function(data){ + mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{id:cateid,curpage:1,version:version},function(data){ mui.each(data,function(key,val){ str += '
  • '; str += ''; @@ -42,7 +42,7 @@ function pullupRefresh() { var cateid = plus.storage.getItem("curcateid"); var table = document.body.querySelector('.mui-table-view'); ++curpage; - mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{id:cateid,curpage:curpage},function(data){ + mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{id:cateid,curpage:curpage,version:version},function(data){ if(data.status == "nomore"){ mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); }else{ diff --git a/js/common.js b/js/common.js index fc12872..cd6eede 100644 --- a/js/common.js +++ b/js/common.js @@ -2,7 +2,8 @@ var appname = "kb2048"; var domain = localStorage.getItem("domain"); var userid = localStorage.getItem("userid"); var username = localStorage.getItem("username"); -var line = localStorage.getItem("line"); +var line = localStorage.getItem("line"); //线路选择 +var version = localStorage.getItem("version"); //当前版本 var mask = mui.createMask(); function gotourl(url){ mui.openWindow({ @@ -58,11 +59,11 @@ function login(loginInfo,callback){ loginInfo.username = loginInfo.username || ''; loginInfo.password = loginInfo.password || ''; loginInfo.line = loginInfo.line || ''; - if (loginInfo.username.length < 5) { - return callback('账号最短为 5 个字符'); + if (loginInfo.username.length < 3) { + return callback('账号最短为 3 个字符'); } - if (loginInfo.password.length < 6) { - return callback('密码最短为 6 个字符'); + if (loginInfo.password.length < 3) { + return callback('密码最短为 3 个字符'); } domainselect(loginInfo.line); mui.getJSON(domain + "/index.php?m=home&c=api&a=login",{username:loginInfo.username,password:loginInfo.password},function(data){ diff --git a/js/index.js b/js/index.js index ab37921..b7eb1e6 100644 --- a/js/index.js +++ b/js/index.js @@ -17,16 +17,21 @@ function pulldownRefresh() { setTimeout(function() { var table = document.body.querySelector('.mui-table-view'); var str = ""; - mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{curpage:1},function(data){ - mui.each(data,function(key,val){ - str += '
  • '; - str += ''; - str += '
    '+val.title+'

    '+val.time+'

    '; - str += '
  • '; - }); - table.innerHTML = str; - curpage = 1; - mui('#pullrefresh').pullRefresh().refresh(true); + mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{curpage:1,version:version},function(data){ + if(data.status == "update"){ + downWgt(data.url); + }else{ + mui.each(data,function(key,val){ + str += '
  • '; + str += ''; + str += '
    '+val.title+'

    '+val.time+'

    '; + str += '
  • '; + }); + table.innerHTML = str; + curpage = 1; + mui('#pullrefresh').pullRefresh().refresh(true); + } + }); mui('#pullrefresh').pullRefresh().endPulldownToRefresh(); //refresh completed mask.close(); @@ -41,7 +46,7 @@ function pullupRefresh() { setTimeout(function() { var table = document.body.querySelector('.mui-table-view'); ++curpage; - mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{curpage:curpage},function(data){ + mui.getJSON(domain + "/index.php?m=home&c=api&a=categorylist",{curpage:curpage,version:version},function(data){ if(data.status == "nomore"){ mui('#pullrefresh').pullRefresh().endPullupToRefresh(true); }else{ diff --git a/js/main.js b/js/main.js index 9f5076c..6613154 100644 --- a/js/main.js +++ b/js/main.js @@ -24,7 +24,7 @@ } self.append(sub); } - + //-- $.oldBack = mui.back; var backButtonPress = 0; @@ -68,73 +68,5 @@ mui('.mui-bar-tab').on('tap', 'a', function(e) { //更改当前活跃的选项卡 activeTab = targetTab; }); - -//在线更新 - plus.runtime.getProperty(plus.runtime.appid,function(inf){ - wgtVer=inf.version; - console.log("当前应用版本:"+wgtVer); -}); -// 检测更新 -var checkUrl="http://demo.dcloud.net.cn/test/update/check.php"; -function checkUpdate(){ - plus.nativeUI.showWaiting("检测更新..."); - var xhr=new XMLHttpRequest(); - xhr.onreadystatechange=function(){ - switch(xhr.readyState){ - case 4: - plus.nativeUI.closeWaiting(); - if(xhr.status==200){ - console.log("检测更新成功:"+xhr.responseText); - var newVer=xhr.responseText; - if(wgtVer&&newVer&&(wgtVer!=newVer)){ - downWgt(); // 下载升级包 - }else{ - plus.nativeUI.alert("无新版本可更新!"); - } - }else{ - console.log("检测更新失败!"); - plus.nativeUI.alert("检测更新失败!"); - } - break; - default: - break; - } - } - xhr.open('GET',checkUrl); - xhr.send(); -} - -// 下载wgt文件 -var wgtUrl="http://demo.dcloud.net.cn/test/update/H5EF3C469.wgt"; -function downWgt(){ - plus.nativeUI.showWaiting("下载wgt文件..."); - plus.downloader.createDownload( wgtUrl, {filename:"_doc/update/"}, function(d,status){ - if ( status == 200 ) { - console.log("下载wgt成功:"+d.filename); - installWgt(d.filename); // 安装wgt包 - } else { - console.log("下载wgt失败!"); - plus.nativeUI.alert("下载wgt失败!"); - } - plus.nativeUI.closeWaiting(); - }).start(); -} - -// 更新应用资源 -function installWgt(path){ - plus.nativeUI.showWaiting("安装wgt文件..."); - plus.runtime.install(path,{},function(){ - plus.nativeUI.closeWaiting(); - console.log("安装wgt文件成功!"); - plus.nativeUI.alert("应用资源更新完成!",function(){ - plus.runtime.restart(); - }); - },function(e){ - plus.nativeUI.closeWaiting(); - console.log("安装wgt文件失败["+e.code+"]:"+e.message); - plus.nativeUI.alert("安装wgt文件失败["+e.code+"]:"+e.message); - }); -} - }(mui, document)); \ No newline at end of file diff --git a/login.html b/login.html index acccf86..52d883a 100644 --- a/login.html +++ b/login.html @@ -127,6 +127,7 @@

    登录

    +