Commit e91ef76c by 李嘉林

亮度调节

parent 667e1cc7
...@@ -64,6 +64,7 @@ export default { ...@@ -64,6 +64,7 @@ export default {
qrCode: "", qrCode: "",
qrCodeImg: "", qrCodeImg: "",
userInfo: {}, userInfo: {},
currentBrightness: 0,
}; };
}, },
components: {}, components: {},
...@@ -76,7 +77,18 @@ export default { ...@@ -76,7 +77,18 @@ export default {
console.log("---onLoad"); console.log("---onLoad");
}, },
onShow() { onShow() {
let _this = this;
wx.getScreenBrightness({
success: (res)=>{
_this.currentBrightness = res.value
},
fail : (res)=>{
console.log(res,'-------getScreenBrightness--fail')
}
});
console.log(this.currentBrightness,'---currentBrightness');
console.log("---onShow"); console.log("---onShow");
this.setScreenBrightness(1);
this.getQrCode(); this.getQrCode();
this.TimeOut = null; this.TimeOut = null;
this.TimeOut = setInterval(() => { this.TimeOut = setInterval(() => {
...@@ -85,13 +97,25 @@ export default { ...@@ -85,13 +97,25 @@ export default {
this.init(); this.init();
}, },
onHide() { onHide() {
this.setScreenBrightness(this.currentBrightness);
clearInterval(this.TimeOut); clearInterval(this.TimeOut);
}, },
onUnload() { onUnload() {
this.setScreenBrightness(this.currentBrightness);
clearInterval(this.TimeOut); clearInterval(this.TimeOut);
}, },
mounted() {}, mounted() {},
methods: { methods: {
setScreenBrightness(val=0.7){
if (wx.setScreenBrightness) {
//设置屏幕亮度 参数值:0-1,越大越亮
wx.setScreenBrightness({
value: val
});
} else {
console.log("------微信版本过低------")
}
},
init() { init() {
wx.showLoading({ wx.showLoading({
title: "加载中...", title: "加载中...",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment