修改屏幕亮度和图标
diff --git a/www/js/qrcode.js b/www/js/qrcode.js
index 1b5a036..79ae312 100644
--- a/www/js/qrcode.js
+++ b/www/js/qrcode.js
@@ -1,16 +1,27 @@
+var brightness;
+var bvalue;
+var setted= false;
var app = {
// Application Constructor
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
-
onDeviceReady: function() {
var uid = window.localStorage.getItem("token");
- this.loadQrcode();
+ app.loadQrcode();
setInterval(function () {
window.location.reload();
},100000);
+
+ brightness = cordova.plugins.brightness;
+ if(brightness){
+ brightness.getBrightness(function(val){
+ bvalue = val;
+ }, function(err){
+ console.log(err);
+ });
+ }
},
loadQrcode: function() {
$.showLoading("加载中");
@@ -27,6 +38,38 @@
colorLight: "#ffffff",
correctLevel: QRCode.CorrectLevel.L
});
+ if(!setted&&brightness){
+ brightness.setBrightness(1, function(ret){
+ console.log(ret);
+ setted = true;
+ brightness.setKeepScreenOn(true);
+ }, function(e){
+ console.log(e)
+ });
+ }
+ } else {
+ $.hideLoading();
+ $.alert("请求失败,请稍后再试", "错误");
+ }
+ } else {
+ $.hideLoading();
+ $.alert("请求失败了:" + ret.status + "请稍后再试", "错误");
+ }
+ })
+ },
+ refresh:function(){
+ V1Qrcode(function(ok, ret) {
+ if (ok) {
+ if (ret.code == 200) {
+ $.hideLoading();
+ var qrcode = new QRCode(document.getElementById("qrcode"), {
+ text: ret.qrcode,
+ width: 200,
+ height: 200,
+ colorDark: "#000000",
+ colorLight: "#ffffff",
+ correctLevel: QRCode.CorrectLevel.L
+ });
} else {
$.hideLoading();
$.alert("请求失败,请稍后再试", "错误");
@@ -37,28 +80,15 @@
}
})
},
- refresh:function(){
- V1Qrcode(function(ok, ret) {
- if (ok) {
- if (ret.code == 200) {
- $.hideLoading();
- var qrcode = new QRCode(document.getElementById("qrcode"), {
- text: ret.qrcode,
- width: 150,
- height: 150,
- colorDark: "#000000",
- colorLight: "#ffffff",
- correctLevel: QRCode.CorrectLevel.L
- });
- } else {
- $.hideLoading();
- $.alert("请求失败,请稍后再试", "错误");
- }
- } else {
- $.hideLoading();
- $.alert("请求失败了:" + ret.status + "请稍后再试", "错误");
- }
- })
+ backTo:function(){
+ if(brightness&&bvalue){
+ brightness.setBrightness(bvalue, function(ret){
+ brightness.setKeepScreenOn(false);
+ }, function(e){
+ console.log(e)
+ });
+ }
+ window,location.href='main.html';
}
};
app.initialize();
\ No newline at end of file
diff --git a/www/qrcode.html b/www/qrcode.html
index ca6cb07..48e9b69 100644
--- a/www/qrcode.html
+++ b/www/qrcode.html
@@ -15,7 +15,7 @@
</head>
<body style="background: #fff" >
<header class="aui-bar aui-bar-nav" style="padding-top:25px;">
- <a class="aui-pull-left" href="main.html">
+ <a class="aui-pull-left" href="app.backTo()">
<span class="aui-iconfont aui-icon-left"></span>
</a>
<div class="aui-title">付款码</div>