Created
January 22, 2021 12:25
-
-
Save Natgho/0cf45ea1671fe8b8f69baeca9b34ed5f to your computer and use it in GitHub Desktop.
secondPageOfApp.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geolocation from '@system.geolocation'; | |
import battery from '@system.battery'; | |
export default { | |
data: { | |
index: 0, | |
latlon: "", | |
accuracy: 0, | |
battery: 0, | |
percentage: 0, | |
myInterval: NaN, | |
}, | |
updateData() { | |
var anchor = this; | |
geolocation.getLocation({ | |
success: function (data) { | |
anchor.latlon = "\n" + data.latitude + "\n" + data.longitude; | |
anchor.accuracy = data.accuracy; | |
} | |
}) | |
battery.getStatus({ | |
success: function (data) { | |
anchor.battery = data.level; | |
} | |
}) | |
}, | |
onInit() { | |
this.updateData(); | |
}, | |
startProgressBar(){ | |
var anchor = this; | |
anchor.myInterval = setInterval(function () { | |
if (anchor.percentage <= 100) { | |
anchor.percentage += 1; | |
} else { | |
anchor.percentage = 0; | |
} | |
}, 100); | |
}, | |
stopProgressBar(){ | |
var anchor = this; | |
clearInterval(anchor.myInterval); | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment