假期作业进度七

Posted on 2019-02-23 00:20  咳咳你  阅读(134)  评论(0)    收藏  举报

最后是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) {
         
       }
     }
   }