最后是js,获取应用实例
//index.js
var util = require('../../utils/util.js')
var app = getApp()
Page({
data: {
todayExpend: "0",
monthExpend: "0",
yearExpend: "0",
todayRecord: [],
},
goRecord_expendTap:function(event){
wx.navigateTo({
url: '../record-expend/record-expend'
})
},
//今日账单item点击 onTodayBillItemClick: function (e) {
let index = e.currentTarget.dataset.index;
},
//今日账单item长按
ononTodayBillLongItemClick: function (e) {
},
onLoad: function () {
},
onShow: function () {
let bill;
const todayDate = util.formatTime(new Date(), "yyyy-MM-dd");
try {
bill = wx.getStorageSync('Bill');
} catch (e) {
}
if (bill != "") {
let todayMoney = 0;
let monthMoney = 0;
let yearMoney = 0;
let todayRecord = [];
for (let key of bill) {
if (util.dateIsDifference(key.date, todayDate, "d")) {
todayMoney += key.spendMoney;
todayRecord.push(key);
}
}
this.setData({
todayExpend: todayMoney,
todayRecord: todayRecord,
});
};
},
onShareAppMessage: function () {
return {
title: '账单',
path: 'pages/index/index',
success: function (res) {
},
fail: function (res) {
}
}
}
浙公网安备 33010602011771号