let util = require('../../../utils/util.js'); var that Page({ /** * 页面的初始数据 */ data: { imageurl: util.imgurl, baseImgUrl: util.baseImgUrl, isfirst: true }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { that = this util.checklogin( function() { that.getDefaultBook() } ) // var nb = wx.getStorageSync("nowbookid") // if (nb) { // this.setData({ // nowbookid: nb // }) // } }, nodo() {}, tomember(e) { wx.navigateTo({ url: '/pages/myinfo/bookmember/bookmember?id=' + e.currentTarget.dataset.id, }) }, del(e) { wx.showModal({ title: '确认', content: '是否确定删除账本', success(res) { if (res.confirm) { util.query("accountbook/wxapi/delete", { id: parseInt(e.currentTarget.dataset.id) }, function(res) { if (res.code == 10000) { util.showToast('删除成功') that.getList() } else { util.showToast(res.message) } }, "POST") } else if (res.cancel) { } } }) }, toedite(e) { wx.navigateTo({ url: '/pages/myinfo/createbook/createbook?id=' + e.currentTarget.dataset.id, }) }, setuse(e) { if (e.detail.value) { this.setdefault(e.currentTarget.dataset.id) } }, setdefault(id) { util.query('accountbook/wxapi/setdefault', { accountBookId: id }, function(res) { if (res.code === 10000) { that.getList(id) } }, 'POST') }, getDefaultBook() { util.query('accountbook/wxapi/getdefault', {}, function(res) { if (res.code === 10000) { that.getList(res.data.id) } }) }, getList(nowid) { util.query('accountbook/wxapi/list', { pageNo: 1, pageSize: 99999 }, function(res) { if (res.code === 10000) { res.data.forEach(function(e) { if (e.userInfos) { e.count = e.userInfos.length } else { e.count = 0 } if (nowid === e.id) { e.sel = true } else { e.sel = false } }) that.setData({ data: res.data }) } else { } }) }, tocreate() { wx.navigateTo({ url: '/pages/myinfo/createbook/createbook', }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function() { }, /** * 生命周期函数--监听页面显示 */ onShow: function() { if (!this.data.isfirst) { this.getList() } }, /** * 生命周期函数--监听页面隐藏 */ onHide: function() { this.setData({ isfirst: false }) }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function() { }, /** * 用户点击右上角分享 */ onShareAppMessage: function() { } })