Commit e91ef76c by 李嘉林

亮度调节

parent 667e1cc7
......@@ -64,6 +64,7 @@ export default {
qrCode: "",
qrCodeImg: "",
userInfo: {},
currentBrightness: 0,
};
},
components: {},
......@@ -76,7 +77,18 @@ export default {
console.log("---onLoad");
},
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");
this.setScreenBrightness(1);
this.getQrCode();
this.TimeOut = null;
this.TimeOut = setInterval(() => {
......@@ -85,13 +97,25 @@ export default {
this.init();
},
onHide() {
this.setScreenBrightness(this.currentBrightness);
clearInterval(this.TimeOut);
},
onUnload() {
this.setScreenBrightness(this.currentBrightness);
clearInterval(this.TimeOut);
},
mounted() {},
methods: {
setScreenBrightness(val=0.7){
if (wx.setScreenBrightness) {
//设置屏幕亮度 参数值:0-1,越大越亮
wx.setScreenBrightness({
value: val
});
} else {
console.log("------微信版本过低------")
}
},
init() {
wx.showLoading({
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