解决安卓扫码问题
diff --git a/www/billdetail.html b/www/billdetail.html
index e419a98..8289dbf 100644
--- a/www/billdetail.html
+++ b/www/billdetail.html
@@ -16,7 +16,7 @@
<body>
<header class="aui-bar aui-bar-nav" style="padding-top:25px;">
- <a class="aui-pull-left" href="javascript:window.history.go(-1)">
+ <a class="aui-pull-left" href="javascript:app.toBack();">
<span class="aui-iconfont aui-icon-left"></span>
</a>
<div class="aui-title">账单详情</div>
diff --git a/www/js/billdetail.js b/www/js/billdetail.js
index 3615234..51579aa 100644
--- a/www/js/billdetail.js
+++ b/www/js/billdetail.js
@@ -9,7 +9,8 @@
this.loadBill()
},
toBack: function (){
- window.history.back();
+ //window.history.back();
+ window.history.go(-1)
},
loadBill: function() {
var refno = window.localStorage.getItem("currentrefno");
diff --git a/www/js/index.js b/www/js/index.js
index fe23a8d..db3d7ce 100644
--- a/www/js/index.js
+++ b/www/js/index.js
@@ -22,9 +22,6 @@
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
- document.addEventListener('jpush.receiveRegistrationId', function (event) {
- console.log(event.registrationId)
- }, false)
},
onDeviceReady: function() {
@@ -37,15 +34,10 @@
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";
+ if(!isEmpty(ret.token)){
+ window.localStorage.setItem("token",ret.token);
}
+ window.location = "main.html";
}else{
window.location = "login.html";
}
diff --git a/www/js/login.js b/www/js/login.js
index 77b8b2a..7931a48 100644
--- a/www/js/login.js
+++ b/www/js/login.js
@@ -33,7 +33,8 @@
$.showLoading("登录中");
var param={
"username":phone,
- "password":pwd
+ "password":pwd,
+ "platform":device.platform
}
Login(param,function(ok,ret){
console.log(ret)
@@ -47,6 +48,7 @@
window.localStorage.setItem("phone",phone);
window.localStorage.setItem("phoneX",ret.phone);
window.localStorage.setItem("token",ret.token);
+ window.localStorage.setItem("uid",ret.uid);
window.localStorage.setItem("tenantid",ret.tenantid);
window.localStorage.setItem("tokenexpire",ret.expire);
window.localStorage.setItem("tokentime",ret.now);
diff --git a/www/js/main.js b/www/js/main.js
index 3b01a2a..90977da 100644
--- a/www/js/main.js
+++ b/www/js/main.js
@@ -4,11 +4,61 @@
initialize: function() {
this.initTab();
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
+ document.addEventListener('jpush.receiveRegistrationId', function(event) {
+ console.log(event.registrationId)
+ }, false)
+ document.addEventListener("jpush.openNotification", function (event) {
+ var refno
+ console.log("openNotify:"+event);
+ if(device.platform == "Android") {
+ refno = event.extras.refno
+ } else {
+ refno = event.refno
+ window.JPush.setApplicationIconBadgeNumber(0);
+ }
+ app.openBill(refno);
+ console.log("openNotify:"+refno);
+ }, false)
+ },
+ openBill:function(billno){
+ window.localStorage.setItem("currentrefno",billno);
+ window.location='billdetail.html';
+ },
+ initJpush: function() {
+ if(device.platform == "Android") {
+ } else {
+ window.JPush.setApplicationIconBadgeNumber(0);
+ }
+ window.JPush.init();
+ window.JPush.setDebugMode(true);
+ window.JPush.isPushStopped(function(result) {
+ if (result == 0) {
+ //window.JPush.resumePush();
+ } else {
+ window.JPush.resumePush();
+ }
+ });
+ window.JPush.getUserNotificationSettings(function(result) {
+ if(result == 0) {
+ } else if(result > 0) {
+ }
+ });
+ var uid = window.localStorage.getItem("uid");
+ window.JPush.setAlias({ sequence: 1, alias: uid },
+ (result) => {
+ var sequence = result.sequence
+ var alias = result.alias
+ //alert(JSON.stringify(result))
+ }, (error) => {
+ var sequence = error.sequence
+ var errorCode = error.code
+ //alert(JSON.stringify(error))
+ })
},
onDeviceReady: function() {
var uid = window.localStorage.getItem("token");
- console.log(CURRENT_INDEX);
+ this.initJpush();
$('#scanBtn').click(function() {
//window.location = "scan.html";
app.checkBefore(function() {
@@ -42,11 +92,12 @@
})
});
$('#secBtn').click(function() {
- app.checkBefore(function() {
+ window.location = "security.html";
+ /*app.checkBefore(function() {
app.checkOther(function() {
window.location = "security.html";
})
- })
+ })*/
});
$('#usersec').click(function() {
app.checkBefore(function() {
@@ -57,22 +108,23 @@
});
this.initData();
},
- initTab:function(){
+ initTab: function() {
$("#maincontent").css("top", $("#maintop").height())
var tab = new auiTab({
element: document.getElementById("footer"),
}, function(ret) {
- window.localStorage.setItem("tabindex",ret.index);
-
+ window.localStorage.setItem("tabindex", ret.index);
+
changeTab(ret.index);
});
- var tabindex = window.localStorage.getItem("tabindex");
- if(!tabindex||tabindex==0){
+ var tabindex = window.localStorage.getItem("tabindex");
+ if (!tabindex || tabindex == 0) {
tabindex = 1
}
changeTab(tabindex);
tab.setActive(tabindex)
- function changeTab(index){
+
+ function changeTab(index) {
if (index == 1) {
$("#main1").show();
$("#main2").hide();
@@ -93,8 +145,9 @@
}
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);
$("#maingt").text(ret.t + "!")
$("#user-amount").text(ret.amount)
$("#user-point").text(ret.point)
@@ -131,7 +184,17 @@
}
})
},
-
+ checkVersion:function(ver,minver,msg){
+ cordova.getAppVersion.getVersionNumber(function (version) {
+ //alert(version);
+ if(version<minver){
+ //TODO 强制升级
+ alert("当前版本过低,为了不影响您的使用,请先升级");
+ }else if(ver>version){
+ alert("有新的版本");
+ }
+ });
+ },
initBillView: function(page) {
var html = '';
for (var i = 0; i < page.data.length; i++) {
@@ -255,4 +318,4 @@
}
}
};
-app.initialize();
\ No newline at end of file
+app.initialize();
diff --git a/www/js/register.js b/www/js/register.js
index e0214ab..d10558e 100644
--- a/www/js/register.js
+++ b/www/js/register.js
@@ -33,7 +33,6 @@
$.hideLoading();
console.log(ret)
if(ret.code==200){
-
window.localStorage.setItem("phone",phone);
window.localStorage.setItem("uid",ret.uid);
window.localStorage.setItem("code",ret.randcode);
diff --git a/www/js/scan.js b/www/js/scan.js
index e75eba8..bb0a001 100644
--- a/www/js/scan.js
+++ b/www/js/scan.js
@@ -32,9 +32,9 @@
$.alert('扫描出错,请稍后再试:' + JSON.stringify(err), '提示');
} else {
// The scan completed, display the contents of the QR code:
- //$.alert(text, '提示');
- showRet(text);
QRScanner.destroy();
+ $.alert(text, '提示');
+ showRet(text);
}
}
//开始扫描,需要将页面的背景设置成透明
@@ -78,10 +78,11 @@
}
var userid = window.localStorage.getItem("userid");
if(url.indexOf("?")>0){
- url=url+'&uid='+userid;
+ url=url+'&userid='+userid;
}else{
- url=url+'?uid='+userid;
+ url=url+'?userid='+userid;
}
+ console.log(url)
inAppBrowserRef = cordova.ThemeableBrowser.open(url, '_blank', {
statusbar: {
color: '#03a9f4ff'
diff --git a/www/js/server.js b/www/js/server.js
index 2bd6a73..c8eb688 100644
--- a/www/js/server.js
+++ b/www/js/server.js
@@ -1,11 +1,12 @@
-var dev = true;
-var SERVER = "http://ykt.supwisdom.com:10010/payapi/mobileapi";
+var dev = false;
+var SERVER = "https://yy.dlsmk.cn/payapi/mobileapi";
var GLOBAL_TODAY="";
var GLOBAL_YESTERDAY="";
var CURRENT_INDEX=1;
if (dev) {
- SERVER = "http://172.28.43.3:8099/payapi/mobileapi";
+ SERVER = "http://172.28.201.70:10010/payapi/mobileapi";
}
+
function V1Qrcode(callback) {
ajaxPost("/v1/qrcode", {}, callback)
}
diff --git a/www/register.html b/www/register.html
index 640b3ee..34e5998 100644
--- a/www/register.html
+++ b/www/register.html
@@ -15,7 +15,7 @@
</head>
<body>
<header class="aui-bar aui-bar-nav" style="padding-top:25px;">
- <a class="aui-pull-left" href="javascript:window.history.back()">
+ <a class="aui-pull-left" href="login.html">
<span class="aui-iconfont aui-icon-left"></span>
</a>
<div class="aui-title">注册</div>
diff --git a/www/security.html b/www/security.html
index 049a988..39a40ca 100644
--- a/www/security.html
+++ b/www/security.html
@@ -50,7 +50,7 @@
</div>
</li>
</ul>
- <div style="padding: 20px;margin-top: 40px;">
+ <div style="padding: 20px;margin-top: 40px;">
<a href="javascript:app.logout();" class="weui-btn weui-btn_warn">退出登录</a>
</div>
</section>