62 lines
1.7 KiB
JavaScript
62 lines
1.7 KiB
JavaScript
const app = getApp()
|
|
Page({
|
|
data: {
|
|
sumToday:0,
|
|
sumBalance:0,
|
|
sumBudget:0,
|
|
sumUsed:0,
|
|
progress:0,
|
|
todayList: []
|
|
},
|
|
onLoad: function (options) {
|
|
},
|
|
onShow: function () {
|
|
app.$api.listBillsToday().then(x => {
|
|
if (x){
|
|
let todayList = x.data
|
|
this.setData({todayList})
|
|
}
|
|
})
|
|
app.$api.getBudgetIndex().then(res => {
|
|
if (res.data){
|
|
let sumToday = res.data.sumToday
|
|
let sumBalance = res.data.sumBalance
|
|
let sumBudget = res.data.sumBudget
|
|
let sumUsed = res.data.sumUsed
|
|
let progress = Math.floor(res.data.sumUsed / res.data.sumBudget * 10000) / 100
|
|
this.setData({sumToday,sumBalance,sumBudget,sumUsed,progress})
|
|
}
|
|
})
|
|
if (wx.canIUse('hideHomeButton')) {
|
|
wx.hideHomeButton()
|
|
}
|
|
let isRun = wx.getStorageSync("isRun");
|
|
if (!isRun) {
|
|
// this.startInter();
|
|
}
|
|
},
|
|
modifyBudget (){
|
|
wx.navigateTo({
|
|
url : '/pages/budget/index'
|
|
})
|
|
},
|
|
addBill() {
|
|
wx.navigateTo({
|
|
url : '/pages/bill/add/index'
|
|
})
|
|
},
|
|
/**
|
|
* 启动定时器
|
|
*/
|
|
startInter : function(){
|
|
wx.setStorageSync("isRun",true);
|
|
let times = 1;
|
|
setInterval(
|
|
function () {
|
|
times ++;
|
|
// 提交远程服务器修改的内容,降低服务器压力,如果网络异常,也可以正常操作
|
|
console.log('setInterval 每过500毫秒执行一次任务' + times)
|
|
}, 5000);
|
|
}
|
|
});
|