123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- let util = require('../../../utils/util.js');
- var that
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imageurl: util.imgurl,
- data: [],
- isfirst: true,
- typeindex: 0,
- types: [],
- },
- dateChange(e) {
- console.log(e)
- this.setData({
- param: {
- dim: e.detail.type,
- day: e.detail.year + '-' + e.detail.month + '-' + e.detail.day,
- month: e.detail.year + '-' + e.detail.month,
- year: e.detail.year,
- beginDate: e.detail.stime,
- endDate: e.detail.etime
- }
- })
- this.getList()
- },
- toadd(e) {
- wx.navigateTo({
- url: '/pages/stock/addpayrecord/addpayrecord',
- })
- },
- toedite(e) {
- wx.navigateTo({
- url: '/pages/stock/addpayrecord/addpayrecord?id=' + e.currentTarget.dataset.id,
- })
- },
- getList() {
- var data = this.data.param
- data = data ? data : {
- dim: 1,
- day: util.formatShortTime(new Date()),
- pageNo: 1,
- pageSize: 9999
- }
- if (this.data.typeindex && this.data.typeindex != '0') {
- data.expendTypeId = this.data.types[this.data.typeindex].id
- } else {
- delete data.expendTypeId
- }
- util.query('expend/wxapi/listpage', data, function(res) {
- if (res.code === 10000) {
- var total = 0
- res.data.content.forEach(function(e) {
- e.time = e.dateStr
- total += e.money
- })
- that.setData({
- data: res.data.content,
- total: total.toFixed(2)
- })
- } else {
- that.setData({
- data: [],
- total: 0
- })
- }
- })
- },
- typechange(e) {
- this.setData({
- typeindex: e.detail.value
- })
- this.getList()
- },
- getTypes() {
- util.query('expendtype/wxapi/list', {
- pageNo: 1,
- pageSize: 99999
- }, function(res) {
- if (res.code === 10000) {
- res.data.unshift({
- id: 0,
- name: '全部'
- })
- that.setData({
- types: res.data
- })
- }
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- that = this
- this.getList()
- this.getTypes()
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- if (!this.data.isfirst) {
- this.getList()
- }
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- this.setData({
- isfirst: false
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|